@donotdev/ui 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/auth/AuthHeader.js +1 -93
- package/dist/components/auth/AuthMenu.d.ts.map +1 -1
- package/dist/components/auth/AuthMenu.js +3 -286
- package/dist/components/auth/index.js +1 -9
- package/dist/components/common/FeatureCard.d.ts.map +1 -1
- package/dist/components/common/FeatureCard.js +1 -86
- package/dist/components/common/FeatureDisabled.js +1 -67
- package/dist/components/common/IconPlaceholder.d.ts +24 -0
- package/dist/components/common/IconPlaceholder.d.ts.map +1 -0
- package/dist/components/common/IconPlaceholder.js +1 -0
- package/dist/components/common/LazyLucideIcon.d.ts +39 -0
- package/dist/components/common/LazyLucideIcon.d.ts.map +1 -0
- package/dist/components/common/LazyLucideIcon.js +1 -0
- package/dist/components/common/ProgressBar.js +1 -84
- package/dist/components/common/RedirectOverlay.js +1 -243
- package/dist/components/common/Skeleton.js +1 -144
- package/dist/components/common/TechBento.d.ts.map +1 -1
- package/dist/components/common/TechBento.js +1 -53
- package/dist/components/common/icon.d.ts +1 -1
- package/dist/components/common/icon.d.ts.map +1 -1
- package/dist/components/common/icon.js +1 -84
- package/dist/components/common/iconByName.d.ts +33 -0
- package/dist/components/common/iconByName.d.ts.map +1 -0
- package/dist/components/common/iconByName.js +1 -0
- package/dist/components/common/index.js +1 -16
- package/dist/components/cookie-consent/ConsentBanner.d.ts +3 -1
- package/dist/components/cookie-consent/ConsentBanner.d.ts.map +1 -1
- package/dist/components/cookie-consent/ConsentBanner.js +1 -31
- package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
- package/dist/components/cookie-consent/CookieConsent.js +1 -183
- package/dist/components/cookie-consent/index.js +1 -11
- package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts +7 -0
- package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts.map +1 -0
- package/dist/components/cookie-consent/useCookieNoticeRequired.js +1 -0
- package/dist/components/index.js +1 -13
- package/dist/components/layout/GameContainer.d.ts.map +1 -1
- package/dist/components/layout/GameContainer.js +1 -72
- package/dist/components/layout/GameFlow.d.ts.map +1 -1
- package/dist/components/layout/GameFlow.js +1 -93
- package/dist/components/layout/PageConfig.d.ts.map +1 -1
- package/dist/components/layout/PageConfig.js +1 -47
- package/dist/components/layout/PageContainer.d.ts.map +1 -1
- package/dist/components/layout/PageContainer.js +1 -38
- package/dist/components/layout/components/Breadcrumbs.d.ts +2 -1
- package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
- package/dist/components/layout/components/Breadcrumbs.js +1 -89
- package/dist/components/layout/components/DropdownNavigation.d.ts.map +1 -1
- package/dist/components/layout/components/DropdownNavigation.js +1 -30
- package/dist/components/layout/components/FloatingLanguageSwitcher.d.ts.map +1 -1
- package/dist/components/layout/components/FloatingLanguageSwitcher.js +1 -26
- package/dist/components/layout/components/Notifications.js +1 -182
- package/dist/components/layout/components/header/AppBranding.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppBranding.js +1 -54
- package/dist/components/layout/components/header/AppIcon.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppIcon.js +1 -59
- package/dist/components/layout/components/header/AppTitle.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppTitle.js +1 -40
- package/dist/components/layout/components/header/CacheSettings.js +1 -225
- package/dist/components/layout/components/header/GameTitle.d.ts.map +1 -1
- package/dist/components/layout/components/header/GameTitle.js +1 -66
- package/dist/components/layout/components/header/HeaderMenu.js +1 -75
- package/dist/components/layout/components/header/HeaderNavigation.d.ts.map +1 -1
- package/dist/components/layout/components/header/HeaderNavigation.js +1 -66
- package/dist/components/layout/components/header/SettingsMenu.d.ts.map +1 -1
- package/dist/components/layout/components/header/SettingsMenu.js +1 -85
- package/dist/components/layout/components/header/ThemeToggle.d.ts.map +1 -1
- package/dist/components/layout/components/header/ThemeToggle.js +1 -93
- package/dist/components/layout/components/index.js +1 -25
- package/dist/components/layout/index.js +1 -14
- package/dist/crud/components/ChildRowsPicker.js +1 -68
- package/dist/crud/components/CrudCardLink.js +1 -14
- package/dist/crud/components/EntityCardList.js +1 -184
- package/dist/crud/components/EntityDisplayRenderer.js +1 -130
- package/dist/crud/components/EntityFormRenderer.js +1 -433
- package/dist/crud/components/EntityList.js +1 -521
- package/dist/crud/components/EntityRecommendations.js +1 -87
- package/dist/crud/components/EntityWorkflow.js +1 -55
- package/dist/crud/components/Form.d.ts.map +1 -1
- package/dist/crud/components/Form.js +1 -198
- package/dist/crud/components/cellEditFor.js +1 -74
- package/dist/crud/components/entityParent.js +1 -76
- package/dist/crud/components/index.js +1 -16
- package/dist/crud/components/useRecordBreadcrumb.d.ts.map +1 -1
- package/dist/crud/components/useRecordBreadcrumb.js +1 -43
- package/dist/crud/crudImports.js +1 -51
- package/dist/crud/index.js +1 -11
- package/dist/data/techLogos.js +1 -99
- package/dist/dndev-next.css +25 -4
- package/dist/dndev.css +25 -4
- package/dist/index.js +1 -5
- package/dist/internal/common/DnDevErrorBoundary.js +1 -55
- package/dist/internal/common/ErrorFallback.js +3 -214
- package/dist/internal/common/GlobalErrorFallback.js +1 -45
- package/dist/internal/common/RouteErrorFallback.js +3 -140
- package/dist/internal/devtools/DebugTools.js +1 -131
- package/dist/internal/devtools/components/AuthDebugButton.js +1 -72
- package/dist/internal/devtools/components/ConfigTab.js +1 -61
- package/dist/internal/devtools/components/CookieTab.js +1 -156
- package/dist/internal/devtools/components/DebugDialog.js +1 -48
- package/dist/internal/devtools/components/DesignTab.js +1 -469
- package/dist/internal/devtools/components/LayoutReset.js +1 -214
- package/dist/internal/devtools/components/MaskedValue.js +1 -39
- package/dist/internal/devtools/components/StoresTab.js +1 -90
- package/dist/internal/devtools/components/index.js +1 -16
- package/dist/internal/devtools/index.js +1 -13
- package/dist/internal/devtools/types.js +0 -2
- package/dist/internal/devtools/utils/envVarDiscovery.js +1 -106
- package/dist/internal/devtools/utils/index.js +1 -12
- package/dist/internal/devtools/utils/maskSensitive.js +1 -59
- package/dist/internal/devtools/utils/virtualModuleInspector.js +1 -309
- package/dist/internal/initializers/BaseStoresInitializer.js +1 -367
- package/dist/internal/initializers/NextJsStoresInitializer.js +1 -78
- package/dist/internal/initializers/ViteStoresInitializer.js +1 -20
- package/dist/internal/initializers/index.js +1 -11
- package/dist/internal/layout/DnDevLayout.js +1 -321
- package/dist/internal/layout/components/AutoMetaTags.d.ts +2 -0
- package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/AutoMetaTags.js +1 -338
- package/dist/internal/layout/components/FaviconHead.js +1 -60
- package/dist/internal/layout/components/FontPreloadLinks.js +1 -31
- package/dist/internal/layout/components/HeadTags.js +1 -20
- package/dist/internal/layout/components/PWAUpdateNotification.js +1 -131
- package/dist/internal/layout/components/footer/FooterBranding.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterBranding.js +1 -35
- package/dist/internal/layout/components/footer/FooterCopyright.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterCopyright.js +1 -37
- package/dist/internal/layout/components/footer/FooterLegalLinks.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterLegalLinks.js +1 -44
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts +4 -2
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/useLegalLinks.js +1 -21
- package/dist/internal/layout/components/i18nSeoMeta.js +1 -53
- package/dist/internal/layout/components/index.js +1 -13
- package/dist/internal/layout/config/defaults.js +1 -47
- package/dist/internal/layout/config/index.js +1 -11
- package/dist/internal/layout/config/presets/admin.js +1 -35
- package/dist/internal/layout/config/presets/blog.js +1 -31
- package/dist/internal/layout/config/presets/docs.js +1 -51
- package/dist/internal/layout/config/presets/game.js +1 -53
- package/dist/internal/layout/config/presets/index.js +1 -24
- package/dist/internal/layout/config/presets/landing.js +1 -42
- package/dist/internal/layout/config/presets/moolti.js +1 -52
- package/dist/internal/layout/config/presets/plain.js +1 -25
- package/dist/internal/layout/renderers/index.js +0 -10
- package/dist/internal/layout/zones/DnDevFooter.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevFooter.js +1 -67
- package/dist/internal/layout/zones/DnDevHeader.js +1 -41
- package/dist/internal/layout/zones/DnDevMergedBar.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevMergedBar.js +1 -52
- package/dist/internal/layout/zones/DnDevSidebar.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevSidebar.js +1 -181
- package/dist/internal/layout/zones/index.js +1 -14
- package/dist/internal/providers/NavigationProvider.d.ts.map +1 -1
- package/dist/internal/providers/NavigationProvider.js +1 -71
- package/dist/internal/providers/SentryInitializer.d.ts.map +1 -1
- package/dist/internal/providers/SentryInitializer.js +1 -36
- package/dist/internal/providers/UIProviders.js +1 -79
- package/dist/internal/providers/index.js +1 -12
- package/dist/next.js +1 -11
- package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
- package/dist/providers/NextJsAppProviders.js +1 -107
- package/dist/providers/ViteAppProviders.d.ts.map +1 -1
- package/dist/providers/ViteAppProviders.js +1 -117
- package/dist/providers/index.js +1 -11
- package/dist/routing/404.js +1 -108
- package/dist/routing/AuthGuard.js +1 -178
- package/dist/routing/AuthGuardFallback.d.ts.map +1 -1
- package/dist/routing/AuthGuardFallback.js +1 -67
- package/dist/routing/AuthReturnTo.js +1 -68
- package/dist/routing/DnDevNavigationMenu.d.ts.map +1 -1
- package/dist/routing/DnDevNavigationMenu.js +1 -138
- package/dist/routing/GoTo.d.ts.map +1 -1
- package/dist/routing/GoTo.js +1 -38
- package/dist/routing/GoToDialog.d.ts.map +1 -1
- package/dist/routing/GoToDialog.js +1 -97
- package/dist/routing/GoToInput.d.ts.map +1 -1
- package/dist/routing/GoToInput.js +1 -49
- package/dist/routing/GoToWrapper.d.ts.map +1 -1
- package/dist/routing/GoToWrapper.js +1 -59
- package/dist/routing/Link.d.ts +10 -2
- package/dist/routing/Link.d.ts.map +1 -1
- package/dist/routing/Link.js +1 -109
- package/dist/routing/NavigationItem.d.ts.map +1 -1
- package/dist/routing/NavigationItem.js +1 -44
- package/dist/routing/NotFoundDocument.d.ts +33 -0
- package/dist/routing/NotFoundDocument.d.ts.map +1 -0
- package/dist/routing/NotFoundDocument.js +1 -0
- package/dist/routing/SignedInRedirect.js +1 -47
- package/dist/routing/hooks/hooks.vite.js +1 -1
- package/dist/routing/hooks/index.js +1 -26
- package/dist/routing/hooks/types.js +0 -2
- package/dist/routing/hooks/useLocation.next.js +1 -35
- package/dist/routing/hooks/useLocation.vite.js +1 -13
- package/dist/routing/hooks/useMatch.next.js +1 -31
- package/dist/routing/hooks/useMatch.vite.js +1 -6
- package/dist/routing/hooks/useNavigate.next.js +1 -64
- package/dist/routing/hooks/useNavigate.vite.js +1 -61
- package/dist/routing/hooks/useParams.next.js +1 -9
- package/dist/routing/hooks/useParams.vite.js +1 -6
- package/dist/routing/hooks/useQueryParams.next.js +1 -66
- package/dist/routing/hooks/useQueryParams.vite.js +1 -66
- package/dist/routing/hooks/useRedirectGuard.next.js +1 -119
- package/dist/routing/hooks/useRedirectGuard.vite.js +1 -117
- package/dist/routing/hooks/useRouteParam.next.js +1 -38
- package/dist/routing/hooks/useRouteParam.vite.js +1 -38
- package/dist/routing/hooks/useRoutePath.next.js +1 -36
- package/dist/routing/hooks/useRoutePath.vite.js +1 -25
- package/dist/routing/hooks/useSearchParams.next.js +1 -22
- package/dist/routing/hooks/useSearchParams.vite.js +1 -22
- package/dist/routing/hooks/useUrlLanguage.next.js +1 -50
- package/dist/routing/hooks/useUrlLanguage.vite.js +1 -41
- package/dist/routing/index.d.ts +1 -0
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +1 -32
- package/dist/routing/link/InternalLink.next.d.ts +23 -0
- package/dist/routing/link/InternalLink.next.d.ts.map +1 -0
- package/dist/routing/link/InternalLink.next.js +1 -0
- package/dist/routing/link/InternalLink.vite.d.ts +22 -0
- package/dist/routing/link/InternalLink.vite.d.ts.map +1 -0
- package/dist/routing/link/InternalLink.vite.js +1 -0
- package/dist/routing/link/absolutePath.d.ts +17 -0
- package/dist/routing/link/absolutePath.d.ts.map +1 -0
- package/dist/routing/link/absolutePath.js +1 -0
- package/dist/routing/link/link.next.d.ts +12 -0
- package/dist/routing/link/link.next.d.ts.map +1 -0
- package/dist/routing/link/link.next.js +1 -0
- package/dist/routing/link/link.vite.d.ts +12 -0
- package/dist/routing/link/link.vite.d.ts.map +1 -0
- package/dist/routing/link/link.vite.js +1 -0
- package/dist/routing/link/types.d.ts +30 -0
- package/dist/routing/link/types.d.ts.map +1 -0
- package/dist/routing/link/types.js +0 -0
- package/dist/routing/parentRoute.js +1 -43
- package/dist/routing/useGoTo.d.ts.map +1 -1
- package/dist/routing/useGoTo.js +1 -59
- package/dist/routing/useNavigation.d.ts.map +1 -1
- package/dist/routing/useNavigation.js +1 -114
- package/dist/routing/useRouteDiscovery.d.ts +1 -0
- package/dist/routing/useRouteDiscovery.d.ts.map +1 -1
- package/dist/routing/useRouteDiscovery.js +1 -313
- package/dist/rsc.d.ts +28 -0
- package/dist/rsc.d.ts.map +1 -0
- package/dist/rsc.js +1 -0
- package/dist/styles/index.css +25 -4
- package/dist/styles/index.js +1 -10
- package/dist/styles/layoutConstants.js +1 -134
- package/dist/symbol-index.json +1 -1
- package/dist/utils/assetResolver.d.ts.map +1 -1
- package/dist/utils/assetResolver.js +1 -297
- package/dist/utils/index.js +1 -23
- package/dist/utils/sanitizeSvg.js +1 -51
- package/dist/utils/tList.js +1 -42
- package/dist/utils/useAISafe.d.ts.map +1 -1
- package/dist/utils/useAISafe.js +1 -53
- package/dist/utils/useAuthSafe.d.ts.map +1 -1
- package/dist/utils/useAuthSafe.js +1 -78
- package/dist/utils/useAuthVisibility.d.ts.map +1 -1
- package/dist/utils/useAuthVisibility.js +1 -63
- package/dist/utils/useBillingVisibility.d.ts.map +1 -1
- package/dist/utils/useBillingVisibility.js +1 -57
- package/dist/utils/useCrudSafe.d.ts.map +1 -1
- package/dist/utils/useCrudSafe.js +1 -75
- package/dist/utils/useDeleteAccountSafe.js +1 -52
- package/dist/utils/useFormStoreSafe.d.ts.map +1 -1
- package/dist/utils/useFormStoreSafe.js +1 -85
- package/dist/utils/useOAuthSafe.d.ts.map +1 -1
- package/dist/utils/useOAuthSafe.js +1 -38
- package/dist/utils/useSeo.js +1 -151
- package/dist/utils/useStripeBillingSafe.d.ts.map +1 -1
- package/dist/utils/useStripeBillingSafe.js +1 -81
- package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
- package/dist/vite-routing/AppRoutes.js +1 -235
- package/dist/vite-routing/RootLayout.d.ts.map +1 -1
- package/dist/vite-routing/RootLayout.js +1 -205
- package/dist/vite-routing/index.js +1 -11
- package/dist/vite.js +1 -10
- package/guidelines/COMPONENTS.md +3 -3
- package/guidelines/PAGES.md +3 -0
- package/guidelines/ROUTING.md +15 -0
- package/guidelines/SEO.md +4 -1
- package/package.json +18 -8
- package/dist/ChildRowsPicker-63M4EQUQ.js +0 -1
- package/dist/ChildRowsPicker-ISP365ON.js +0 -1
- package/dist/ChildRowsPicker-PQFE6NCR.js +0 -1
- package/dist/ChildRowsPicker-XXFFSMWY.js +0 -1
- package/dist/CookieConsent-QOUAY6B4.js +0 -1
- package/dist/GoToDialog-KSBGOIWO.js +0 -1
- package/dist/GoToDialog-XBK5EZF4.js +0 -1
- package/dist/chunk-3CIZFGST.js +0 -1
- package/dist/chunk-LHMKU342.js +0 -1
- package/dist/chunk-MS7ZIW5Z.js +0 -1
- package/dist/chunk-O2XFH626.js +0 -1
- package/dist/chunk-P2DHZWPY.js +0 -1
- package/dist/components/common/lucideIconByName.d.ts +0 -9
- package/dist/components/common/lucideIconByName.d.ts.map +0 -1
- package/dist/components/common/lucideIconByName.js +0 -32
- package/dist/internal/layout/components/PerformanceHints.d.ts +0 -71
- package/dist/internal/layout/components/PerformanceHints.d.ts.map +0 -1
- package/dist/internal/layout/components/PerformanceHints.js +0 -71
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview UI providers
|
|
4
|
-
* @description Provider components for DoNotDev framework
|
|
5
|
-
*
|
|
6
|
-
* @version 0.1.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
export { UIProviders } from './UIProviders';
|
|
11
|
-
export { NavigationProvider } from './NavigationProvider';
|
|
12
|
-
export { SentryInitializer } from './SentryInitializer';
|
|
1
|
+
import{UIProviders as e}from"./UIProviders.js";import{NavigationProvider as t}from"./NavigationProvider.js";import{SentryInitializer as f}from"./SentryInitializer.js";export{t as NavigationProvider,f as SentryInitializer,e as UIProviders};
|
package/dist/next.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Next.js App Providers
|
|
4
|
-
* @description Next.js-specific app providers export. Provides NextJsAppProviders component for Next.js applications.
|
|
5
|
-
*
|
|
6
|
-
* @version 0.1.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
export { NextJsAppProviders } from './providers/NextJsAppProviders';
|
|
11
|
-
export { FontPreloadLinks, default as FontPreloadLinksDefault, } from './internal/layout/components/FontPreloadLinks';
|
|
1
|
+
import{NextJsAppProviders as r}from"./providers/NextJsAppProviders.js";import{FontPreloadLinks as a,default as s}from"./internal/layout/components/FontPreloadLinks.js";export{a as FontPreloadLinks,s as FontPreloadLinksDefault,r as NextJsAppProviders};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextJsAppProviders.d.ts","sourceRoot":"","sources":["../../src/providers/NextJsAppProviders.tsx"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"NextJsAppProviders.d.ts","sourceRoot":"","sources":["../../src/providers/NextJsAppProviders.tsx"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,gBAAgB,CAAC;AA2F1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAQD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,+BA0FhE"}
|
|
@@ -1,107 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
// packages/ui/src/providers/NextJsAppProviders.tsx
|
|
4
|
-
/**
|
|
5
|
-
* @fileoverview NextJsAppProviders component
|
|
6
|
-
* @description Next.js-specific app providers with SSR support
|
|
7
|
-
*
|
|
8
|
-
* @version 0.1.0
|
|
9
|
-
* @since 0.0.1
|
|
10
|
-
* @author AMBROISE PARK Consulting
|
|
11
|
-
*/
|
|
12
|
-
import { useRouter } from 'next/navigation';
|
|
13
|
-
import { lazy, Suspense, useEffect, useMemo, useState } from 'react';
|
|
14
|
-
import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental';
|
|
15
|
-
import { AppConfigProvider, AuthSessionProvider, getI18nInstance, getLanguageRouting, getProvider, getRequestLanguage, hasProvider, isMultilingual, LanguageNavigationProvider, QueryProviders, RequestLanguageProvider, } from '@donotdev/core';
|
|
16
|
-
import { useConsent } from '@donotdev/core';
|
|
17
|
-
// Platform-specific hooks via conditional exports
|
|
18
|
-
import { useUrlLanguage } from '@donotdev/ui/routing/hooks';
|
|
19
|
-
import { NextJsStoresInitializer } from '../internal/initializers/NextJsStoresInitializer';
|
|
20
|
-
import { AutoMetaTags } from '../internal/layout/components/AutoMetaTags';
|
|
21
|
-
import FaviconHead from '../internal/layout/components/FaviconHead';
|
|
22
|
-
import { DnDevLayout } from '../internal/layout/DnDevLayout';
|
|
23
|
-
import { SentryInitializer } from '../internal/providers/SentryInitializer';
|
|
24
|
-
import { UIProviders } from '../internal/providers/UIProviders';
|
|
25
|
-
import { AuthReturnTo } from '../routing/AuthReturnTo';
|
|
26
|
-
import { PasswordResetCallback } from '../utils/useAuthSafe';
|
|
27
|
-
// Null fallback for lazy components that fail to load (e.g., optional auth dependency absent)
|
|
28
|
-
const NullFallback = () => null;
|
|
29
|
-
// Lazy load client-only components — each wrapped with catch to prevent hanging
|
|
30
|
-
// if an optional dependency (e.g., @donotdev/auth) is not installed.
|
|
31
|
-
const CookieConsent = lazy(() => import('../components/cookie-consent/CookieConsent').catch(() => ({ default: NullFallback })));
|
|
32
|
-
const PWAUpdateNotification = lazy(() => import('../internal/layout/components/PWAUpdateNotification')
|
|
33
|
-
.then((m) => ({ default: m.default }))
|
|
34
|
-
.catch(() => ({ default: NullFallback })));
|
|
35
|
-
const RedirectOverlay = lazy(() => import('../components/common/RedirectOverlay')
|
|
36
|
-
.then((m) => ({ default: m.RedirectOverlay }))
|
|
37
|
-
.catch(() => ({ default: NullFallback })));
|
|
38
|
-
/**
|
|
39
|
-
* ConsentBanner - Lazy loaded consent component
|
|
40
|
-
* Only shows if user hasn't consented yet
|
|
41
|
-
*
|
|
42
|
-
* @version 0.1.0
|
|
43
|
-
* @since 0.0.1
|
|
44
|
-
* @author AMBROISE PARK Consulting
|
|
45
|
-
*/
|
|
46
|
-
function ConsentBanner() {
|
|
47
|
-
const hasConsented = useConsent('hasConsented');
|
|
48
|
-
const showBanner = useConsent('showBanner');
|
|
49
|
-
if (hasConsented && !showBanner) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
return (_jsx(Suspense, { fallback: null, children: _jsx(CookieConsent, {}) }));
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Language of the render. 2+ languages: the URL's (`/en/…`, the default language at
|
|
56
|
-
* the root; the generated proxy already moved a first visit to the visitor's
|
|
57
|
-
* language). One language: from the request headers (language cookie >
|
|
58
|
-
* Accept-Language > fallback). Same inputs on the server and in the hydration pass.
|
|
59
|
-
*/
|
|
60
|
-
function useRenderLanguage(serverCookies, acceptLanguage) {
|
|
61
|
-
const urlLanguage = useUrlLanguage();
|
|
62
|
-
const multilingual = isMultilingual(getLanguageRouting().languages);
|
|
63
|
-
const requestLanguage = useMemo(() => getRequestLanguage(serverCookies, acceptLanguage), [serverCookies, acceptLanguage]);
|
|
64
|
-
return multilingual ? urlLanguage : requestLanguage;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* The live i18n instance follows the render language: a language switch navigates
|
|
68
|
-
* client-side to the other language's URL, and the page re-renders in it.
|
|
69
|
-
*/
|
|
70
|
-
function useFollowLanguage(language) {
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
const instance = getI18nInstance();
|
|
73
|
-
if (instance.language !== language)
|
|
74
|
-
void instance.changeLanguage(language);
|
|
75
|
-
}, [language]);
|
|
76
|
-
}
|
|
77
|
-
/** Auth session snapshot of the request, `null` when the auth provider cannot tell. */
|
|
78
|
-
function readAuthSnapshot(cookieHeader) {
|
|
79
|
-
if (cookieHeader === undefined || !hasProvider('auth'))
|
|
80
|
-
return null;
|
|
81
|
-
return getProvider('auth').readSessionSnapshot?.(cookieHeader) ?? null;
|
|
82
|
-
}
|
|
83
|
-
export function NextJsAppProviders(props) {
|
|
84
|
-
const { config = {}, layout, children, serverCookies, acceptLanguage, customStores, } = props;
|
|
85
|
-
// Same URL and header values on the server and in the hydration pass → same language
|
|
86
|
-
// and signed-in state on both, so the first paint is final (no keys, no auth swap).
|
|
87
|
-
const language = useRenderLanguage(serverCookies, acceptLanguage);
|
|
88
|
-
useFollowLanguage(language);
|
|
89
|
-
// Language switchers (core) open the other language's URL through the Next router
|
|
90
|
-
const router = useRouter();
|
|
91
|
-
const navigateToLanguage = (url) => router.push(url, { scroll: false });
|
|
92
|
-
const authSnapshot = useMemo(() => readAuthSnapshot(serverCookies), [serverCookies]);
|
|
93
|
-
// SSR is the default for Next apps: render the provider tree on the server so
|
|
94
|
-
// page content is present in the initial HTML (crawlable, real SSR). An app
|
|
95
|
-
// opts OUT with appConfig.ssr === false, restoring the legacy client-only
|
|
96
|
-
// render (the tree mounts after hydration). Hooks are still called
|
|
97
|
-
// unconditionally to keep render order stable.
|
|
98
|
-
const ssr = config.ssr !== false;
|
|
99
|
-
const [isMounted, setIsMounted] = useState(false);
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
setIsMounted(true);
|
|
102
|
-
}, []);
|
|
103
|
-
if (!ssr && !isMounted) {
|
|
104
|
-
return _jsx(_Fragment, { children: children });
|
|
105
|
-
}
|
|
106
|
-
return (_jsx(RequestLanguageProvider, { language: language, children: _jsx(LanguageNavigationProvider, { navigate: navigateToLanguage, children: _jsx(AuthSessionProvider, { snapshot: authSnapshot, children: _jsxs(AppConfigProvider, { config: config, platform: "nextjs", children: [_jsx(SentryInitializer, {}), _jsxs(NextJsStoresInitializer, { serverCookies: serverCookies, customStores: customStores, children: [_jsx(FaviconHead, {}), _jsx(QueryProviders, { children: _jsx(ReactQueryStreamedHydration, { children: _jsxs(UIProviders, { children: [_jsx(AutoMetaTags, {}), _jsx(DnDevLayout, { layout: layout, children: children }), _jsx(ConsentBanner, {}), _jsx(AuthReturnTo, {}), _jsx(PasswordResetCallback, {}), _jsx(Suspense, { fallback: null, children: _jsx(PWAUpdateNotification, {}) }), _jsx(Suspense, { fallback: null, children: _jsx(RedirectOverlay, {}) })] }) }) })] })] }) }) }) }));
|
|
107
|
-
}
|
|
1
|
+
"use client";import{useRouter as R}from"next/navigation";import{lazy as u,Suspense as i,useEffect as d,useMemo as p,useState as A}from"react";import{ReactQueryStreamedHydration as C}from"@tanstack/react-query-next-experimental";import{AppConfigProvider as k,AuthSessionProvider as b,getI18nInstance as x,getLanguageRouting as I,getProvider as q,getRequestLanguage as F,hasProvider as J,isMultilingual as M,LanguageNavigationProvider as w,QueryProviders as z,RequestLanguageProvider as D}from"@donotdev/core";import{useConsent as c}from"@donotdev/core";import{useUrlLanguage as Q}from"@donotdev/ui/routing/hooks";import{useCookieNoticeRequired as T}from"../components/cookie-consent/useCookieNoticeRequired.js";import{NextJsStoresInitializer as U}from"../internal/initializers/NextJsStoresInitializer.js";import{AutoMetaTags as B}from"../internal/layout/components/AutoMetaTags.js";import H from"../internal/layout/components/FaviconHead.js";import{DnDevLayout as O}from"../internal/layout/DnDevLayout.js";import{SentryInitializer as E}from"../internal/providers/SentryInitializer.js";import{UIProviders as W}from"../internal/providers/UIProviders.js";import{AuthReturnTo as j}from"../routing/AuthReturnTo.js";import{PasswordResetCallback as G}from"../utils/useAuthSafe.js";import{Fragment as ee,jsx as e,jsxs as s}from"react/jsx-runtime";var l=()=>null,K=u(()=>import("../components/cookie-consent/CookieConsent.js").catch(()=>({default:l}))),V=u(()=>import("../internal/layout/components/PWAUpdateNotification.js").then(t=>({default:t.default})).catch(()=>({default:l}))),X=u(()=>import("../components/common/RedirectOverlay.js").then(t=>({default:t.RedirectOverlay})).catch(()=>({default:l})));function Y(){let t=c("hasConsented"),o=c("showBanner");return!T()||t&&!o?null:e(i,{fallback:null,children:e(K,{})})}function Z(t,o){let n=Q(),a=M(I().languages),r=p(()=>F(t,o),[t,o]);return a?n:r}function _(t){d(()=>{let o=x();o.language!==t&&o.changeLanguage(t)},[t])}function $(t){return t===void 0||!J("auth")?null:q("auth").readSessionSnapshot?.(t)??null}function ve(t){let{config:o={},layout:n,children:a,serverCookies:r,acceptLanguage:f,customStores:m}=t,g=Z(r,f);_(g);let v=R(),P=N=>v.push(N,{scroll:!1}),h=p(()=>$(r),[r]),y=o.ssr!==!1,[L,S]=A(!1);return d(()=>{S(!0)},[]),!y&&!L?e(ee,{children:a}):e(D,{language:g,children:e(w,{navigate:P,children:e(b,{snapshot:h,children:s(k,{config:o,platform:"nextjs",children:[e(E,{}),s(U,{serverCookies:r,customStores:m,children:[e(H,{}),e(z,{children:e(C,{children:s(W,{children:[e(B,{}),e(O,{layout:n,children:a}),e(Y,{}),e(j,{}),e(G,{}),e(i,{fallback:null,children:e(V,{})}),e(i,{fallback:null,children:e(X,{})})]})})})]})]})})})})}export{ve as NextJsAppProviders};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViteAppProviders.d.ts","sourceRoot":"","sources":["../../src/providers/ViteAppProviders.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ViteAppProviders.d.ts","sourceRoot":"","sources":["../../src/providers/ViteAppProviders.tsx"],"names":[],"mappings":"AAeA,OAAO,aAAa,CAAC;AACrB,OAAO,gBAAgB,CAAC;AACxB,OAAO,sBAAsB,CAAC;AAC9B,OAAO,gBAAgB,CAAC;AACxB,OAAO,gBAAgB,CAAC;AAUxB,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,gBAAgB,CAAC;AAoC1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,+BA4DxD"}
|
|
@@ -1,117 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
// packages/ui/src/providers/ViteAppProviders.tsx
|
|
3
|
-
/**
|
|
4
|
-
* @fileoverview ViteAppProviders component
|
|
5
|
-
* @description Vite-specific app providers with lazy loading
|
|
6
|
-
*
|
|
7
|
-
* @version 0.1.0
|
|
8
|
-
* @since 0.0.1
|
|
9
|
-
* @author AMBROISE PARK Consulting
|
|
10
|
-
*/
|
|
11
|
-
import { lazy, Suspense, useEffect, useMemo, useRef, useState } from 'react';
|
|
12
|
-
// Import virtual modules to populate globalThis._DNDEV_CONFIG_ before any components load
|
|
13
|
-
import 'virtual:env';
|
|
14
|
-
import 'virtual:themes';
|
|
15
|
-
import 'virtual:i18n-mapping';
|
|
16
|
-
import 'virtual:routes';
|
|
17
|
-
import 'virtual:assets';
|
|
18
|
-
import { AppConfigProvider, applyFirstVisitLanguage, getI18nInstance, getLanguageRouting, getUrlLanguage, LanguageNavigationProvider, } from '@donotdev/core';
|
|
19
|
-
import { ViteStoresInitializer } from '../internal/initializers/ViteStoresInitializer';
|
|
20
|
-
import { NavigationProvider } from '../internal/providers/NavigationProvider';
|
|
21
|
-
import { SentryInitializer } from '../internal/providers/SentryInitializer';
|
|
22
|
-
import { useRouteDiscovery } from '../routing/useRouteDiscovery';
|
|
23
|
-
import { createAppRouter } from '../vite-routing/AppRoutes';
|
|
24
|
-
// ✅ LAZY LOAD: Everything that imports Radix UI or react-router-dom
|
|
25
|
-
const HelmetProvider = lazy(() => import('react-helmet-async').then((m) => ({ default: m.HelmetProvider })));
|
|
26
|
-
// 🚨 CRITICAL: NavigationProvider must NOT be lazy loaded
|
|
27
|
-
// NavigationProvider uses React hooks (useEffect) and must load in the same chunk as React
|
|
28
|
-
// Lazy loading causes "Invalid hook call" errors because React's dispatcher is null when the chunk loads
|
|
29
|
-
// This has been tested - lazy loading NavigationProvider NEVER works, keep it eagerly imported
|
|
30
|
-
const FaviconHead = lazy(() => import('../internal/layout/components/FaviconHead').then((m) => ({
|
|
31
|
-
default: m.default,
|
|
32
|
-
})));
|
|
33
|
-
/** Language of the browser URL (prefix, else the default language). */
|
|
34
|
-
function currentUrlLanguage() {
|
|
35
|
-
return getUrlLanguage(window.location.pathname);
|
|
36
|
-
}
|
|
37
|
-
/** Stop the history listener of a router replaced by a language switch. */
|
|
38
|
-
function useDisposeReplacedRouter(router) {
|
|
39
|
-
const previous = useRef(router);
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (previous.current !== router)
|
|
42
|
-
previous.current.dispose();
|
|
43
|
-
previous.current = router;
|
|
44
|
-
}, [router]);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* ViteAppProviders - Vite platform-specific app providers
|
|
48
|
-
*
|
|
49
|
-
* Clean provider hierarchy with configuration via context (no prop drilling).
|
|
50
|
-
* Uses React Router v7 data router pattern (RouterProvider + createBrowserRouter).
|
|
51
|
-
*
|
|
52
|
-
* Provider hierarchy (outside router):
|
|
53
|
-
* 1. AppConfigProvider (configuration context)
|
|
54
|
-
* 2. SentryInitializer (error monitoring)
|
|
55
|
-
* 3. ViteStoresInitializer (store setup)
|
|
56
|
-
* 4. HelmetProvider (head management)
|
|
57
|
-
* 5. FaviconHead (favicon configuration)
|
|
58
|
-
* 6. NavigationProvider (RouterProvider with auto-abort)
|
|
59
|
-
*
|
|
60
|
-
* Provider hierarchy (inside router via RootLayout):
|
|
61
|
-
* 7. QueryProviders (React Query)
|
|
62
|
-
* 8. UIProviders (design system)
|
|
63
|
-
* 9. AutoMetaTags (SEO)
|
|
64
|
-
* 10. FrameworkReadySignal (framework initialization)
|
|
65
|
-
* 11. Layout (application layout)
|
|
66
|
-
* 12. ConsentBanner (cookie consent)
|
|
67
|
-
* 13. PWAUpdateNotification (PWA updates)
|
|
68
|
-
*
|
|
69
|
-
* @version 0.1.0
|
|
70
|
-
* @since 0.0.1
|
|
71
|
-
* @author AMBROISE PARK Consulting
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```tsx
|
|
75
|
-
* <ViteAppProviders
|
|
76
|
-
* config={{ app: { name: 'My App' } }}
|
|
77
|
-
* />
|
|
78
|
-
* ```
|
|
79
|
-
*
|
|
80
|
-
* Note: HomePage.tsx in src/pages/ is automatically used for the root route "/"
|
|
81
|
-
*/
|
|
82
|
-
export function ViteAppProviders(props) {
|
|
83
|
-
const { config = {}, layout, children, customStores } = props;
|
|
84
|
-
// Discover routes using the route discovery hook
|
|
85
|
-
const routeGroups = useRouteDiscovery();
|
|
86
|
-
// Create router instance using React Router v7 data router pattern
|
|
87
|
-
// Virtual modules are loaded at module level (lines 20-26), so routes are available
|
|
88
|
-
// HomePage.tsx is automatically assigned path "/" by RouteDiscovery convention
|
|
89
|
-
// Memoized so the router instance is stable across re-renders (Item 86)
|
|
90
|
-
// The router runs under the URL's language prefix (createAppRouter basename). A
|
|
91
|
-
// language switch moves the URL to the other language's prefix and recreates the
|
|
92
|
-
// router under it: client-side, no document reload.
|
|
93
|
-
const [urlLanguage, setUrlLanguage] = useState(currentUrlLanguage);
|
|
94
|
-
const router = useMemo(() => createAppRouter({ routeGroups, layout }),
|
|
95
|
-
// urlLanguage: a new router (new basename) per URL language
|
|
96
|
-
[routeGroups, layout, urlLanguage]);
|
|
97
|
-
useDisposeReplacedRouter(router);
|
|
98
|
-
// Back/forward across languages: the router of the other prefix takes over
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
const onPopState = () => {
|
|
101
|
-
// Same rule as a first visit (and as the Next proxy) for an unprefixed URL
|
|
102
|
-
const routing = getLanguageRouting();
|
|
103
|
-
applyFirstVisitLanguage(routing.languages, routing.defaultLanguage);
|
|
104
|
-
const language = currentUrlLanguage();
|
|
105
|
-
void getI18nInstance().changeLanguage(language);
|
|
106
|
-
setUrlLanguage(language);
|
|
107
|
-
};
|
|
108
|
-
window.addEventListener('popstate', onPopState);
|
|
109
|
-
return () => window.removeEventListener('popstate', onPopState);
|
|
110
|
-
}, []);
|
|
111
|
-
const navigateToLanguage = (url, language) => {
|
|
112
|
-
window.history.pushState(null, '', url);
|
|
113
|
-
void getI18nInstance().changeLanguage(language);
|
|
114
|
-
setUrlLanguage(language);
|
|
115
|
-
};
|
|
116
|
-
return (_jsxs(AppConfigProvider, { config: config, platform: "vite", children: [_jsx(SentryInitializer, {}), _jsx(ViteStoresInitializer, { customStores: customStores, children: _jsx(Suspense, { fallback: null, children: _jsxs(HelmetProvider, { children: [_jsx(FaviconHead, {}), _jsx(LanguageNavigationProvider, { navigate: navigateToLanguage, children: _jsx(NavigationProvider, { router: router }) })] }) }) })] }));
|
|
117
|
-
}
|
|
1
|
+
"use client";import{lazy as d,Suspense as L,useEffect as l,useMemo as P,useRef as S,useState as y}from"react";import"virtual:env";import"virtual:themes";import"virtual:i18n-mapping";import"virtual:routes";import"virtual:assets";import{AppConfigProvider as h,applyFirstVisitLanguage as w,getI18nInstance as s,getLanguageRouting as R,getUrlLanguage as A,LanguageNavigationProvider as I}from"@donotdev/core";import{ViteStoresInitializer as N}from"../internal/initializers/ViteStoresInitializer.js";import{NavigationProvider as z}from"../internal/providers/NavigationProvider.js";import{SentryInitializer as H}from"../internal/providers/SentryInitializer.js";import{useRouteDiscovery as V}from"../routing/useRouteDiscovery.js";import{createAppRouter as E}from"../vite-routing/AppRoutes.js";import{jsx as t,jsxs as m}from"react/jsx-runtime";var T=d(()=>import("react-helmet-async").then(e=>({default:e.HelmetProvider}))),U=d(()=>import("../internal/layout/components/FaviconHead.js").then(e=>({default:e.default})));function c(){return A(window.location.pathname)}function C(e){let o=S(e);l(()=>{o.current!==e&&o.current.dispose(),o.current=e},[e])}function X(e){let{config:o={},layout:i,children:D,customStores:v}=e,a=V(),[f,u]=y(c),g=P(()=>E({routeGroups:a,layout:i}),[a,i,f]);return C(g),l(()=>{let n=()=>{let r=R();w(r.languages,r.defaultLanguage);let p=c();s().changeLanguage(p),u(p)};return window.addEventListener("popstate",n),()=>window.removeEventListener("popstate",n)},[]),m(h,{config:o,platform:"vite",children:[t(H,{}),t(N,{customStores:v,children:t(L,{fallback:null,children:m(T,{children:[t(U,{}),t(I,{navigate:(n,r)=>{window.history.pushState(null,"",n),s().changeLanguage(r),u(r)},children:t(z,{router:g})})]})})})]})}export{X as ViteAppProviders};
|
package/dist/providers/index.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview UI providers
|
|
4
|
-
* @description Provider components for DoNotDev framework
|
|
5
|
-
*
|
|
6
|
-
* @version 0.1.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
export { ViteAppProviders } from './ViteAppProviders';
|
|
11
|
-
export { NextJsAppProviders } from './NextJsAppProviders';
|
|
1
|
+
import{ViteAppProviders as o}from"./ViteAppProviders.js";import{NextJsAppProviders as t}from"./NextJsAppProviders.js";export{t as NextJsAppProviders,o as ViteAppProviders};
|
package/dist/routing/404.js
CHANGED
|
@@ -1,108 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
// packages/ui/src/routing/404.tsx
|
|
4
|
-
/**
|
|
5
|
-
* @fileoverview 404 Not Found page component
|
|
6
|
-
* @description Professional 404 page with full-viewport centered layout, i18n, and dynamic route suggestions
|
|
7
|
-
*
|
|
8
|
-
* @version 0.1.0
|
|
9
|
-
* @since 0.0.1
|
|
10
|
-
* @author AMBROISE PARK Consulting
|
|
11
|
-
*/
|
|
12
|
-
import { Home, ArrowLeft, Link as LinkIcon } from 'lucide-react';
|
|
13
|
-
import { useMemo } from 'react';
|
|
14
|
-
import { Button, BUTTON_VARIANT, Stack, Text } from '@donotdev/components';
|
|
15
|
-
import { useTranslation } from '@donotdev/core';
|
|
16
|
-
// Platform-specific hooks via conditional exports
|
|
17
|
-
import { useNavigate, useRoutePath } from '@donotdev/ui/routing/hooks';
|
|
18
|
-
import { Link } from './Link';
|
|
19
|
-
import { useNavigationItems } from './useNavigation';
|
|
20
|
-
import { Icon } from '../components/common/icon';
|
|
21
|
-
import { PageContainer } from '../components/layout/PageContainer';
|
|
22
|
-
/**
|
|
23
|
-
* 404 Not Found page metadata configuration
|
|
24
|
-
*
|
|
25
|
-
* @version 0.1.0
|
|
26
|
-
* @since 0.0.1
|
|
27
|
-
* @author AMBROISE PARK Consulting
|
|
28
|
-
*/
|
|
29
|
-
export const meta = {
|
|
30
|
-
hideFromMenu: true,
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Professional 404 Not Found page component
|
|
34
|
-
*
|
|
35
|
-
* Features:
|
|
36
|
-
* - Full-viewport centered design for professional appearance
|
|
37
|
-
* - Translation system integration (i18n)
|
|
38
|
-
* - Dynamic route suggestions from discovered routes
|
|
39
|
-
* - Optional requested-path badge (shown by default for existing consumers)
|
|
40
|
-
* - Accessible design with proper semantic HTML
|
|
41
|
-
* - Responsive across all viewports
|
|
42
|
-
*
|
|
43
|
-
* Legacy errors.notFound keys are compatibility references to the canonical
|
|
44
|
-
* messages.notFound resources. Keep lookups here so legacy app overrides win.
|
|
45
|
-
*
|
|
46
|
-
* @version 0.1.0
|
|
47
|
-
* @since 0.0.1
|
|
48
|
-
* @author AMBROISE PARK Consulting
|
|
49
|
-
*/
|
|
50
|
-
export default function NotFoundPage({ showRequestedPath = true, } = {}) {
|
|
51
|
-
const { t } = useTranslation('dndev');
|
|
52
|
-
const pathname = useRoutePath();
|
|
53
|
-
const navigate = useNavigate();
|
|
54
|
-
const navigationItems = useNavigationItems();
|
|
55
|
-
/**
|
|
56
|
-
* Get suggested routes for navigation
|
|
57
|
-
* Filters out dynamic routes, home, and limits to 4 suggestions
|
|
58
|
-
*/
|
|
59
|
-
const suggestedRoutes = useMemo(() => {
|
|
60
|
-
return navigationItems
|
|
61
|
-
.filter((route) => !route.path.includes(':') && route.path !== '/')
|
|
62
|
-
.slice(0, 4);
|
|
63
|
-
}, [navigationItems]);
|
|
64
|
-
/**
|
|
65
|
-
* Handle back button click
|
|
66
|
-
* Uses navigate('back') for platform-agnostic back navigation
|
|
67
|
-
*/
|
|
68
|
-
const handleBack = () => {
|
|
69
|
-
navigate('back');
|
|
70
|
-
};
|
|
71
|
-
return (_jsx(PageContainer, { variant: "docs", centered: true, children: _jsxs(Stack, { gap: "large", align: "center", justify: "center", children: [_jsxs(Stack, { align: "center", children: [_jsx(Text, { level: "h1", style: {
|
|
72
|
-
fontSize: 'clamp(4rem, 12vw, 8rem)',
|
|
73
|
-
fontWeight: 'var(--font-weight-bold)',
|
|
74
|
-
lineHeight: 1,
|
|
75
|
-
letterSpacing: '-0.02em',
|
|
76
|
-
background: 'linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%)',
|
|
77
|
-
WebkitBackgroundClip: 'text',
|
|
78
|
-
WebkitTextFillColor: 'transparent',
|
|
79
|
-
backgroundClip: 'text',
|
|
80
|
-
margin: 0,
|
|
81
|
-
}, children: "404" }), _jsx(Text, { level: "h2", style: {
|
|
82
|
-
fontSize: 'var(--font-size-2xl)',
|
|
83
|
-
fontWeight: 'var(--font-weight-semibold)',
|
|
84
|
-
margin: 0,
|
|
85
|
-
}, children: t('errors.notFound.title', 'Page Not Found') }), _jsx(Text, { style: {
|
|
86
|
-
fontSize: 'var(--font-size-lg)',
|
|
87
|
-
color: 'var(--muted-foreground)',
|
|
88
|
-
textAlign: 'center',
|
|
89
|
-
margin: 0,
|
|
90
|
-
}, children: t('errors.notFound.description', "The page you're looking for doesn't exist or has been moved.") }), showRequestedPath && pathname && (_jsx("code", { style: {
|
|
91
|
-
padding: 'var(--gap-sm) var(--gap-md)',
|
|
92
|
-
background: 'var(--muted)',
|
|
93
|
-
borderRadius: 'var(--radius-md)',
|
|
94
|
-
fontSize: 'var(--font-size-sm)',
|
|
95
|
-
fontFamily: 'var(--font-mono)',
|
|
96
|
-
color: 'var(--foreground)',
|
|
97
|
-
wordBreak: 'break-all',
|
|
98
|
-
maxWidth: '100%',
|
|
99
|
-
overflow: 'hidden',
|
|
100
|
-
textOverflow: 'ellipsis',
|
|
101
|
-
border: '1px solid var(--border-hairline)',
|
|
102
|
-
}, children: pathname }))] }), suggestedRoutes.length > 0 && (_jsxs(Stack, { align: "center", children: [_jsx("p", { className: "dndev-text-base", style: {
|
|
103
|
-
fontSize: 'var(--font-size-md)',
|
|
104
|
-
fontWeight: 'var(--font-weight-semibold)',
|
|
105
|
-
margin: 0,
|
|
106
|
-
color: 'var(--muted-foreground)',
|
|
107
|
-
}, children: t('errors.notFound.suggestions', 'You might be looking for:') }), _jsx(Stack, { direction: "row", wrap: "wrap", justify: "center", gap: "tight", children: suggestedRoutes.map((route) => (_jsx(Link, { path: route.path, replace: true, children: _jsx(Button, { variant: BUTTON_VARIANT.OUTLINE, icon: _jsx(Icon, { icon: route.icon, fallback: LinkIcon }), "aria-label": t('errors.notFound.navigateTo', `Navigate to ${route.label}`, { label: route.label }), children: route.label }) }, route.path))) })] })), _jsxs(Stack, { direction: "row", wrap: "wrap", justify: "center", children: [_jsx(Link, { path: "/", replace: true, children: _jsx(Button, { variant: BUTTON_VARIANT.DEFAULT, icon: Home, "aria-label": t('errors.notFound.goHome', 'Go to home page'), children: t('errors.notFound.goHome', 'Go Home') }) }), _jsx(Button, { variant: BUTTON_VARIANT.OUTLINE, icon: ArrowLeft, onClick: handleBack, "aria-label": t('errors.notFound.goBack', 'Go back to previous page'), children: t('errors.notFound.goBack', 'Go Back') })] })] }) }));
|
|
108
|
-
}
|
|
1
|
+
"use client";import{Home as f,ArrowLeft as v,Link as h}from"lucide-react";import{useMemo as k}from"react";import{Button as n,BUTTON_VARIANT as i,Stack as r,Text as l}from"@donotdev/components";import{useTranslation as b}from"@donotdev/core";import{useNavigate as w,useRoutePath as x}from"@donotdev/ui/routing/hooks";import{Link as g}from"./Link.js";import{useNavigationItems as F}from"./useNavigation.js";import{Icon as T}from"../components/common/icon.js";import{PageContainer as y}from"../components/layout/PageContainer.js";import{jsx as e,jsxs as a}from"react/jsx-runtime";var H={hideFromMenu:!0};function S({showRequestedPath:m=!0}={}){let{t}=b("dndev"),s=x(),p=w(),d=F(),c=k(()=>d.filter(o=>!o.path.includes(":")&&o.path!=="/").slice(0,4),[d]),u=()=>{p("back")};return e(y,{variant:"docs",centered:!0,children:a(r,{gap:"large",align:"center",justify:"center",children:[a(r,{align:"center",children:[e(l,{level:"h1",style:{fontSize:"clamp(4rem, 12vw, 8rem)",fontWeight:"var(--font-weight-bold)",lineHeight:1,letterSpacing:"-0.02em",background:"linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text",margin:0},children:"404"}),e(l,{level:"h2",style:{fontSize:"var(--font-size-2xl)",fontWeight:"var(--font-weight-semibold)",margin:0},children:t("errors.notFound.title","Page Not Found")}),e(l,{style:{fontSize:"var(--font-size-lg)",color:"var(--muted-foreground)",textAlign:"center",margin:0},children:t("errors.notFound.description","The page you're looking for doesn't exist or has been moved.")}),m&&s&&e("code",{style:{padding:"var(--gap-sm) var(--gap-md)",background:"var(--muted)",borderRadius:"var(--radius-md)",fontSize:"var(--font-size-sm)",fontFamily:"var(--font-mono)",color:"var(--foreground)",wordBreak:"break-all",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",border:"1px solid var(--border-hairline)"},children:s})]}),c.length>0&&a(r,{align:"center",children:[e("p",{className:"dndev-text-base",style:{fontSize:"var(--font-size-md)",fontWeight:"var(--font-weight-semibold)",margin:0,color:"var(--muted-foreground)"},children:t("errors.notFound.suggestions","You might be looking for:")}),e(r,{direction:"row",wrap:"wrap",justify:"center",gap:"tight",children:c.map(o=>e(g,{path:o.path,replace:!0,children:e(n,{variant:i.OUTLINE,icon:e(T,{icon:o.icon,fallback:h}),"aria-label":t("errors.notFound.navigateTo",`Navigate to ${o.label}`,{label:o.label}),children:o.label})},o.path))})]}),a(r,{direction:"row",wrap:"wrap",justify:"center",children:[e(g,{path:"/",replace:!0,children:e(n,{variant:i.DEFAULT,icon:f,"aria-label":t("errors.notFound.goHome","Go to home page"),children:t("errors.notFound.goHome","Go Home")})}),e(n,{variant:i.OUTLINE,icon:v,onClick:u,"aria-label":t("errors.notFound.goBack","Go back to previous page"),children:t("errors.notFound.goBack","Go Back")})]})]})})}export{S as default,H as meta};
|
|
@@ -1,178 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
// packages/ui/src/routing/AuthGuard.tsx
|
|
4
|
-
/**
|
|
5
|
-
* @fileoverview AuthGuard component
|
|
6
|
-
* @description Cold-load safety net for protected routes. Redirects unauthenticated
|
|
7
|
-
* users to authRoute. SPA navigation is intercepted earlier in useNavigate.
|
|
8
|
-
*
|
|
9
|
-
* @version 0.1.0
|
|
10
|
-
* @since 0.0.1
|
|
11
|
-
* @author AMBROISE PARK Consulting
|
|
12
|
-
*/
|
|
13
|
-
import { useEffect } from 'react';
|
|
14
|
-
import { Spinner } from '@donotdev/components';
|
|
15
|
-
import { FEATURE_STATUS, USER_ROLES, SUBSCRIPTION_TIERS, isClient, safeSessionStorage, } from '@donotdev/core';
|
|
16
|
-
// Platform-specific hooks via conditional exports
|
|
17
|
-
import { useRedirectGuard, useNavigate } from '@donotdev/ui/routing/hooks';
|
|
18
|
-
import { useAuthSafe } from '../utils/useAuthSafe';
|
|
19
|
-
/**
|
|
20
|
-
* AuthGuard - cold-load redirect safety net
|
|
21
|
-
*
|
|
22
|
-
* For SPA navigation, auth is intercepted in useNavigate (before page mount).
|
|
23
|
-
* This component handles the cold-load case: user pastes a protected URL directly.
|
|
24
|
-
* It redirects to authRoute, saves returnTo, and AuthReturnTo handles the redirect back.
|
|
25
|
-
*
|
|
26
|
-
* @version 0.1.0
|
|
27
|
-
* @since 0.0.1
|
|
28
|
-
* @author AMBROISE PARK Consulting
|
|
29
|
-
*/
|
|
30
|
-
export function AuthGuard({ auth, children, fallback: Fallback = () => _jsx(Spinner, { overlay: true }), }) {
|
|
31
|
-
const navigate = useNavigate();
|
|
32
|
-
const user = useAuthSafe('user');
|
|
33
|
-
const status = useAuthSafe('status');
|
|
34
|
-
const { shouldRedirect, redirectTo, isChecking } = useRedirectGuard({
|
|
35
|
-
auth,
|
|
36
|
-
});
|
|
37
|
-
// Redirect if needed - save current path when redirecting unauthenticated user
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (shouldRedirect && redirectTo) {
|
|
40
|
-
if (!user && isClient()) {
|
|
41
|
-
safeSessionStorage.setItem('dndev.auth.returnTo', window.location.pathname + window.location.search);
|
|
42
|
-
safeSessionStorage.setItem('dndev.auth.guardToast', '1');
|
|
43
|
-
}
|
|
44
|
-
navigate(redirectTo, { replace: true });
|
|
45
|
-
}
|
|
46
|
-
}, [shouldRedirect, redirectTo, navigate, user]);
|
|
47
|
-
// Return-to after OAuth is handled by AuthReturnTo (mounted in RootLayout).
|
|
48
|
-
// Public route - no auth required
|
|
49
|
-
if (auth === false) {
|
|
50
|
-
return _jsx(_Fragment, { children: children });
|
|
51
|
-
}
|
|
52
|
-
// Show spinner while redirect will happen or auth is still checking
|
|
53
|
-
if (shouldRedirect || isChecking) {
|
|
54
|
-
return _jsx(Spinner, { overlay: true });
|
|
55
|
-
}
|
|
56
|
-
// Still initializing auth - show fallback spinner
|
|
57
|
-
if (status === FEATURE_STATUS.INITIALIZING) {
|
|
58
|
-
return _jsx(Fallback, {});
|
|
59
|
-
}
|
|
60
|
-
// All checks passed, render children
|
|
61
|
-
return _jsx(_Fragment, { children: children });
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Hook to check if current user can navigate to a route with given auth config
|
|
65
|
-
* ONLY uses store - single source of truth!
|
|
66
|
-
*
|
|
67
|
-
* @version 0.1.0
|
|
68
|
-
* @since 0.0.1
|
|
69
|
-
* @author AMBROISE PARK Consulting
|
|
70
|
-
*/
|
|
71
|
-
export function useCanNavigate(auth) {
|
|
72
|
-
const can = useAuthSafe('can');
|
|
73
|
-
return can?.navigate(auth) ?? false;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Hook to get current user's role - directly from store
|
|
77
|
-
*
|
|
78
|
-
* @version 0.1.0
|
|
79
|
-
* @since 0.0.1
|
|
80
|
-
* @author AMBROISE PARK Consulting
|
|
81
|
-
*/
|
|
82
|
-
export function useUserRole() {
|
|
83
|
-
const user = useAuthSafe('user');
|
|
84
|
-
const role = user?.role;
|
|
85
|
-
return (role || USER_ROLES.GUEST);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Hook to check specific role - directly from store
|
|
89
|
-
*
|
|
90
|
-
* @version 0.1.0
|
|
91
|
-
* @since 0.0.1
|
|
92
|
-
* @author AMBROISE PARK Consulting
|
|
93
|
-
*/
|
|
94
|
-
export function useHasRole(role) {
|
|
95
|
-
const user = useAuthSafe('user');
|
|
96
|
-
// Use cached role for display purposes
|
|
97
|
-
return user?.role === role;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Hook to get all auth state for debugging
|
|
101
|
-
*
|
|
102
|
-
* @version 0.1.0
|
|
103
|
-
* @since 0.0.1
|
|
104
|
-
* @author AMBROISE PARK Consulting
|
|
105
|
-
*/
|
|
106
|
-
export function useAuthState() {
|
|
107
|
-
const user = useAuthSafe('user');
|
|
108
|
-
const userSubscription = useAuthSafe('userSubscription');
|
|
109
|
-
const loading = useAuthSafe('loading');
|
|
110
|
-
return {
|
|
111
|
-
authenticated: !!user,
|
|
112
|
-
role: user?.role,
|
|
113
|
-
tier: userSubscription?.tier || 'free',
|
|
114
|
-
loading,
|
|
115
|
-
userId: user?.id,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* HOC to wrap components with auth protection
|
|
120
|
-
*
|
|
121
|
-
* @version 0.1.0
|
|
122
|
-
* @since 0.0.1
|
|
123
|
-
* @author AMBROISE PARK Consulting
|
|
124
|
-
*/
|
|
125
|
-
export function withAuth(Component, auth) {
|
|
126
|
-
const WrappedComponent = (props) => (_jsx(AuthGuard, { auth: auth, children: _jsx(Component, { ...props }) }));
|
|
127
|
-
return WrappedComponent;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Utility to create auth configs
|
|
131
|
-
*
|
|
132
|
-
* @version 0.1.0
|
|
133
|
-
* @since 0.0.1
|
|
134
|
-
* @author AMBROISE PARK Consulting
|
|
135
|
-
*/
|
|
136
|
-
export const createAuthConfig = {
|
|
137
|
-
/** No authentication required */
|
|
138
|
-
public: () => false,
|
|
139
|
-
/** Basic authentication required */
|
|
140
|
-
required: () => ({ required: true }),
|
|
141
|
-
/** User role (any authenticated user) */
|
|
142
|
-
user: () => ({
|
|
143
|
-
required: true,
|
|
144
|
-
role: USER_ROLES.USER,
|
|
145
|
-
}),
|
|
146
|
-
/** Admin role (Firebase custom claim isAdmin: true) */
|
|
147
|
-
admin: () => ({
|
|
148
|
-
required: true,
|
|
149
|
-
role: USER_ROLES.ADMIN,
|
|
150
|
-
}),
|
|
151
|
-
/** Tier-based authentication */
|
|
152
|
-
tier: (tier) => ({
|
|
153
|
-
required: true,
|
|
154
|
-
tier,
|
|
155
|
-
}),
|
|
156
|
-
/** Pro tier */
|
|
157
|
-
pro: () => ({
|
|
158
|
-
required: true,
|
|
159
|
-
tier: SUBSCRIPTION_TIERS.PRO,
|
|
160
|
-
}),
|
|
161
|
-
/** Premium tier */
|
|
162
|
-
premium: () => ({
|
|
163
|
-
required: true,
|
|
164
|
-
tier: SUBSCRIPTION_TIERS.PREMIUM,
|
|
165
|
-
}),
|
|
166
|
-
/** Admin with pro tier requirement */
|
|
167
|
-
adminPro: () => ({
|
|
168
|
-
required: true,
|
|
169
|
-
role: USER_ROLES.ADMIN,
|
|
170
|
-
tier: SUBSCRIPTION_TIERS.PRO,
|
|
171
|
-
}),
|
|
172
|
-
/** Custom validation */
|
|
173
|
-
custom: (validate) => ({
|
|
174
|
-
required: true,
|
|
175
|
-
validate,
|
|
176
|
-
}),
|
|
177
|
-
};
|
|
178
|
-
export default AuthGuard;
|
|
1
|
+
"use client";import{useEffect as h}from"react";import{Spinner as S}from"@donotdev/components";import{FEATURE_STATUS as A,USER_ROLES as a,SUBSCRIPTION_TIERS as p,isClient as m,safeSessionStorage as c}from"@donotdev/core";import{useRedirectGuard as U,useNavigate as g}from"@donotdev/ui/routing/hooks";import{useAuthSafe as r}from"../utils/useAuthSafe.js";import{Fragment as d,jsx as o}from"react/jsx-runtime";function R({auth:e,children:t,fallback:u=()=>o(S,{overlay:!0})}){let n=g(),f=r("user"),l=r("status"),{shouldRedirect:i,redirectTo:s,isChecking:E}=U({auth:e});return h(()=>{i&&s&&(!f&&m()&&(c.setItem("dndev.auth.returnTo",window.location.pathname+window.location.search),c.setItem("dndev.auth.guardToast","1")),n(s,{replace:!0}))},[i,s,n,f]),e===!1?o(d,{children:t}):i||E?o(S,{overlay:!0}):l===A.INITIALIZING?o(u,{}):o(d,{children:t})}function N(e){return r("can")?.navigate(e)??!1}function _(){return r("user")?.role||a.GUEST}function C(e){return r("user")?.role===e}function L(){let e=r("user"),t=r("userSubscription"),u=r("loading");return{authenticated:!!e,role:e?.role,tier:t?.tier||"free",loading:u,userId:e?.id}}function G(e,t){return n=>o(R,{auth:t,children:o(e,{...n})})}var b={public:()=>!1,required:()=>({required:!0}),user:()=>({required:!0,role:a.USER}),admin:()=>({required:!0,role:a.ADMIN}),tier:e=>({required:!0,tier:e}),pro:()=>({required:!0,tier:p.PRO}),premium:()=>({required:!0,tier:p.PREMIUM}),adminPro:()=>({required:!0,role:a.ADMIN,tier:p.PRO}),custom:e=>({required:!0,validate:e})},q=R;export{R as AuthGuard,b as createAuthConfig,q as default,L as useAuthState,N as useCanNavigate,C as useHasRole,_ as useUserRole,G as withAuth};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthGuardFallback.d.ts","sourceRoot":"","sources":["../../src/routing/AuthGuardFallback.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AuthGuardFallback.d.ts","sourceRoot":"","sources":["../../src/routing/AuthGuardFallback.tsx"],"names":[],"mappings":"AA8BA,UAAU,sBAAsB;IAC9B,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gCAAgC;IAChC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,WAAW,EACX,cAAqB,EACrB,MAAM,EACN,SAAc,GACf,EAAE,sBAAsB,+BAqHxB;AAED,eAAe,iBAAiB,CAAC"}
|