@donotdev/ui 0.3.0 → 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.d.ts +17 -16
- package/dist/components/layout/components/header/HeaderMenu.d.ts.map +1 -1
- package/dist/components/layout/components/header/HeaderMenu.js +1 -47
- 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 +104 -17
- package/dist/dndev.css +104 -17
- 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 +104 -17
- 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 +4 -4
- 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
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
// packages/ui/src/vite-routing/AppRoutes.tsx
|
|
1
|
+
"use client";import{lazy as l,Suspense as y,useLayoutEffect as P}from"react";import{createBrowserRouter as L}from"react-router-dom";import{Spinner as h}from"@donotdev/components";import{applyFirstVisitLanguage as C,getLanguageRouting as w,splitLanguagePath as A,useLayout as m}from"@donotdev/core";import{RootLayout as B}from"./RootLayout.js";import{AuthGuard as x}from"../routing/AuthGuard.js";import{SignedInRedirect as G}from"../routing/SignedInRedirect.js";import{Fragment as S,jsx as o}from"react/jsx-runtime";var i=new Map;function k(){i.has("404")||i.set("404",l(()=>import("../routing/404.js")));let t=i.get("404");return o(y,{fallback:o(h,{overlay:!0}),children:o(t,{})})}var E=({component:e,path:t})=>{i.has(t)||i.set(t,l(e));let r=i.get(t);return o(y,{fallback:o(h,{overlay:!0}),children:o(r,{})})};function p(e){if(e&&typeof e=="object"&&"preset"in e){let t=e.preset;return typeof t=="string"?t:void 0}}function c(e){if(e&&typeof e=="object"&&"hideBreadcrumbs"in e){let t=e.hideBreadcrumbs;return typeof t=="boolean"?t:void 0}}function N(e){if(e&&typeof e=="object"&&"signedInRedirect"in e){let t=e.signedInRedirect;return typeof t=="string"?t:void 0}}function d(e){let t=o(E,{component:e.component,path:e.path}),r=N(e.meta);return r?o(G,{to:r,children:t}):t}var f=({preset:e,hideBreadcrumbs:t,children:r})=>{let a=m("setRoutePresetOverride"),u=m("setRouteHideBreadcrumbs");return P(()=>{a(e??null),u(t??!1)},[e,t,a,u]),o(S,{children:r})};function v(e){return typeof e=="boolean"?e?{required:!0}:!1:typeof e=="object"&&e!==null?e:!1}function D(e){let{routeGroups:t,basename:r,layout:a}=e,u=H(r),g=t.flatMap(n=>n.routes),s=g.find(n=>n.path==="/");if(!s)throw new Error("No HomePage.tsx found. Create src/pages/HomePage.tsx to define the root route.");let R=g.map(n=>({...n,parsedAuth:v(n.auth)})),b=[{path:"/",element:o(B,{layout:a}),children:[{index:!0,element:(s.auth&&typeof window<"u"&&import.meta.env.DEV,o(f,{preset:p(s.meta),hideBreadcrumbs:c(s.meta),children:d(s)}))},...R.filter(n=>n.path!=="/").map(n=>({path:n.path.startsWith("/")?n.path.slice(1):n.path,element:n.parsedAuth===!1?o(f,{preset:p(n.meta),hideBreadcrumbs:c(n.meta),children:d(n)}):o(f,{preset:p(n.meta),hideBreadcrumbs:c(n.meta),children:o(x,{auth:n.parsedAuth,children:d(n)})})})),{path:"*",element:o(k,{})}]}];return L(b,{basename:u})}function H(e){let t=w();C(t.languages,t.defaultLanguage);let r=e??"",{language:a,prefixed:u}=A(window.location.pathname.slice(r.length)||"/",t);return u?`${r}/${a}`:e}export{D as createAppRouter};
|
|
3
2
|
/**
|
|
4
3
|
* @fileoverview AppRoutes - Professional Route Configuration System
|
|
5
4
|
* @description Enterprise-grade routing with automatic discovery, authentication, and lazy loading
|
|
@@ -46,236 +45,3 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
46
45
|
* <RouterProvider router={router} />
|
|
47
46
|
* ```
|
|
48
47
|
*/
|
|
49
|
-
import { lazy, Suspense, useLayoutEffect } from 'react';
|
|
50
|
-
import { createBrowserRouter } from 'react-router-dom';
|
|
51
|
-
import { Spinner } from '@donotdev/components';
|
|
52
|
-
import { applyFirstVisitLanguage, getLanguageRouting, splitLanguagePath, useLayout, } from '@donotdev/core';
|
|
53
|
-
import { RootLayout } from './RootLayout';
|
|
54
|
-
import { AuthGuard } from '../routing/AuthGuard';
|
|
55
|
-
import { SignedInRedirect } from '../routing/SignedInRedirect';
|
|
56
|
-
// Cache lazy components to prevent recreation and infinite loops
|
|
57
|
-
const lazyComponentCache = new Map();
|
|
58
|
-
/**
|
|
59
|
-
* NotFoundPage component with lazy loading and caching
|
|
60
|
-
* Only loads when actually needed (404 route)
|
|
61
|
-
*/
|
|
62
|
-
function NotFoundPage() {
|
|
63
|
-
const cacheKey = '404';
|
|
64
|
-
// Use the same caching mechanism as dynamic routes
|
|
65
|
-
if (!lazyComponentCache.has(cacheKey)) {
|
|
66
|
-
lazyComponentCache.set(cacheKey, lazy(() => import('../routing/404')));
|
|
67
|
-
}
|
|
68
|
-
const LazyNotFoundPage = lazyComponentCache.get(cacheKey);
|
|
69
|
-
return (_jsx(Suspense, { fallback: _jsx(Spinner, { overlay: true }), children: _jsx(LazyNotFoundPage, {}) }));
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* LazyRoute - Optimized Component Loader
|
|
73
|
-
*
|
|
74
|
-
* Provides efficient lazy loading with caching to prevent component recreation
|
|
75
|
-
* and infinite loops. Uses the component function directly from route discovery.
|
|
76
|
-
*
|
|
77
|
-
* @param component - Lazy component function from route discovery
|
|
78
|
-
* @param path - Route path for caching
|
|
79
|
-
* @returns Lazy-loaded React component
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```tsx
|
|
83
|
-
* <LazyRoute component={route.component} path={route.path} />
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
const LazyRoute = ({ component, path, }) => {
|
|
87
|
-
if (!lazyComponentCache.has(path)) {
|
|
88
|
-
lazyComponentCache.set(path, lazy(component));
|
|
89
|
-
}
|
|
90
|
-
const Component = lazyComponentCache.get(path);
|
|
91
|
-
return (_jsx(Suspense, { fallback: _jsx(Spinner, { overlay: true }), children: _jsx(Component, {}) }));
|
|
92
|
-
};
|
|
93
|
-
/** Extract preset from route meta (meta is unknown at the interface level) */
|
|
94
|
-
function getRoutePreset(meta) {
|
|
95
|
-
if (meta && typeof meta === 'object' && 'preset' in meta) {
|
|
96
|
-
const preset = meta.preset;
|
|
97
|
-
return typeof preset === 'string' ? preset : undefined;
|
|
98
|
-
}
|
|
99
|
-
return undefined;
|
|
100
|
-
}
|
|
101
|
-
/** Extract hideBreadcrumbs from route meta */
|
|
102
|
-
function getRouteHideBreadcrumbs(meta) {
|
|
103
|
-
if (meta && typeof meta === 'object' && 'hideBreadcrumbs' in meta) {
|
|
104
|
-
const hide = meta.hideBreadcrumbs;
|
|
105
|
-
return typeof hide === 'boolean' ? hide : undefined;
|
|
106
|
-
}
|
|
107
|
-
return undefined;
|
|
108
|
-
}
|
|
109
|
-
/** Extract signedInRedirect (PageMeta) from route meta */
|
|
110
|
-
function getRouteSignedInRedirect(meta) {
|
|
111
|
-
if (meta && typeof meta === 'object' && 'signedInRedirect' in meta) {
|
|
112
|
-
const to = meta.signedInRedirect;
|
|
113
|
-
return typeof to === 'string' ? to : undefined;
|
|
114
|
-
}
|
|
115
|
-
return undefined;
|
|
116
|
-
}
|
|
117
|
-
/** Route page, inside SignedInRedirect when its PageMeta sets `signedInRedirect` */
|
|
118
|
-
function routePage(route) {
|
|
119
|
-
const page = _jsx(LazyRoute, { component: route.component, path: route.path });
|
|
120
|
-
const to = getRouteSignedInRedirect(route.meta);
|
|
121
|
-
return to ? _jsx(SignedInRedirect, { to: to, children: page }) : page;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* LayoutRoute - Per-route preset switcher
|
|
125
|
-
*
|
|
126
|
-
* Wraps route elements to apply the route's `meta.preset` override.
|
|
127
|
-
* On mount, sets the route preset override in the theme store.
|
|
128
|
-
* On unmount (navigation away), the next route's LayoutRoute sets its own value.
|
|
129
|
-
* Routes without a preset pass null, falling back to the app's default.
|
|
130
|
-
*
|
|
131
|
-
* Uses useLayoutEffect to apply before paint, avoiding visual flash.
|
|
132
|
-
*/
|
|
133
|
-
const LayoutRoute = ({ preset, hideBreadcrumbs, children, }) => {
|
|
134
|
-
const setRoutePresetOverride = useLayout('setRoutePresetOverride');
|
|
135
|
-
const setRouteHideBreadcrumbs = useLayout('setRouteHideBreadcrumbs');
|
|
136
|
-
useLayoutEffect(() => {
|
|
137
|
-
// Set route override (or null to clear and use app default)
|
|
138
|
-
setRoutePresetOverride(preset ?? null);
|
|
139
|
-
setRouteHideBreadcrumbs(hideBreadcrumbs ?? false);
|
|
140
|
-
}, [
|
|
141
|
-
preset,
|
|
142
|
-
hideBreadcrumbs,
|
|
143
|
-
setRoutePresetOverride,
|
|
144
|
-
setRouteHideBreadcrumbs,
|
|
145
|
-
]);
|
|
146
|
-
return _jsx(_Fragment, { children: children });
|
|
147
|
-
};
|
|
148
|
-
/**
|
|
149
|
-
* Parse auth configuration to PageAuth | false for AuthGuard
|
|
150
|
-
*
|
|
151
|
-
* Handles various auth configurations from route discovery:
|
|
152
|
-
* - boolean true: Convert to { required: true }
|
|
153
|
-
* - boolean false: Return false (public)
|
|
154
|
-
* - PageAuth object: Return as-is
|
|
155
|
-
* - function: Invalid config, default to public
|
|
156
|
-
* - undefined/null: Default to public
|
|
157
|
-
*
|
|
158
|
-
* @param auth - Auth configuration from route discovery
|
|
159
|
-
* @returns Clean PageAuth or false for AuthGuard
|
|
160
|
-
*/
|
|
161
|
-
function parseAuthConfig(auth) {
|
|
162
|
-
if (typeof auth === 'boolean') {
|
|
163
|
-
return auth ? { required: true } : false;
|
|
164
|
-
}
|
|
165
|
-
if (typeof auth === 'object' && auth !== null) {
|
|
166
|
-
return auth; // Return PageAuth object as-is
|
|
167
|
-
}
|
|
168
|
-
return false; // Default to public
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* createAppRouter - Router Factory Function
|
|
172
|
-
*
|
|
173
|
-
* Creates a configured React Router instance with automatic route discovery,
|
|
174
|
-
* authentication, lazy loading, and error handling.
|
|
175
|
-
*
|
|
176
|
-
* This factory function replaces the component-based approach with React Router v7's
|
|
177
|
-
* data router pattern (createBrowserRouter). It discovers routes at creation time
|
|
178
|
-
* and returns a router instance ready for use with RouterProvider.
|
|
179
|
-
*
|
|
180
|
-
* Features:
|
|
181
|
-
* - Automatic route discovery from filesystem
|
|
182
|
-
* - Lazy loading with code splitting
|
|
183
|
-
* - Authentication integration via AuthGuard
|
|
184
|
-
* - SEO-friendly root route
|
|
185
|
-
* - Native scroll restoration
|
|
186
|
-
* - Optional layout wrapper integration
|
|
187
|
-
*
|
|
188
|
-
* @param options - Router configuration options
|
|
189
|
-
* @returns Configured router instance for RouterProvider
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* ```tsx
|
|
193
|
-
* const groups = useRouteDiscovery();
|
|
194
|
-
* const router = createAppRouter({
|
|
195
|
-
* routeGroups: groups
|
|
196
|
-
* });
|
|
197
|
-
* <RouterProvider router={router} />
|
|
198
|
-
* ```
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* ```tsx
|
|
202
|
-
* // With basename and layout config
|
|
203
|
-
* const groups = useRouteDiscovery();
|
|
204
|
-
* const router = createAppRouter({
|
|
205
|
-
* routeGroups: groups,
|
|
206
|
-
* basename: '/app',
|
|
207
|
-
* layout: { header: () => <CustomHeader /> }
|
|
208
|
-
* });
|
|
209
|
-
* <RouterProvider router={router} />
|
|
210
|
-
* ```
|
|
211
|
-
*/
|
|
212
|
-
export function createAppRouter(options) {
|
|
213
|
-
const { routeGroups, basename, layout } = options;
|
|
214
|
-
const routerBasename = languageBasename(basename);
|
|
215
|
-
// Find HomePage route (path "/")
|
|
216
|
-
const allRoutes = routeGroups.flatMap((group) => group.routes);
|
|
217
|
-
const homePageRoute = allRoutes.find((route) => route.path === '/');
|
|
218
|
-
if (!homePageRoute) {
|
|
219
|
-
throw new Error('No HomePage.tsx found. Create src/pages/HomePage.tsx to define the root route.');
|
|
220
|
-
}
|
|
221
|
-
// Pre-parse auth configs for all routes
|
|
222
|
-
const routesWithParsedAuth = allRoutes.map((route) => ({
|
|
223
|
-
...route,
|
|
224
|
-
parsedAuth: parseAuthConfig(route.auth),
|
|
225
|
-
}));
|
|
226
|
-
// Build route configuration
|
|
227
|
-
const routeConfig = [
|
|
228
|
-
{
|
|
229
|
-
/** Root route - HomePage.tsx is automatically assigned path "/" by convention */
|
|
230
|
-
path: '/',
|
|
231
|
-
element: _jsx(RootLayout, { layout: layout }),
|
|
232
|
-
children: [
|
|
233
|
-
{
|
|
234
|
-
/** HomePage route - lazy loaded, public (no AuthGuard).
|
|
235
|
-
* Auth config on HomePage is intentionally ignored — use a different page as entry. */
|
|
236
|
-
index: true,
|
|
237
|
-
element: (() => {
|
|
238
|
-
if (homePageRoute.auth &&
|
|
239
|
-
typeof window !== 'undefined' &&
|
|
240
|
-
import.meta.env.DEV) {
|
|
241
|
-
console.warn('[DoNotDev] HomePage has auth config but the index route is always public. ' +
|
|
242
|
-
'Auth config on HomePage is ignored. Use a different page as your protected entry point.');
|
|
243
|
-
}
|
|
244
|
-
return (_jsx(LayoutRoute, { preset: getRoutePreset(homePageRoute.meta), hideBreadcrumbs: getRouteHideBreadcrumbs(homePageRoute.meta), children: routePage(homePageRoute) }));
|
|
245
|
-
})(),
|
|
246
|
-
},
|
|
247
|
-
/** All other routes are discovered and rendered here */
|
|
248
|
-
...routesWithParsedAuth
|
|
249
|
-
.filter((route) => route.path !== '/')
|
|
250
|
-
.map((route) => ({
|
|
251
|
-
path: route.path.startsWith('/') ? route.path.slice(1) : route.path,
|
|
252
|
-
element: route.parsedAuth === false ? (_jsx(LayoutRoute, { preset: getRoutePreset(route.meta), hideBreadcrumbs: getRouteHideBreadcrumbs(route.meta), children: routePage(route) })) : (_jsx(LayoutRoute, { preset: getRoutePreset(route.meta), hideBreadcrumbs: getRouteHideBreadcrumbs(route.meta), children: _jsx(AuthGuard, { auth: route.parsedAuth, children: routePage(route) }) })),
|
|
253
|
-
})),
|
|
254
|
-
// 404 catch-all route (must be last)
|
|
255
|
-
{
|
|
256
|
-
path: '*',
|
|
257
|
-
element: _jsx(NotFoundPage, {}),
|
|
258
|
-
},
|
|
259
|
-
],
|
|
260
|
-
},
|
|
261
|
-
];
|
|
262
|
-
// Create and return router instance
|
|
263
|
-
return createBrowserRouter(routeConfig, { basename: routerBasename });
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Router basename for the URL's language: `/en` on `/en/…` (other languages live under
|
|
267
|
-
* their prefix, the default language at the root), so routes, links and useLocation
|
|
268
|
-
* work with app paths. A first visit to an unprefixed URL moves to the visitor's
|
|
269
|
-
* language first (same rule as the Next proxy). One language: the basename unchanged.
|
|
270
|
-
*
|
|
271
|
-
* @param basename - App basename, if the app is not served at the domain root
|
|
272
|
-
*/
|
|
273
|
-
function languageBasename(basename) {
|
|
274
|
-
const routing = getLanguageRouting();
|
|
275
|
-
applyFirstVisitLanguage(routing.languages, routing.defaultLanguage);
|
|
276
|
-
const appBase = basename ?? '';
|
|
277
|
-
const { language, prefixed } = splitLanguagePath(window.location.pathname.slice(appBase.length) || '/', routing);
|
|
278
|
-
if (!prefixed)
|
|
279
|
-
return basename;
|
|
280
|
-
return `${appBase}/${language}`;
|
|
281
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RootLayout.d.ts","sourceRoot":"","sources":["../../src/vite-routing/RootLayout.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RootLayout.d.ts","sourceRoot":"","sources":["../../src/vite-routing/RootLayout.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAuLnD;;GAEG;AACH,UAAU,oBAAoB;IAC5B,2BAA2B;IAC3B,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE,oBAAoB,+BAiC1D"}
|
|
@@ -1,205 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
// packages/ui/src/vite-routing/RootLayout.tsx
|
|
3
|
-
/**
|
|
4
|
-
* @fileoverview RootLayout - Root route layout component
|
|
5
|
-
* @description Wraps all routes with QueryProviders, UIProviders, and Layout
|
|
6
|
-
*
|
|
7
|
-
* This component is rendered as the root route element in the React Router v7
|
|
8
|
-
* data router configuration. It provides the core provider hierarchy for all
|
|
9
|
-
* routes in the application.
|
|
10
|
-
*
|
|
11
|
-
* @version 0.1.0
|
|
12
|
-
* @since 0.0.1
|
|
13
|
-
* @author AMBROISE PARK Consulting
|
|
14
|
-
*/
|
|
15
|
-
import { Suspense, lazy, useEffect, useLayoutEffect, useRef } from 'react';
|
|
16
|
-
import { Outlet, useLocation } from 'react-router-dom';
|
|
17
|
-
import { globalEmitter, isClient, QueryProviders } from '@donotdev/core';
|
|
18
|
-
import { DnDevLayout } from '../internal/layout/DnDevLayout';
|
|
19
|
-
import { UIProviders } from '../internal/providers/UIProviders';
|
|
20
|
-
import { AuthReturnTo } from '../routing/AuthReturnTo';
|
|
21
|
-
import { PasswordResetCallback } from '../utils/useAuthSafe';
|
|
22
|
-
// Only lazy load non-critical components (not in render path)
|
|
23
|
-
const AutoMetaTags = lazy(() => import('../internal/layout/components/AutoMetaTags').then((m) => ({
|
|
24
|
-
default: m.default,
|
|
25
|
-
})));
|
|
26
|
-
const ConsentBanner = lazy(() => import('../components/cookie-consent/ConsentBanner').then((m) => ({
|
|
27
|
-
default: m.default,
|
|
28
|
-
})));
|
|
29
|
-
const PWAUpdateNotification = lazy(() => import('../internal/layout/components/PWAUpdateNotification').then((m) => ({
|
|
30
|
-
default: m.default,
|
|
31
|
-
})));
|
|
32
|
-
const RedirectOverlay = lazy(() => import('../components/common/RedirectOverlay').then((m) => ({
|
|
33
|
-
default: m.RedirectOverlay,
|
|
34
|
-
})));
|
|
35
|
-
/**
|
|
36
|
-
* CustomScrollRestoration - Scroll restoration for custom scroll containers
|
|
37
|
-
*
|
|
38
|
-
* React Router's <ScrollRestoration /> only works with window-level scrolling.
|
|
39
|
-
* Our layout uses main[role='main'] as the scroll container (overflow-y: auto),
|
|
40
|
-
* so we need custom scroll restoration logic.
|
|
41
|
-
*
|
|
42
|
-
* Behavior:
|
|
43
|
-
* - New navigation (PUSH): Scroll main element to top
|
|
44
|
-
* - Back/Forward (POP): Restore previous scroll position
|
|
45
|
-
*
|
|
46
|
-
* @version 0.1.0
|
|
47
|
-
* @since 0.0.1
|
|
48
|
-
* @author AMBROISE PARK Consulting
|
|
49
|
-
*/
|
|
50
|
-
function CustomScrollRestoration() {
|
|
51
|
-
const location = useLocation();
|
|
52
|
-
const scrollPositions = useRef(new Map());
|
|
53
|
-
const prevLocationKey = useRef(null);
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
const mainElement = document.querySelector('main[role="main"]');
|
|
56
|
-
if (!mainElement)
|
|
57
|
-
return;
|
|
58
|
-
// main is always the sole scroll container (overflow-y: auto)
|
|
59
|
-
// Save scroll position of the page we're leaving
|
|
60
|
-
if (prevLocationKey.current) {
|
|
61
|
-
scrollPositions.current.set(prevLocationKey.current, mainElement.scrollTop);
|
|
62
|
-
}
|
|
63
|
-
// Check if this is a back/forward navigation (POP) by checking saved position
|
|
64
|
-
const saved = scrollPositions.current.get(location.key);
|
|
65
|
-
if (saved !== undefined) {
|
|
66
|
-
// POP navigation - restore scroll position
|
|
67
|
-
requestAnimationFrame(() => {
|
|
68
|
-
mainElement.scrollTop = saved;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
// PUSH navigation - scroll to top
|
|
73
|
-
mainElement.scrollTop = 0;
|
|
74
|
-
}
|
|
75
|
-
prevLocationKey.current = location.key;
|
|
76
|
-
// Cleanup: Keep only last 20 positions to prevent memory leaks
|
|
77
|
-
if (scrollPositions.current.size > 20) {
|
|
78
|
-
for (const key of scrollPositions.current.keys()) {
|
|
79
|
-
scrollPositions.current.delete(key);
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}, [location.pathname, location.key]);
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* FrameworkReadySignal - Signals when framework providers are painted
|
|
88
|
-
*
|
|
89
|
-
* Framework responsibility: Show shell loader while framework sets up (stores, providers).
|
|
90
|
-
* Customer responsibility: Handle their own loading states via Suspense boundaries.
|
|
91
|
-
*
|
|
92
|
-
* This component signals when the FRAMEWORK is ready (providers painted),
|
|
93
|
-
* NOT when customer content is ready. Customer's Suspense fallbacks handle that gap.
|
|
94
|
-
*
|
|
95
|
-
* Uses useLayoutEffect to detect when framework providers (UIProviders wrapper) are painted.
|
|
96
|
-
* Dispatches 'DNDEV_FRAMEWORK_READY' event for shell loader removal coordination.
|
|
97
|
-
*
|
|
98
|
-
* @version 0.1.0
|
|
99
|
-
* @since 0.0.1
|
|
100
|
-
* @author AMBROISE PARK Consulting
|
|
101
|
-
*/
|
|
102
|
-
function FrameworkReadySignal({ children }) {
|
|
103
|
-
const hasSignaled = useRef(false);
|
|
104
|
-
const frameworkRef = useRef(null);
|
|
105
|
-
useLayoutEffect(() => {
|
|
106
|
-
if (!isClient() || hasSignaled.current)
|
|
107
|
-
return;
|
|
108
|
-
const checkAndSignal = () => {
|
|
109
|
-
if (hasSignaled.current)
|
|
110
|
-
return;
|
|
111
|
-
const element = frameworkRef.current;
|
|
112
|
-
if (!element)
|
|
113
|
-
return;
|
|
114
|
-
requestAnimationFrame(() => {
|
|
115
|
-
const rect = element.getBoundingClientRect();
|
|
116
|
-
const hasVisibleFramework = rect.width > 0 && rect.height > 0;
|
|
117
|
-
if (hasVisibleFramework) {
|
|
118
|
-
hasSignaled.current = true;
|
|
119
|
-
requestAnimationFrame(() => {
|
|
120
|
-
requestAnimationFrame(() => {
|
|
121
|
-
globalEmitter.emit('DNDEV_FRAMEWORK_READY');
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
checkAndSignal();
|
|
128
|
-
const timeout = setTimeout(() => {
|
|
129
|
-
if (!hasSignaled.current) {
|
|
130
|
-
hasSignaled.current = true;
|
|
131
|
-
globalEmitter.emit('DNDEV_FRAMEWORK_READY');
|
|
132
|
-
}
|
|
133
|
-
}, 500);
|
|
134
|
-
return () => {
|
|
135
|
-
clearTimeout(timeout);
|
|
136
|
-
};
|
|
137
|
-
}, []);
|
|
138
|
-
return _jsx("div", { ref: frameworkRef, children: children });
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* RouteReadySignal - Signals when route content is painted
|
|
142
|
-
*
|
|
143
|
-
* Emits 'DNDEV_ROUTE_READY' event when route content (inside Suspense) is painted.
|
|
144
|
-
* Used in coordination with FrameworkReadySignal to time shell loader removal.
|
|
145
|
-
*
|
|
146
|
-
* Shell loader removed only when BOTH framework AND route are ready,
|
|
147
|
-
* preventing "late arrival" of route content after Header/Footer paint.
|
|
148
|
-
*
|
|
149
|
-
* @version 0.1.0
|
|
150
|
-
* @since 0.0.1
|
|
151
|
-
* @author AMBROISE PARK Consulting
|
|
152
|
-
*/
|
|
153
|
-
function RouteReadySignal({ children }) {
|
|
154
|
-
const hasSignaled = useRef(false);
|
|
155
|
-
useLayoutEffect(() => {
|
|
156
|
-
if (!isClient() || hasSignaled.current)
|
|
157
|
-
return;
|
|
158
|
-
// Wait for two animation frames to ensure paint completion
|
|
159
|
-
requestAnimationFrame(() => {
|
|
160
|
-
requestAnimationFrame(() => {
|
|
161
|
-
if (hasSignaled.current)
|
|
162
|
-
return;
|
|
163
|
-
hasSignaled.current = true;
|
|
164
|
-
globalEmitter.emit('DNDEV_ROUTE_READY');
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
}, []);
|
|
168
|
-
return _jsx(_Fragment, { children: children });
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* RootLayout - Root route layout component
|
|
172
|
-
*
|
|
173
|
-
* Provides the core provider hierarchy for all routes:
|
|
174
|
-
* - QueryProviders (React Query)
|
|
175
|
-
* - UIProviders (design system, error boundaries)
|
|
176
|
-
* - AutoMetaTags (SEO)
|
|
177
|
-
* - FrameworkReadySignal (framework initialization signal)
|
|
178
|
-
* - Layout (application layout with slots)
|
|
179
|
-
* - ConsentBanner (cookie consent)
|
|
180
|
-
* - PWAUpdateNotification (PWA update notifications)
|
|
181
|
-
*
|
|
182
|
-
* Wraps <Outlet /> which renders child routes.
|
|
183
|
-
*
|
|
184
|
-
* @param props - RootLayout props
|
|
185
|
-
* @returns Root layout with providers
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
* ```tsx
|
|
189
|
-
* // Used in route configuration
|
|
190
|
-
* const routes = [
|
|
191
|
-
* {
|
|
192
|
-
* path: '/',
|
|
193
|
-
* element: <RootLayout layout={layoutConfig} />,
|
|
194
|
-
* children: [...]
|
|
195
|
-
* }
|
|
196
|
-
* ];
|
|
197
|
-
* ```
|
|
198
|
-
*
|
|
199
|
-
* @version 0.1.0
|
|
200
|
-
* @since 0.0.1
|
|
201
|
-
* @author AMBROISE PARK Consulting
|
|
202
|
-
*/
|
|
203
|
-
export function RootLayout({ layout }) {
|
|
204
|
-
return (_jsx(QueryProviders, { children: _jsxs(UIProviders, { children: [_jsx(Suspense, { fallback: null, children: _jsx(AutoMetaTags, {}) }), _jsxs(FrameworkReadySignal, { children: [_jsx(DnDevLayout, { layout: layout, children: _jsx(RouteReadySignal, { children: _jsx(Outlet, {}) }) }), _jsx(CustomScrollRestoration, {}), _jsx(AuthReturnTo, {}), _jsxs(Suspense, { fallback: null, children: [_jsx(ConsentBanner, {}), _jsx(PasswordResetCallback, {}), _jsx(PWAUpdateNotification, {}), _jsx(RedirectOverlay, {})] })] })] }) }));
|
|
205
|
-
}
|
|
1
|
+
"use client";import{Suspense as f,lazy as c,useEffect as p,useLayoutEffect as d,useRef as i}from"react";import{Outlet as y,useLocation as g}from"react-router-dom";import{globalEmitter as l,isClient as R,QueryProviders as D}from"@donotdev/core";import{DnDevLayout as h}from"../internal/layout/DnDevLayout.js";import{UIProviders as k}from"../internal/providers/UIProviders.js";import{AuthReturnTo as v}from"../routing/AuthReturnTo.js";import{PasswordResetCallback as A}from"../utils/useAuthSafe.js";import{Fragment as w,jsx as r,jsxs as s}from"react/jsx-runtime";var E=c(()=>import("../internal/layout/components/AutoMetaTags.js").then(e=>({default:e.default}))),S=c(()=>import("../components/cookie-consent/ConsentBanner.js").then(e=>({default:e.default}))),F=c(()=>import("../internal/layout/components/PWAUpdateNotification.js").then(e=>({default:e.default}))),L=c(()=>import("../components/common/RedirectOverlay.js").then(e=>({default:e.RedirectOverlay})));function P(){let e=g(),t=i(new Map),n=i(null);return p(()=>{let o=document.querySelector('main[role="main"]');if(!o)return;n.current&&t.current.set(n.current,o.scrollTop);let u=t.current.get(e.key);if(u!==void 0?requestAnimationFrame(()=>{o.scrollTop=u}):o.scrollTop=0,n.current=e.key,t.current.size>20)for(let a of t.current.keys()){t.current.delete(a);break}},[e.pathname,e.key]),null}function T({children:e}){let t=i(!1),n=i(null);return d(()=>{if(!R()||t.current)return;(()=>{if(t.current)return;let a=n.current;a&&requestAnimationFrame(()=>{let m=a.getBoundingClientRect();m.width>0&&m.height>0&&(t.current=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>{l.emit("DNDEV_FRAMEWORK_READY")})}))})})();let u=setTimeout(()=>{t.current||(t.current=!0,l.emit("DNDEV_FRAMEWORK_READY"))},500);return()=>{clearTimeout(u)}},[]),r("div",{ref:n,children:e})}function b({children:e}){let t=i(!1);return d(()=>{!R()||t.current||requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.current||(t.current=!0,l.emit("DNDEV_ROUTE_READY"))})})},[]),r(w,{children:e})}function K({layout:e}){return r(D,{children:s(k,{children:[r(f,{fallback:null,children:r(E,{})}),s(T,{children:[r(h,{layout:e,children:r(b,{children:r(y,{})})}),r(P,{}),r(v,{}),s(f,{fallback:null,children:[r(S,{}),r(A,{}),r(F,{}),r(L,{})]})]})]})})}export{K as RootLayout};
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Vite-specific routing exports
|
|
4
|
-
* @description React Router based routing components for Vite applications only
|
|
5
|
-
*
|
|
6
|
-
* @version 0.1.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
export * from './AppRoutes';
|
|
11
|
-
export * from './RootLayout';
|
|
1
|
+
export*from"./AppRoutes.js";export*from"./RootLayout.js";
|
package/dist/vite.js
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Vite App Providers
|
|
4
|
-
* @description Vite-specific app providers and routing exports
|
|
5
|
-
*
|
|
6
|
-
* @version 0.1.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
export { ViteAppProviders } from './providers/ViteAppProviders';
|
|
1
|
+
import{ViteAppProviders as o}from"./providers/ViteAppProviders.js";export{o as ViteAppProviders};
|
package/guidelines/COMPONENTS.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
- **Breadcrumbs** - Breadcrumb navigation component.
|
|
24
24
|
- **HeaderNavigation** - Header navigation menu component.
|
|
25
25
|
- **DropdownNavigation** - Dropdown navigation menu.
|
|
26
|
-
- **HeaderMenu** - Header
|
|
26
|
+
- **HeaderMenu** - Header controls inline from 1024px up, behind a hamburger below (CSS switch, no hydration swap). Popups inside it (DropdownMenu, Dialog) work from the burger panel.
|
|
27
27
|
- **SettingsMenu** - Settings menu component.
|
|
28
28
|
- **ThemeToggle** - Theme toggle button component.
|
|
29
29
|
- **CacheSettings** - Cache settings component.
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
## Common Components
|
|
49
49
|
|
|
50
50
|
- **FeatureDisabled** - Component shown when features are disabled.
|
|
51
|
-
- **Icon** - Icon component wrapper.
|
|
51
|
+
- **Icon** - Icon component wrapper. `icon`: Lucide component (`{Rocket}`, static), emoji, ReactNode, or Lucide name string (`"Rocket"`): theme icons (`--theme-icon`) render statically from the build-time registry, any other name loads as its own chunk (same-size placeholder meanwhile, none in server HTML; unknown names show `Palette`). Prefer components for server-rendered icons.
|
|
52
52
|
- **ProgressBar** - Progress bar component.
|
|
53
53
|
- **Skeleton** - Skeleton loading component (consumer use, not used internally).
|
|
54
54
|
- **FeatureCard** - Feature showcase card component.
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
|
|
59
59
|
## Routing Components
|
|
60
60
|
|
|
61
|
-
- **Link** - Platform-agnostic link component (works in Vite + Next.js).
|
|
61
|
+
- **Link** - Platform-agnostic link component (works in Vite + Next.js). Internal paths render `next/link` on Next.js (route prefetch by default, in full for signed-in visitors; `prefetch={false}` disables it) and a react-router `<a href>` on Vite. See ROUTING.md.
|
|
62
62
|
- **AuthGuard** - Route guard component for protected routes.
|
|
63
63
|
- **AuthGuardFallback** - Fallback component for auth-guarded routes.
|
|
64
64
|
- **GoTo** - Programmatic navigation component.
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
## Cookie Consent
|
|
93
93
|
|
|
94
94
|
- **CookieConsent** - Cookie consent management component.
|
|
95
|
-
- **ConsentBanner** - Cookie consent banner component.
|
|
95
|
+
- **ConsentBanner** - Cookie consent banner component. Renders nothing when the app sets only strictly necessary cookies (`features.requiredCookies` has no `functional`/`analytics`/`marketing`); the `#cookie-settings` footer link is then hidden too.
|
|
96
96
|
|
|
97
97
|
---
|
|
98
98
|
|
package/guidelines/PAGES.md
CHANGED
|
@@ -180,7 +180,10 @@ import { useCrud } from '@donotdev/crud';
|
|
|
180
180
|
|
|
181
181
|
**Sub-path exceptions** (server, config, and provider-specific):
|
|
182
182
|
- **Server:** `@donotdev/core/server`, `@donotdev/firebase/server`, `@donotdev/security/server`
|
|
183
|
+
- **Server components (Next only):** `@donotdev/core/rsc` (`useTranslation`, `setRequestLanguage`; see core `I18N.md`), `@donotdev/components/rsc`, `@donotdev/ui/rsc`. They resolve only in React Server Components (`react-server` condition); importing them anywhere else fails the build.
|
|
183
184
|
- **Config:** `@donotdev/core/vite`, `@donotdev/core/next`, `@donotdev/core/functions`
|
|
185
|
+
|
|
186
|
+
**`@donotdev/components/rsc` / `@donotdev/ui/rsc`** export the same names as the package root. Presentational components (Stack, Text, Grid, Button…) render on the server. Interactive ones (hooks, Radix, context, event handlers, browser APIs: Card, Dialog, PageContainer…) carry their own `'use client'` and render as client islands. Calling one of their hooks or helpers from a server component throws. The package roots (`@donotdev/components`, `@donotdev/ui`) are unchanged: client barrels everywhere, including server files. Nothing imports the `/rsc` entries yet, so apps render exactly as before until a later phase adopts them. Vite never uses them.
|
|
184
187
|
- **Functions:** `@donotdev/functions/firebase`, `@donotdev/functions/vercel`, `@donotdev/functions/supabase`
|
|
185
188
|
|
|
186
189
|
---
|
package/guidelines/ROUTING.md
CHANGED
|
@@ -39,6 +39,12 @@ import { Link, DnDevNavigationMenu } from '@donotdev/ui';
|
|
|
39
39
|
<Link path="/users/:id" replace prefetch={false}>User Details</Link>
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
Internal paths render a real `<a href>` on both platforms (via `@donotdev/ui/routing/link`, resolved like `routing/hooks`):
|
|
43
|
+
- **Next.js:** `next/link`. `prefetch` (default `true`): guests get next/link's default prefetch (production only: static routes fully, dynamic routes up to the nearest `loading.js`); signed-in visitors (`useAuth('isAuthenticated')`, cookie snapshot until the provider is ready) get `prefetch={true}`, the full route of each visible link, because their pages render per request (session tree) and the default skips them. `prefetch={false}` disables it for everyone. An `onClick` calling `preventDefault()` cancels the navigation.
|
|
44
|
+
- **Vite:** `<a href>` navigated by react-router; `prefetch` has no effect.
|
|
45
|
+
- Modifier / middle clicks keep the browser default (new tab). External URLs (`http(s)`, `mailto:`, `tel:`) are plain `<a target="_blank">`. Cards (`href`) and Tables render links through `Link`, so they get the same behaviour.
|
|
46
|
+
- String `icon` names (`"Package"`) load per icon (own chunk); prefer an imported component (`icon={Package}`) for server-rendered icons.
|
|
47
|
+
|
|
42
48
|
**DnDevNavigationMenu (Sidebar/Header):**
|
|
43
49
|
```tsx
|
|
44
50
|
// Auto-fetches routes, handles auth filtering
|
|
@@ -72,6 +78,15 @@ not-found wrappers opt into this generic, badge-free content. This prop hides on
|
|
|
72
78
|
the path badge; translated labels, route suggestions and Home/Back actions remain
|
|
73
79
|
server-renderable. It does not disable SSR or defer navigation until mount.
|
|
74
80
|
|
|
81
|
+
The badge is not the only URL-derived output. The static Next 404 is built once (at
|
|
82
|
+
`/_not-found`) and served for every unknown URL, so anything computed from the
|
|
83
|
+
pathname differs between its HTML and the browser's render (React #418). The
|
|
84
|
+
generated not-found and global not-found pages wrap their tree in
|
|
85
|
+
`<NotFoundDocument>` (`@donotdev/ui`): inside it, `AutoMetaTags` emits no canonical
|
|
86
|
+
link and no URL-derived JSON-LD, and `Breadcrumbs` renders nothing. A hand-written
|
|
87
|
+
shared 404 must do the same. Apps that set `breadcrumbs: 'never'` in their layout
|
|
88
|
+
still need it for the head tags.
|
|
89
|
+
|
|
75
90
|
The canonical translation text is `dndev:messages.notFound.*`. Framework eager
|
|
76
91
|
locales expose `errors.notFound.{title,description,suggestions,navigateTo,goHome,goBack}`
|
|
77
92
|
as explicit i18next `$t(messages.notFound.<key>)` compatibility references, not
|
package/guidelines/SEO.md
CHANGED
|
@@ -245,9 +245,12 @@ defineEntity({
|
|
|
245
245
|
Both list the same pages, generated from `src/pages` - no app code:
|
|
246
246
|
|
|
247
247
|
- **In:** public static routes, plus one URL per public record (`status` not in `HIDDEN_STATUSES`: any status except `draft`/`deleted`) of each single-param route's entity (`/produits/:slug` → `meta.entity` collection). Never a `:param` template.
|
|
248
|
-
- **Out:** `auth.required` routes
|
|
248
|
+
- **Out:** `auth.required` routes, `seo: { noindex: true }` routes and error routes (`/404`, `/not-found`, `/500`, `/error`).
|
|
249
|
+
- **RSS:** `<link rel="alternate" type="application/rss+xml">` to `/rss.xml` is in the head only when the app has blog posts (`src/content/blog/*_en.md`), the condition under which the feed is generated (`routes.manifest.hasBlogFeed`).
|
|
249
250
|
- **URLs:** absolute, from `seo.baseUrl` or `NEXT_PUBLIC_APP_URL` / `VITE_APP_URL`. A production build with a localhost URL fails.
|
|
250
251
|
- **llms.txt labels (app default language):** page = namespace `title` → `seo.title` → namespace `meta.fullTitle` → `seo.fullTitle` (a static page with none fails the build); entity record = `deriveEntitySeo` title/description (same as `<Seo entity data>`); entity section = `namePlural` of its `entity-*` translations.
|
|
252
|
+
- **Prerendered pages (Next):** the same records fill each entity page's `generateStaticParams` (`listStaticParams`, one route → collection decision `publicCollection`): every URL of the sitemap's dynamic routes is built at build time (`appConfig.prerenderRecords: false` to opt out).
|
|
253
|
+
- **Reader (Next):** records are read on the server as a signed-out visitor, from the app's public env, never a privileged key: `@donotdev/supabase` (RLS decides) or `@donotdev/firebase` (`@donotdev/firebase/public`, Firestore Security Rules decide; they must allow the whole `status not-in` query). Any other provider fails the build when a route lists records.
|
|
251
254
|
- **Next:** `src/app/sitemap.xml/route.next.ts` and `src/app/llms.txt/route.next.ts`, revalidated hourly (`appConfig.revalidate`: other lifetime in seconds, or `false` until the next deploy). Entity definitions come from the app's `entities` package.
|
|
252
255
|
- **Vite:** written at build; static pages only (same as the Vite sitemap).
|
|
253
256
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@donotdev/ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"import": "./dist/index.js",
|
|
14
14
|
"default": "./dist/index.js"
|
|
15
15
|
},
|
|
16
|
+
"./rsc": {
|
|
17
|
+
"types": "./dist/rsc.d.ts",
|
|
18
|
+
"react-server": "./dist/rsc.js"
|
|
19
|
+
},
|
|
16
20
|
"./vite": {
|
|
17
21
|
"types": "./dist/vite.d.ts",
|
|
18
22
|
"import": "./dist/vite.js",
|
|
@@ -29,6 +33,12 @@
|
|
|
29
33
|
"import": "./dist/routing/hooks/hooks.next.js",
|
|
30
34
|
"default": "./dist/routing/hooks/hooks.next.js"
|
|
31
35
|
},
|
|
36
|
+
"./routing/link": {
|
|
37
|
+
"types": "./dist/routing/link/link.next.d.ts",
|
|
38
|
+
"vite-app": "./dist/routing/link/link.vite.js",
|
|
39
|
+
"import": "./dist/routing/link/link.next.js",
|
|
40
|
+
"default": "./dist/routing/link/link.next.js"
|
|
41
|
+
},
|
|
32
42
|
"./dndev.css": "./dist/dndev.css",
|
|
33
43
|
"./dndev-next.css": "./dist/dndev-next.css"
|
|
34
44
|
},
|
|
@@ -57,13 +67,13 @@
|
|
|
57
67
|
"@tanstack/react-query-next-experimental": "5.107.1"
|
|
58
68
|
},
|
|
59
69
|
"peerDependencies": {
|
|
60
|
-
"@donotdev/ai": "^0.3.
|
|
61
|
-
"@donotdev/auth": "^0.3.
|
|
62
|
-
"@donotdev/billing": "^0.3.
|
|
63
|
-
"@donotdev/components": "^0.3.
|
|
64
|
-
"@donotdev/core": "^0.3.
|
|
65
|
-
"@donotdev/crud": "^0.3.
|
|
66
|
-
"@donotdev/oauth": "^0.3.
|
|
70
|
+
"@donotdev/ai": "^0.3.1",
|
|
71
|
+
"@donotdev/auth": "^0.3.1",
|
|
72
|
+
"@donotdev/billing": "^0.3.1",
|
|
73
|
+
"@donotdev/components": "^0.3.2",
|
|
74
|
+
"@donotdev/core": "^0.3.1",
|
|
75
|
+
"@donotdev/crud": "^0.3.1",
|
|
76
|
+
"@donotdev/oauth": "^0.3.1",
|
|
67
77
|
"@hookform/resolvers": "^5.9.2",
|
|
68
78
|
"lucide-react": "^0.575.0",
|
|
69
79
|
"react": "^19.3.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use client";import{g as p,n as u,t as g,v as m,w as f}from"./chunk-P2DHZWPY.js";import"./chunk-O2XFH626.js";import{useState as I}from"react";import{Button as k,DataTable as L,Dialog as D,Stack as P,Text as E}from"@donotdev/components";import{useTranslation as w}from"@donotdev/core";import{jsx as i,jsxs as R}from"react/jsx-runtime";function F({entity:t,excludedIds:h,onPick:b,onClose:l}){let{t:s}=w([t.namespace,"crud"]),{t:o}=w("crud"),a=p(t,{pagination:"client"}),y=u(t),[r,v]=I([]),c=a.processed.filter(e=>!h.has(e.id)),d=t.listFields||Object.keys(t.fields),C=d.flatMap(e=>{let n=t.fields[e];return n?[{key:e,title:m(e,n,s),dataIndex:e,sortable:!0,render:(x,S)=>f(x,n,s,{compact:!0,referenceData:y,item:S})}]:[]}),T=s("name",{defaultValue:t.name});return i(D,{open:!0,onOpenChange:e=>{e||l()},title:o("childRows.pickTitle",{entity:T}),footer:R(P,{direction:"row",gap:"tight",justify:"end",children:[i(k,{variant:"outline",onClick:l,children:o("actions.cancel")}),i(k,{intent:"add",disabled:r.length===0,onClick:()=>{b(r),l()},children:o("childRows.pickConfirm",{count:r.length})})]}),children:R(P,{children:[i(g,{entity:t,data:a.items,fieldsToFilter:d}),!a.loading&&c.length===0?i(E,{level:"body",children:o("childRows.pickEmpty")}):i(L,{data:c,columns:C,sortable:!0,searchable:!1,pagination:!0,loading:a.loading,selectable:!0,getRowId:e=>e.id,onSelect:e=>v(e.map(n=>n.id)),showingLabel:o("pagination.showing"),paginationPreviousLabel:o("pagination.previous"),paginationNextLabel:o("pagination.next"),paginationItemsPerPagePlaceholder:o("pagination.itemsPerPagePlaceholder")})]})})}export{F as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use client";import{A as b,g as m,k as f,n as h,t as k,v as w,w as P,z as R}from"./chunk-P2DHZWPY.js";import"./chunk-O2XFH626.js";import{Search as V}from"lucide-react";import{useState as v}from"react";import{Button as y,DataTable as j,Dialog as M,Input as U,Stack as C,Text as _}from"@donotdev/components";import{useTranslation as S}from"@donotdev/core";import{jsx as i,jsxs as T}from"react/jsx-runtime";var $="deleted";function q({entity:t,excludedIds:x,viewerRole:E,onPick:I,onClose:a}){let{t:l}=S([t.namespace,"crud"]),{t:o}=S("crud"),r=m(t,{pagination:"client"}),D=h(t),[s,F]=v([]),[c,L]=v(""),d=`${t.collection}#picker`,{filters:A}=f({collection:d}),p=r.items.filter(e=>e.status!==$&&!x.has(e.id)),u=b(R(p,A,t),c,t),g=t.listFields||Object.keys(t.fields),B=g.flatMap(e=>{let n=t.fields[e];return n?[{key:e,title:w(e,n,l),dataIndex:e,sortable:!0,render:(O,Q)=>P(O,n,l,{compact:!0,referenceData:D,item:Q})}]:[]}),K=l("name",{defaultValue:t.name});return i(M,{open:!0,onOpenChange:e=>{e||a()},title:o("childRows.pickTitle",{entity:K}),footer:T(C,{direction:"row",gap:"tight",justify:"end",children:[i(y,{variant:"outline",onClick:a,children:o("actions.cancel")}),i(y,{intent:"add",disabled:s.length===0,onClick:()=>{I(s),a()},children:o("childRows.pickConfirm",{count:s.length})})]}),children:T(C,{children:[i(k,{entity:t,data:p,fieldsToFilter:g,viewerRole:E,filterKey:d}),i(U,{placeholder:o("actions.searchPlaceholder"),value:c,onChange:e=>L(e.target.value),icon:V,className:"dndev-w-full"}),!r.loading&&u.length===0?i(_,{level:"body",children:o("childRows.pickEmpty")}):i(j,{data:u,columns:B,sortable:!0,searchable:!1,pagination:!0,loading:r.loading,selectable:!0,getRowId:e=>e.id,onSelect:e=>F(e.map(n=>n.id)),showingLabel:o("pagination.showing"),paginationPreviousLabel:o("pagination.previous"),paginationNextLabel:o("pagination.next"),paginationItemsPerPagePlaceholder:o("pagination.itemsPerPagePlaceholder")})]})})}export{q as default};
|