@donotdev/ui 0.1.0 → 0.1.1
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/{GoToDialog-CR4VOVXT.js → GoToDialog-RU5RP7S2.js} +1 -1
- package/dist/chunk-ETE4RC7M.js +1 -0
- package/dist/components/auth/AuthHeader.d.ts +6 -1
- package/dist/components/auth/AuthHeader.d.ts.map +1 -1
- package/dist/components/auth/AuthHeader.js +4 -4
- package/dist/components/common/FeatureCard.d.ts +2 -0
- package/dist/components/common/FeatureCard.d.ts.map +1 -1
- package/dist/components/common/FeatureDisabled.d.ts +1 -0
- package/dist/components/common/FeatureDisabled.d.ts.map +1 -1
- package/dist/components/common/TechBento.d.ts +1 -0
- package/dist/components/common/TechBento.d.ts.map +1 -1
- package/dist/components/common/icon.d.ts +1 -0
- package/dist/components/common/icon.d.ts.map +1 -1
- package/dist/components/cookie-consent/CookieConsent.d.ts +1 -0
- package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
- package/dist/components/layout/PageConfig.d.ts +25 -0
- package/dist/components/layout/PageConfig.d.ts.map +1 -0
- package/dist/components/layout/PageConfig.js +47 -0
- package/dist/components/layout/components/Breadcrumbs.d.ts +2 -0
- package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
- package/dist/components/layout/components/FloatingLanguageSwitcher.d.ts +1 -0
- package/dist/components/layout/components/FloatingLanguageSwitcher.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppBranding.d.ts +1 -0
- package/dist/components/layout/components/header/AppBranding.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppIcon.d.ts +1 -0
- package/dist/components/layout/components/header/AppIcon.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppTitle.d.ts +1 -0
- package/dist/components/layout/components/header/AppTitle.d.ts.map +1 -1
- package/dist/components/layout/components/header/CacheSettings.js +2 -2
- package/dist/components/layout/components/header/GameTitle.d.ts +1 -0
- package/dist/components/layout/components/header/GameTitle.d.ts.map +1 -1
- package/dist/components/layout/components/header/HeaderMenu.d.ts +1 -0
- package/dist/components/layout/components/header/HeaderMenu.d.ts.map +1 -1
- package/dist/components/layout/components/header/HeaderNavigation.d.ts +1 -0
- package/dist/components/layout/components/header/HeaderNavigation.d.ts.map +1 -1
- package/dist/components/layout/components/header/SettingsMenu.d.ts +1 -0
- package/dist/components/layout/components/header/SettingsMenu.d.ts.map +1 -1
- package/dist/components/layout/index.d.ts +1 -0
- package/dist/components/layout/index.d.ts.map +1 -1
- package/dist/components/layout/index.js +1 -0
- package/dist/crud/components/EntityCardList.d.ts +1 -1
- package/dist/crud/components/EntityCardList.d.ts.map +1 -1
- package/dist/crud/components/EntityCardList.js +32 -21
- package/dist/crud/components/EntityDisplayRenderer.d.ts +1 -1
- package/dist/crud/components/EntityDisplayRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityDisplayRenderer.js +13 -12
- package/dist/crud/components/EntityFormRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityFormRenderer.js +16 -18
- package/dist/crud/components/EntityList.d.ts +1 -1
- package/dist/crud/components/EntityList.d.ts.map +1 -1
- package/dist/crud/components/EntityList.js +40 -24
- package/dist/crud/components/EntityRecommendations.d.ts +1 -1
- package/dist/crud/components/EntityRecommendations.d.ts.map +1 -1
- package/dist/crud/components/EntityRecommendations.js +4 -4
- package/dist/crud/crudImports.d.ts +1 -0
- package/dist/crud/crudImports.d.ts.map +1 -1
- package/dist/crud/crudImports.js +1 -0
- package/dist/dndev-next.css +198 -75
- package/dist/dndev.css +228 -74
- package/dist/index.js +4 -4
- package/dist/internal/common/ErrorFallback.js +1 -1
- package/dist/internal/devtools/DebugTools.js +1 -1
- package/dist/internal/devtools/components/DesignTab.d.ts.map +1 -1
- package/dist/internal/devtools/components/DesignTab.js +6 -2
- package/dist/internal/devtools/utils/envVarDiscovery.d.ts.map +1 -1
- package/dist/internal/devtools/utils/envVarDiscovery.js +4 -5
- package/dist/internal/devtools/utils/virtualModuleInspector.d.ts.map +1 -1
- package/dist/internal/devtools/utils/virtualModuleInspector.js +2 -0
- package/dist/internal/initializers/BaseStoresInitializer.d.ts.map +1 -1
- package/dist/internal/initializers/BaseStoresInitializer.js +11 -2
- package/dist/internal/layout/DnDevLayout.d.ts.map +1 -1
- package/dist/internal/layout/DnDevLayout.js +39 -16
- package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/AutoMetaTags.js +55 -23
- package/dist/internal/layout/components/NextJsAutoMetaTags.d.ts +2 -0
- package/dist/internal/layout/components/NextJsAutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/NextJsAutoMetaTags.js +45 -15
- package/dist/internal/layout/components/PWAUpdateNotification.d.ts.map +1 -1
- package/dist/internal/layout/components/PWAUpdateNotification.js +15 -2
- package/dist/internal/layout/zones/DnDevFooter.d.ts +3 -1
- package/dist/internal/layout/zones/DnDevFooter.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevFooter.js +5 -1
- package/dist/internal/layout/zones/DnDevHeader.d.ts +3 -1
- package/dist/internal/layout/zones/DnDevHeader.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevHeader.js +7 -2
- package/dist/internal/layout/zones/DnDevSidebar.d.ts +3 -1
- package/dist/internal/layout/zones/DnDevSidebar.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevSidebar.js +9 -3
- package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
- package/dist/providers/NextJsAppProviders.js +3 -1
- package/dist/routing/AuthGuard.d.ts +7 -22
- package/dist/routing/AuthGuard.d.ts.map +1 -1
- package/dist/routing/AuthGuard.js +19 -64
- package/dist/routing/AuthReturnTo.d.ts +13 -0
- package/dist/routing/AuthReturnTo.d.ts.map +1 -0
- package/dist/routing/AuthReturnTo.js +61 -0
- package/dist/routing/DnDevNavigationMenu.d.ts +1 -0
- package/dist/routing/DnDevNavigationMenu.d.ts.map +1 -1
- package/dist/routing/GoTo.d.ts +1 -0
- package/dist/routing/GoTo.d.ts.map +1 -1
- package/dist/routing/hooks/hooks.next.js +1 -1
- package/dist/routing/hooks/hooks.vite.js +1 -1
- package/dist/routing/hooks/useNavigate.next.d.ts +8 -0
- package/dist/routing/hooks/useNavigate.next.d.ts.map +1 -1
- package/dist/routing/hooks/useNavigate.next.js +58 -8
- package/dist/routing/hooks/useNavigate.vite.d.ts +8 -0
- package/dist/routing/hooks/useNavigate.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useNavigate.vite.js +64 -14
- package/dist/routing/hooks/useRedirectGuard.next.d.ts +2 -0
- package/dist/routing/hooks/useRedirectGuard.next.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.next.js +11 -27
- package/dist/routing/hooks/useRedirectGuard.vite.d.ts +2 -0
- package/dist/routing/hooks/useRedirectGuard.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.vite.js +11 -27
- package/dist/routing/index.d.ts +1 -0
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +1 -0
- package/dist/styles/index.css +228 -74
- package/dist/symbol-index.json +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/sanitizeSvg.d.ts +4 -0
- package/dist/utils/sanitizeSvg.d.ts.map +1 -1
- package/dist/utils/sanitizeSvg.js +4 -0
- package/dist/utils/useAISafe.d.ts +28 -0
- package/dist/utils/useAISafe.d.ts.map +1 -0
- package/dist/utils/useAISafe.js +53 -0
- package/dist/utils/useAuthSafe.d.ts +39 -0
- package/dist/utils/useAuthSafe.d.ts.map +1 -1
- package/dist/utils/useAuthSafe.js +5 -0
- package/dist/utils/useAuthVisibility.d.ts +1 -0
- package/dist/utils/useAuthVisibility.d.ts.map +1 -1
- package/dist/utils/useBillingVisibility.d.ts +1 -0
- package/dist/utils/useBillingVisibility.d.ts.map +1 -1
- package/dist/utils/useSeo.d.ts +121 -0
- package/dist/utils/useSeo.d.ts.map +1 -0
- package/dist/utils/useSeo.js +114 -0
- package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
- package/dist/vite-routing/AppRoutes.js +14 -4
- package/dist/vite-routing/RootLayout.d.ts.map +1 -1
- package/dist/vite-routing/RootLayout.js +6 -4
- package/guidelines/COMPONENTS.md +136 -0
- package/guidelines/GOTCHAS.md +66 -0
- package/guidelines/LAYOUTS.md +310 -0
- package/guidelines/PAGES.md +205 -0
- package/guidelines/ROUTING.md +499 -0
- package/guidelines/SEO.md +275 -0
- package/package.json +12 -7
- package/dist/chunk-XHGRMKOY.js +0 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { AppMetadata } from '@donotdev/core';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
3
|
export interface DnDevFooterProps {
|
|
4
|
+
/** Custom mode: full zone replacement. When provided, app prop is ignored and no polish CSS applies. */
|
|
5
|
+
children?: ReactNode;
|
|
4
6
|
/** App metadata for copyright/links */
|
|
5
7
|
app?: AppMetadata;
|
|
6
8
|
}
|
|
@@ -24,7 +26,7 @@ export interface DnDevFooterProps {
|
|
|
24
26
|
* preset-specific visibility (moolti/plain hide footer, blog hides on mobile).
|
|
25
27
|
* DO NOT change role, tag, or className.
|
|
26
28
|
*/
|
|
27
|
-
declare function DnDevFooterComponent({ app }: DnDevFooterProps): ReactNode;
|
|
29
|
+
declare function DnDevFooterComponent({ children, app }: DnDevFooterProps): ReactNode;
|
|
28
30
|
export declare const DnDevFooter: import("react").MemoExoticComponent<typeof DnDevFooterComponent>;
|
|
29
31
|
export {};
|
|
30
32
|
//# sourceMappingURL=DnDevFooter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DnDevFooter.d.ts","sourceRoot":"","sources":["../../../../src/internal/layout/zones/DnDevFooter.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAUlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,GAAG,CAAC,EAAE,WAAW,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,oBAAoB,CAAC,EAAE,GAAQ,EAAE,EAAE,gBAAgB,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"DnDevFooter.d.ts","sourceRoot":"","sources":["../../../../src/internal/layout/zones/DnDevFooter.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAUlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,MAAM,WAAW,gBAAgB;IAC/B,wGAAwG;IACxG,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,uCAAuC;IACvC,GAAG,CAAC,EAAE,WAAW,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,oBAAoB,CAAC,EAAE,QAAQ,EAAE,GAAQ,EAAE,EAAE,gBAAgB,GAAG,SAAS,CAuFjF;AAED,eAAO,MAAM,WAAW,kEAA6B,CAAC"}
|
|
@@ -38,11 +38,15 @@ import { getLegalLinks, } from '../components/footer/useLegalLinks';
|
|
|
38
38
|
* preset-specific visibility (moolti/plain hide footer, blog hides on mobile).
|
|
39
39
|
* DO NOT change role, tag, or className.
|
|
40
40
|
*/
|
|
41
|
-
function DnDevFooterComponent({ app = {} }) {
|
|
41
|
+
function DnDevFooterComponent({ children, app = {} }) {
|
|
42
42
|
const { t } = useTranslation('dndev');
|
|
43
43
|
const isLaptopOrDesktop = useBreakpoint('isLaptopOrDesktop');
|
|
44
44
|
// Get legal links (defaults or custom) — must be called before any return
|
|
45
45
|
const links = getLegalLinks(app?.footer);
|
|
46
|
+
// Custom mode: consumer owns zone visuals, structural wrapper only
|
|
47
|
+
if (children !== undefined) {
|
|
48
|
+
return (_jsx("footer", { role: "contentinfo", className: "footer", "data-custom": true, children: children }));
|
|
49
|
+
}
|
|
46
50
|
// Explicit null hides footer
|
|
47
51
|
if (app?.footer === null) {
|
|
48
52
|
return null;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
export interface DnDevHeaderProps {
|
|
3
|
+
/** Custom mode: full zone replacement. When provided, slot props are ignored and no polish CSS applies. */
|
|
4
|
+
children?: ReactNode;
|
|
3
5
|
/** Start slot - ReactNode from preset or consumer override */
|
|
4
6
|
start?: ReactNode | null;
|
|
5
7
|
/** Center slot - ReactNode from preset or consumer override */
|
|
@@ -20,7 +22,7 @@ export interface DnDevHeaderProps {
|
|
|
20
22
|
* and preset-specific rules (e.g. landing compact mode, mergedBar hiding).
|
|
21
23
|
* DO NOT change role, tag, or classNames.
|
|
22
24
|
*/
|
|
23
|
-
declare function DnDevHeaderComponent({ start, center, end, }: DnDevHeaderProps): ReactNode;
|
|
25
|
+
declare function DnDevHeaderComponent({ children, start, center, end, }: DnDevHeaderProps): ReactNode;
|
|
24
26
|
export declare const DnDevHeader: import("react").MemoExoticComponent<typeof DnDevHeaderComponent>;
|
|
25
27
|
export {};
|
|
26
28
|
//# sourceMappingURL=DnDevHeader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DnDevHeader.d.ts","sourceRoot":"","sources":["../../../../src/internal/layout/zones/DnDevHeader.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,KAAK,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IACzB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC1B,4DAA4D;IAC5D,GAAG,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,iBAAS,oBAAoB,CAAC,EAC5B,KAAK,EACL,MAAM,EACN,GAAG,GACJ,EAAE,gBAAgB,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"DnDevHeader.d.ts","sourceRoot":"","sources":["../../../../src/internal/layout/zones/DnDevHeader.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,gBAAgB;IAC/B,2GAA2G;IAC3G,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IACzB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC1B,4DAA4D;IAC5D,GAAG,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,iBAAS,oBAAoB,CAAC,EAC5B,QAAQ,EACR,KAAK,EACL,MAAM,EACN,GAAG,GACJ,EAAE,gBAAgB,GAAG,SAAS,CAsB9B;AAED,eAAO,MAAM,WAAW,kEAA6B,CAAC"}
|
|
@@ -28,8 +28,13 @@ import { cn } from '@donotdev/components';
|
|
|
28
28
|
* and preset-specific rules (e.g. landing compact mode, mergedBar hiding).
|
|
29
29
|
* DO NOT change role, tag, or classNames.
|
|
30
30
|
*/
|
|
31
|
-
function DnDevHeaderComponent({ start, center, end, }) {
|
|
32
|
-
//
|
|
31
|
+
function DnDevHeaderComponent({ children, start, center, end, }) {
|
|
32
|
+
// Custom mode: children provided = consumer owns zone visuals
|
|
33
|
+
const isCustom = children !== undefined;
|
|
34
|
+
if (isCustom) {
|
|
35
|
+
return (_jsx("header", { role: "banner", className: "header", "data-custom": true, children: children }));
|
|
36
|
+
}
|
|
37
|
+
// Slotted mode: framework slot layout with polish CSS
|
|
33
38
|
const hasCenter = center !== null && center !== undefined;
|
|
34
39
|
return (_jsxs("header", { role: "banner", className: "header", children: [_jsx("div", { className: "header-start", children: start }), hasCenter && _jsx("div", { className: "header-center", children: center }), _jsx("div", { className: "header-end", children: end })] }));
|
|
35
40
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
export interface DnDevSidebarProps {
|
|
3
|
+
/** Custom mode: full zone replacement. When provided, slot props are ignored and no polish CSS applies. */
|
|
4
|
+
children?: ReactNode;
|
|
3
5
|
/** Top slot - ReactNode from preset or consumer override */
|
|
4
6
|
top?: ReactNode | null;
|
|
5
7
|
/** Content slot - ReactNode from preset or consumer override */
|
|
@@ -23,7 +25,7 @@ export interface DnDevSidebarProps {
|
|
|
23
25
|
* targets `aside[role='navigation'].sidebar`. Removing it silently breaks every sidebar feature.
|
|
24
26
|
* DO NOT remove or change role="navigation" under any circumstance.
|
|
25
27
|
*/
|
|
26
|
-
declare function DnDevSidebarComponent({ top, content, bottom, defaultWidth, minWidth, maxWidth, }: DnDevSidebarProps): ReactNode;
|
|
28
|
+
declare function DnDevSidebarComponent({ children, top, content, bottom, defaultWidth, minWidth, maxWidth, }: DnDevSidebarProps): ReactNode;
|
|
27
29
|
export declare const DnDevSidebar: import("react").MemoExoticComponent<typeof DnDevSidebarComponent>;
|
|
28
30
|
export {};
|
|
29
31
|
//# sourceMappingURL=DnDevSidebar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DnDevSidebar.d.ts","sourceRoot":"","sources":["../../../../src/internal/layout/zones/DnDevSidebar.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,MAAM,WAAW,iBAAiB;IAChC,4DAA4D;IAC5D,GAAG,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IACvB,gEAAgE;IAChE,OAAO,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC3B,+DAA+D;IAC/D,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC1B,6CAA6C;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,iBAAS,qBAAqB,CAAC,EAC7B,GAAG,EACH,OAAO,EACP,MAAM,EACN,YAAiD,EACjD,QAAyC,EACzC,QAAyC,GAC1C,EAAE,iBAAiB,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"DnDevSidebar.d.ts","sourceRoot":"","sources":["../../../../src/internal/layout/zones/DnDevSidebar.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,MAAM,WAAW,iBAAiB;IAChC,2GAA2G;IAC3G,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,4DAA4D;IAC5D,GAAG,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IACvB,gEAAgE;IAChE,OAAO,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC3B,+DAA+D;IAC/D,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC1B,6CAA6C;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,iBAAS,qBAAqB,CAAC,EAC7B,QAAQ,EACR,GAAG,EACH,OAAO,EACP,MAAM,EACN,YAAiD,EACjD,QAAyC,EACzC,QAAyC,GAC1C,EAAE,iBAAiB,GAAG,SAAS,CA+M/B;AAED,eAAO,MAAM,YAAY,mEAA8B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// packages/ui/src/internal/layout/zones/DnDevSidebar.tsx
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview DnDevSidebar Zone Component
|
|
@@ -28,7 +28,9 @@ const RESIZE_HANDLE_WIDTH = 6;
|
|
|
28
28
|
* targets `aside[role='navigation'].sidebar`. Removing it silently breaks every sidebar feature.
|
|
29
29
|
* DO NOT remove or change role="navigation" under any circumstance.
|
|
30
30
|
*/
|
|
31
|
-
function DnDevSidebarComponent({ top, content, bottom, defaultWidth = DEFAULT_SLOTS.sidebar.defaultWidth, minWidth = DEFAULT_SLOTS.sidebar.minWidth, maxWidth = DEFAULT_SLOTS.sidebar.maxWidth, }) {
|
|
31
|
+
function DnDevSidebarComponent({ children, top, content, bottom, defaultWidth = DEFAULT_SLOTS.sidebar.defaultWidth, minWidth = DEFAULT_SLOTS.sidebar.minWidth, maxWidth = DEFAULT_SLOTS.sidebar.maxWidth, }) {
|
|
32
|
+
// Custom mode: children provided = consumer owns zone visuals, data-custom skips polish CSS
|
|
33
|
+
const isCustom = children !== undefined;
|
|
32
34
|
// Resize state
|
|
33
35
|
const sidebarWidth = useLayout('sidebarWidth') ?? defaultWidth;
|
|
34
36
|
const setSidebarWidth = useLayout('setSidebarWidth');
|
|
@@ -170,6 +172,10 @@ function DnDevSidebarComponent({ top, content, bottom, defaultWidth = DEFAULT_SL
|
|
|
170
172
|
* resize handle styles, collapsed styles — essentially ALL sidebar behavior.
|
|
171
173
|
* aria-label provides the accessible name. Both attributes are required.
|
|
172
174
|
*/
|
|
173
|
-
_jsxs("aside", { ref: asideRef, role: "navigation", "aria-label": "Site navigation", className: "sidebar", "data-dragging": isDragging, "data-collapsed": isCollapsed,
|
|
175
|
+
_jsxs("aside", { ref: asideRef, role: "navigation", "aria-label": "Site navigation", className: "sidebar", "data-dragging": isDragging, "data-collapsed": isCollapsed, "data-custom": isCustom || undefined, children: [isCustom ? (
|
|
176
|
+
/* Custom mode: consumer component fills content area, no slot divs */
|
|
177
|
+
children) : (
|
|
178
|
+
/* Slotted mode: framework slot layout with polish CSS */
|
|
179
|
+
_jsxs(_Fragment, { children: [top && _jsx("div", { className: "sidebar-top", children: top }), _jsx("div", { className: "sidebar-content", children: content }), bottom && _jsx("div", { className: "sidebar-bottom", children: bottom })] })), _jsx("div", { className: "dndev-sidebar-resize-handle", onPointerDown: handlePointerDown, onDoubleClick: toggleCollapse, onKeyDown: handleKeyDown, role: "separator", "aria-label": "Resize sidebar. Double-click or Enter to toggle. Home to collapse, End to fit content.", "aria-valuenow": sidebarWidth, "aria-valuemin": minWidth, "aria-valuemax": maxWidth, "aria-orientation": "vertical", tabIndex: 0 })] }));
|
|
174
180
|
}
|
|
175
181
|
export const DnDevSidebar = memo(DnDevSidebarComponent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextJsAppProviders.d.ts","sourceRoot":"","sources":["../../src/providers/NextJsAppProviders.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"NextJsAppProviders.d.ts","sourceRoot":"","sources":["../../src/providers/NextJsAppProviders.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AA+DxD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,2CAuDhE"}
|
|
@@ -20,6 +20,8 @@ import PerformanceHints from '../internal/layout/components/PerformanceHints';
|
|
|
20
20
|
import { DnDevLayout } from '../internal/layout/DnDevLayout';
|
|
21
21
|
import { SentryInitializer } from '../internal/providers/SentryInitializer';
|
|
22
22
|
import { UIProviders } from '../internal/providers/UIProviders';
|
|
23
|
+
import { PasswordResetCallback } from '../utils/useAuthSafe';
|
|
24
|
+
import { AuthReturnTo } from '../routing/AuthReturnTo';
|
|
23
25
|
// Null fallback for lazy components that fail to load (e.g., optional auth dependency absent)
|
|
24
26
|
const NullFallback = () => null;
|
|
25
27
|
// Lazy load client-only components — each wrapped with catch to prevent hanging
|
|
@@ -52,5 +54,5 @@ function ConsentBanner() {
|
|
|
52
54
|
}
|
|
53
55
|
export function NextJsAppProviders(props) {
|
|
54
56
|
const { config = {}, layout, children, serverCookies, customStores } = props;
|
|
55
|
-
return (_jsxs(AppConfigProvider, { config: config, platform: "nextjs", children: [_jsx(SentryInitializer, {}), _jsx(HelmetProvider, { children: _jsxs(NextJsStoresInitializer, { serverCookies: serverCookies, customStores: customStores, children: [_jsx(FaviconHead, {}), _jsx(PerformanceHints, {}), _jsx(QueryProviders, { children: _jsxs(UIProviders, { children: [_jsx(DnDevLayout, { layout: layout, children: children }), _jsx(ConsentBanner, {}), _jsx(Suspense, { fallback: null, children: _jsx(PWAUpdateNotification, {}) }), _jsx(Suspense, { fallback: null, children: _jsx(LicenseWatermark, {}) }), _jsx(Suspense, { fallback: null, children: _jsx(RedirectOverlay, {}) })] }) })] }) })] }));
|
|
57
|
+
return (_jsxs(AppConfigProvider, { config: config, platform: "nextjs", children: [_jsx(SentryInitializer, {}), _jsx(HelmetProvider, { children: _jsxs(NextJsStoresInitializer, { serverCookies: serverCookies, customStores: customStores, children: [_jsx(FaviconHead, {}), _jsx(PerformanceHints, {}), _jsx(QueryProviders, { children: _jsxs(UIProviders, { children: [_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(LicenseWatermark, {}) }), _jsx(Suspense, { fallback: null, children: _jsx(RedirectOverlay, {}) })] }) })] }) })] }));
|
|
56
58
|
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* @version 0.1.0
|
|
6
|
-
* @since 0.0.1
|
|
7
|
-
* @author AMBROISE PARK Consulting
|
|
8
|
-
*/
|
|
9
|
-
import { type ReactNode, type ComponentType } from 'react';
|
|
10
|
-
import { USER_ROLES, SUBSCRIPTION_TIERS, type PageAuth } from '@donotdev/core';
|
|
1
|
+
import type { ReactNode, ComponentType } from 'react';
|
|
2
|
+
import { USER_ROLES, SUBSCRIPTION_TIERS } from '@donotdev/core';
|
|
3
|
+
import type { PageAuth } from '@donotdev/core';
|
|
11
4
|
/**
|
|
12
5
|
* Props for AuthGuard component
|
|
13
6
|
*/
|
|
@@ -20,19 +13,11 @@ interface AuthGuardProps {
|
|
|
20
13
|
fallback?: ComponentType;
|
|
21
14
|
}
|
|
22
15
|
/**
|
|
23
|
-
* AuthGuard
|
|
24
|
-
*
|
|
25
|
-
* 🎯 SINGLE SOURCE OF TRUTH: Only uses @donotdev/core, never directly calls auth
|
|
26
|
-
*
|
|
27
|
-
* Role System (from store):
|
|
28
|
-
* - 'guest': No authentication
|
|
29
|
-
* - 'user': Authenticated Firebase user
|
|
30
|
-
* - 'admin': Authenticated user with Firebase custom claim isAdmin: true
|
|
16
|
+
* AuthGuard - cold-load redirect safety net
|
|
31
17
|
*
|
|
32
|
-
*
|
|
33
|
-
* -
|
|
34
|
-
*
|
|
35
|
-
* - 'premium': Premium features
|
|
18
|
+
* For SPA navigation, auth is intercepted in useNavigate (before page mount).
|
|
19
|
+
* This component handles the cold-load case: user pastes a protected URL directly.
|
|
20
|
+
* It redirects to authRoute, saves returnTo, and AuthReturnTo handles the redirect back.
|
|
36
21
|
*
|
|
37
22
|
* @version 0.1.0
|
|
38
23
|
* @since 0.0.1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthGuard.d.ts","sourceRoot":"","sources":["../../src/routing/AuthGuard.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AuthGuard.d.ts","sourceRoot":"","sources":["../../src/routing/AuthGuard.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,EAEL,UAAU,EACV,kBAAkB,EAGnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAM/C;;GAEG;AACH,UAAU,cAAc;IACtB,wCAAwC;IACxC,IAAI,EAAE,QAAQ,GAAG,KAAK,CAAC;IACvB,wCAAwC;IACxC,QAAQ,EAAE,SAAS,CAAC;IACpB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,QAAQ,EACR,QAAQ,EAAE,QAAoC,GAC/C,EAAE,cAAc,2CA0ChB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,CAG9D;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,uBAAiB,CAAC;AAE3C;;;;;;GAMG;AACH,wBAAgB,WAAW,IACvB,OAAO,UAAU,CAAC,KAAK,GACvB,OAAO,UAAU,CAAC,IAAI,GACtB,OAAO,UAAU,CAAC,KAAK,CAS1B;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,IAAI,EACA,OAAO,UAAU,CAAC,KAAK,GACvB,OAAO,UAAU,CAAC,IAAI,GACtB,OAAO,UAAU,CAAC,KAAK,GAC1B,OAAO,CAIT;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY;;;;;;EAW3B;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EACvC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAC3B,IAAI,EAAE,QAAQ,GAAG,KAAK,WAEW,CAAC,6CAOnC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB;IAC3B,iCAAiC;kBACrB,KAAK;IAEjB,oCAAoC;oBACtB,QAAQ;IAEtB,yCAAyC;gBAC/B,QAAQ;IAKlB,uDAAuD;iBAC5C,QAAQ;IAKnB,gCAAgC;iBAExB,CAAC,OAAO,kBAAkB,EAAE,MAAM,OAAO,kBAAkB,CAAC,KACjE,QAAQ;IAKX,eAAe;eACN,QAAQ;IAKjB,mBAAmB;mBACN,QAAQ;IAKrB,sCAAsC;oBACxB,QAAQ;IAMtB,wBAAwB;uBACL,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,KAAG,QAAQ;CAItE,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,36 +1,27 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, Fragment as _Fragment
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
// packages/ui/src/routing/AuthGuard.tsx
|
|
4
4
|
/**
|
|
5
5
|
* @fileoverview AuthGuard component
|
|
6
|
-
* @description
|
|
6
|
+
* @description Cold-load safety net for protected routes. Redirects unauthenticated
|
|
7
|
+
* users to authRoute. SPA navigation is intercepted earlier in useNavigate.
|
|
7
8
|
*
|
|
8
9
|
* @version 0.1.0
|
|
9
10
|
* @since 0.0.1
|
|
10
11
|
* @author AMBROISE PARK Consulting
|
|
11
12
|
*/
|
|
12
|
-
import { useEffect,
|
|
13
|
-
import { Spinner
|
|
14
|
-
import {
|
|
13
|
+
import { useEffect, } from 'react';
|
|
14
|
+
import { Spinner } from '@donotdev/components';
|
|
15
|
+
import { FEATURE_STATUS, USER_ROLES, SUBSCRIPTION_TIERS, isClient, safeSessionStorage, } from '@donotdev/core';
|
|
15
16
|
// Platform-specific hooks via conditional exports
|
|
16
17
|
import { useRedirectGuard, useNavigate } from '@donotdev/ui/routing/hooks';
|
|
17
18
|
import { useAuthSafe } from '../utils/useAuthSafe';
|
|
18
|
-
// Lazy load consent component for auth routes
|
|
19
|
-
const CookieConsent = lazy(() => import('../components/cookie-consent/CookieConsent'));
|
|
20
19
|
/**
|
|
21
|
-
* AuthGuard
|
|
20
|
+
* AuthGuard - cold-load redirect safety net
|
|
22
21
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* - 'guest': No authentication
|
|
27
|
-
* - 'user': Authenticated Firebase user
|
|
28
|
-
* - 'admin': Authenticated user with Firebase custom claim isAdmin: true
|
|
29
|
-
*
|
|
30
|
-
* Subscription System (from store):
|
|
31
|
-
* - 'free': Basic features
|
|
32
|
-
* - 'pro': Professional features
|
|
33
|
-
* - 'premium': Premium features
|
|
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.
|
|
34
25
|
*
|
|
35
26
|
* @version 0.1.0
|
|
36
27
|
* @since 0.0.1
|
|
@@ -39,69 +30,33 @@ const CookieConsent = lazy(() => import('../components/cookie-consent/CookieCons
|
|
|
39
30
|
export function AuthGuard({ auth, children, fallback: Fallback = () => _jsx(Spinner, { overlay: true }), }) {
|
|
40
31
|
const navigate = useNavigate();
|
|
41
32
|
const user = useAuthSafe('user');
|
|
42
|
-
const can = useAuthSafe('can');
|
|
43
33
|
const status = useAuthSafe('status');
|
|
44
|
-
const [slowWarning, setSlowWarning] = useState(false);
|
|
45
|
-
// Check if redirect should happen BEFORE rendering fallback
|
|
46
34
|
const { shouldRedirect, redirectTo, isChecking } = useRedirectGuard({
|
|
47
35
|
auth,
|
|
48
36
|
});
|
|
49
|
-
|
|
50
|
-
// Soft timeout at 5 seconds - show warning, don't force redirect
|
|
51
|
-
// Firebase auth typically resolves in 200ms-800ms (broadband), 1-3s (cold start)
|
|
52
|
-
const timer = setTimeout(() => {
|
|
53
|
-
if (status === FEATURE_STATUS.INITIALIZING) {
|
|
54
|
-
setSlowWarning(true);
|
|
55
|
-
if (process.env.NODE_ENV === 'development') {
|
|
56
|
-
console.warn('[AuthGuard] Auth taking longer than usual (>5s)');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}, 5000);
|
|
60
|
-
return () => clearTimeout(timer);
|
|
61
|
-
}, [status]);
|
|
62
|
-
// Redirect if needed
|
|
37
|
+
// Redirect if needed - save current path when redirecting unauthenticated user
|
|
63
38
|
useEffect(() => {
|
|
64
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
|
+
}
|
|
65
44
|
navigate(redirectTo, { replace: true });
|
|
66
45
|
}
|
|
67
|
-
}, [shouldRedirect, redirectTo, navigate]);
|
|
46
|
+
}, [shouldRedirect, redirectTo, navigate, user]);
|
|
47
|
+
// Return-to after OAuth is handled by AuthReturnTo (mounted in RootLayout).
|
|
68
48
|
// Public route - no auth required
|
|
69
49
|
if (auth === false) {
|
|
70
50
|
return _jsx(_Fragment, { children: children });
|
|
71
51
|
}
|
|
72
|
-
//
|
|
73
|
-
// This prevents content flash before redirect
|
|
52
|
+
// Show spinner while redirect will happen or auth is still checking
|
|
74
53
|
if (shouldRedirect || isChecking) {
|
|
75
54
|
return _jsx(Spinner, { overlay: true });
|
|
76
55
|
}
|
|
77
|
-
//
|
|
78
|
-
if (status === FEATURE_STATUS.INITIALIZING && slowWarning) {
|
|
79
|
-
return (_jsx(Stack, { align: "center", justify: "center", style: { padding: 'var(--gap-md)', minHeight: '100vh' }, children: _jsxs("div", { className: "dndev-w-full", style: { maxWidth: '28rem', textAlign: 'center' }, children: [_jsx("h2", { style: { marginBottom: 'var(--gap-md)' }, children: "Loading is taking longer than usual" }), _jsx("p", { style: {
|
|
80
|
-
marginBottom: 'var(--gap-md)',
|
|
81
|
-
color: 'var(--muted-foreground)',
|
|
82
|
-
}, children: "This might be due to a slow connection. Please wait or try refreshing the page." }), _jsx("button", { onClick: () => window.location.reload(), style: {
|
|
83
|
-
padding: 'var(--gap-sm) var(--gap-md)',
|
|
84
|
-
backgroundColor: 'var(--primary)',
|
|
85
|
-
color: 'var(--primary-foreground)',
|
|
86
|
-
border: 'none',
|
|
87
|
-
borderRadius: 'var(--radius)',
|
|
88
|
-
cursor: 'pointer',
|
|
89
|
-
}, children: "Refresh Page" })] }) }));
|
|
90
|
-
}
|
|
91
|
-
// Still checking auth state (but not redirecting) - show fallback
|
|
56
|
+
// Still initializing auth - show fallback spinner
|
|
92
57
|
if (status === FEATURE_STATUS.INITIALIZING) {
|
|
93
58
|
return _jsx(Fallback, {});
|
|
94
59
|
}
|
|
95
|
-
// Check if it's a consent issue (no functional cookies for auth)
|
|
96
|
-
// This is a special case where we don't redirect, but show consent UI
|
|
97
|
-
if (auth &&
|
|
98
|
-
typeof auth === 'object' &&
|
|
99
|
-
auth.required &&
|
|
100
|
-
!user &&
|
|
101
|
-
can &&
|
|
102
|
-
!can.navigate(auth)) {
|
|
103
|
-
return (_jsx(Stack, { align: "center", justify: "center", style: { padding: 'var(--gap-md)', minHeight: '100vh' }, children: _jsxs("div", { className: "dndev-w-full", style: { maxWidth: '28rem' }, children: [_jsx("h2", { style: { marginBottom: 'var(--gap-md)' }, children: "Authentication Required" }), _jsx("p", { style: { marginBottom: 'var(--gap-md)' }, children: "This page requires authentication. Please accept functional cookies to continue." }), _jsx(Suspense, { fallback: _jsx("div", { children: "Loading consent..." }), children: _jsx(CookieConsent, {}) })] }) }));
|
|
104
|
-
}
|
|
105
60
|
// All checks passed, render children
|
|
106
61
|
return _jsx(_Fragment, { children: children });
|
|
107
62
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthReturnTo - Restores navigation after OAuth redirect.
|
|
3
|
+
*
|
|
4
|
+
* OAuth always lands on `/` (origin). This component watches for sign-in,
|
|
5
|
+
* reads the saved returnTo path, and navigates back. Runs once per sign-in.
|
|
6
|
+
*
|
|
7
|
+
* Also shows a warning toast when the user was redirected by the auth guard
|
|
8
|
+
* (flag set by useNavigate, consumed here on mount of the landing page).
|
|
9
|
+
*
|
|
10
|
+
* @component
|
|
11
|
+
*/
|
|
12
|
+
export declare function AuthReturnTo(): null;
|
|
13
|
+
//# sourceMappingURL=AuthReturnTo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthReturnTo.d.ts","sourceRoot":"","sources":["../../src/routing/AuthReturnTo.tsx"],"names":[],"mappings":"AA0BA;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,SA2B3B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// packages/ui/src/routing/AuthReturnTo.tsx
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Auth Return-To Navigation + Guard Toast
|
|
5
|
+
* @description Consumes `dndev.auth.returnTo` from sessionStorage after OAuth
|
|
6
|
+
* redirect and navigates back to the pre-auth path.
|
|
7
|
+
* Also consumes `dndev.auth.guardToast` flag to show a toast when
|
|
8
|
+
* useNavigate blocked a SPA nav to a protected route.
|
|
9
|
+
*
|
|
10
|
+
* Mount once at layout/provider level (RootLayout). Renders nothing.
|
|
11
|
+
* Works on all routes - unlike AuthGuard which only runs on guarded pages.
|
|
12
|
+
*
|
|
13
|
+
* @version 0.1.0
|
|
14
|
+
* @since 0.6.0
|
|
15
|
+
* @author AMBROISE PARK Consulting
|
|
16
|
+
*/
|
|
17
|
+
import { useEffect } from 'react';
|
|
18
|
+
import { useToast } from '@donotdev/components';
|
|
19
|
+
import { isClient, safeSessionStorage, useTranslation } from '@donotdev/core';
|
|
20
|
+
import { useAuthSafe } from '../utils/useAuthSafe';
|
|
21
|
+
import { useNavigate } from '@donotdev/ui/routing/hooks';
|
|
22
|
+
/**
|
|
23
|
+
* AuthReturnTo - Restores navigation after OAuth redirect.
|
|
24
|
+
*
|
|
25
|
+
* OAuth always lands on `/` (origin). This component watches for sign-in,
|
|
26
|
+
* reads the saved returnTo path, and navigates back. Runs once per sign-in.
|
|
27
|
+
*
|
|
28
|
+
* Also shows a warning toast when the user was redirected by the auth guard
|
|
29
|
+
* (flag set by useNavigate, consumed here on mount of the landing page).
|
|
30
|
+
*
|
|
31
|
+
* @component
|
|
32
|
+
*/
|
|
33
|
+
export function AuthReturnTo() {
|
|
34
|
+
const user = useAuthSafe('user');
|
|
35
|
+
const navigate = useNavigate();
|
|
36
|
+
const { t } = useTranslation('dndev');
|
|
37
|
+
const { toast } = useToast();
|
|
38
|
+
// Show guard toast on landing page after auth redirect
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!isClient())
|
|
41
|
+
return;
|
|
42
|
+
const flag = safeSessionStorage.getItem('dndev.auth.guardToast');
|
|
43
|
+
if (!flag)
|
|
44
|
+
return;
|
|
45
|
+
safeSessionStorage.removeItem('dndev.auth.guardToast');
|
|
46
|
+
toast('warning', t('guard.signInRequired', 'Please sign in to access this page'));
|
|
47
|
+
}, []);
|
|
48
|
+
// Return-to after sign-in
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!user || !isClient())
|
|
51
|
+
return;
|
|
52
|
+
const returnTo = safeSessionStorage.getItem('dndev.auth.returnTo');
|
|
53
|
+
if (!returnTo)
|
|
54
|
+
return;
|
|
55
|
+
safeSessionStorage.removeItem('dndev.auth.returnTo');
|
|
56
|
+
if (returnTo !== window.location.pathname) {
|
|
57
|
+
navigate(returnTo, { replace: true });
|
|
58
|
+
}
|
|
59
|
+
}, [user, navigate]);
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ComponentType } from 'react';
|
|
2
2
|
import { DISPLAY } from '@donotdev/components';
|
|
3
3
|
import type { NavigationItem } from './useNavigation';
|
|
4
|
+
/** Props for the DnDevNavigationMenu component. */
|
|
4
5
|
export interface DnDevNavigationMenuProps {
|
|
5
6
|
/** Routes to display (optional - auto-fetches if not provided) */
|
|
6
7
|
routes?: NavigationItem[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DnDevNavigationMenu.d.ts","sourceRoot":"","sources":["../../src/routing/DnDevNavigationMenu.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AAEf,OAAO,EAOL,OAAO,EACR,MAAM,sBAAsB,CAAC;AAW9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,WAAW,wBAAwB;IACvC,kEAAkE;IAClE,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1B,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IACjD,mEAAmE;IACnE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,4BAA4B;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,wBAAwB,CA8KvE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"DnDevNavigationMenu.d.ts","sourceRoot":"","sources":["../../src/routing/DnDevNavigationMenu.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AAEf,OAAO,EAOL,OAAO,EACR,MAAM,sBAAsB,CAAC;AAW9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,mDAAmD;AACnD,MAAM,WAAW,wBAAwB;IACvC,kEAAkE;IAClE,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1B,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IACjD,mEAAmE;IACnE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,4BAA4B;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,wBAAwB,CA8KvE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
package/dist/routing/GoTo.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoTo.d.ts","sourceRoot":"","sources":["../../src/routing/GoTo.tsx"],"names":[],"mappings":"AAaA,OAAO,EAA0B,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGvE,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IACjD,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,iCAIlB,SAAS,4CA0CX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
1
|
+
{"version":3,"file":"GoTo.d.ts","sourceRoot":"","sources":["../../src/routing/GoTo.tsx"],"names":[],"mappings":"AAaA,OAAO,EAA0B,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGvE,kDAAkD;AAClD,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IACjD,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,iCAIlB,SAAS,4CA0CX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useRouter as
|
|
1
|
+
"use client";import{useRouter as p}from"next/navigation";import{isClient as b,useOverlayStore as k,useAuthConfig as N,FEATURE_STATUS as w,getRoutes as C,safeSessionStorage as y}from"@donotdev/core";import*as S from"@donotdev/auth";import{DEGRADED_AUTH_API as T}from"@donotdev/core";var x=S?.useAuth;function v(e){return T[e]}function m(e){return x?x(e):v(e)}var W=S?.PasswordResetCallback??(()=>null);function G(e){try{let t=C();if(!t?.length)return!1;let r=t.find(n=>n.path===e||e.startsWith(n.path+"/"));return r?!!(r.auth===!0||typeof r.auth=="object"&&r.auth?.required):!1}catch{return!1}}function d(){let e=p(),t=k(s=>s.closeAll),r=m("user"),n=m("status"),u=N();return(s,o)=>{if(s==="back")return t(),e.back();if(!r&&n!==w.INITIALIZING&&G(s))return y.setItem("dndev.auth.returnTo",s),y.setItem("dndev.auth.guardToast","1"),t(),e.replace(u.authRoute);if(t(),o?.preserveScroll&&b()){let a=window.scrollY;o?.replace?e.replace(s):e.push(s),requestAnimationFrame(()=>{window.scrollTo({top:a,behavior:"auto"})});return}return o?.replace?e.replace(s):e.push(s)}}function $(){let e=p();return()=>e.back()}function U(){let e=p();return()=>e.refresh()}function K(){let e=p();return t=>e.prefetch(t)}import{usePathname as E,useSearchParams as L}from"next/navigation";function l(){let e=E(),r=L().toString(),n=r?`?${r}`:void 0;return{pathname:e||"/",search:n,hash:"",state:null}}import{useParams as O}from"next/navigation";function g(){let e=O();return e||{}}function q(e){let r=g()[e];if(typeof r=="string")return r;if(Array.isArray(r)&&r.length>0)return r[0]}import{useSearchParams as F}from"next/navigation";function R(){return F()}import{usePathname as Q}from"next/navigation";function j(e){let t=Q(),r=e.replace(/:[^/]+/g,"([^/]+)").replace(/\*/g,".*"),n=new RegExp(`^${r}$`),u=t.match(n);if(!u)return null;let s=e.match(/:[^/]+/g)?.map(a=>a.slice(1))||[],o={};return s.forEach((a,i)=>{o[a]=u[i+1]||""}),{params:o,pathname:t,pattern:e}}import{useCallback as A}from"react";function M(){let e=R(),t=d(),r=l(),n=A((o,a)=>{let i=new URLSearchParams(e.toString());i.set(o,a);let h=i.toString(),c=`${r.pathname||"/"}${h?`?${h}`:""}`;t(c)},[e,t,r.pathname]),u=A(o=>{let a=new URLSearchParams(e.toString());a.delete(o);let i=a.toString(),f=`${r.pathname||"/"}${i?`?${i}`:""}`;t(f)},[e,t,r.pathname]),s=A(()=>{let o=r.pathname||"/";t(o)},[t,r.pathname]);return{query:e,setQuery:n,removeQuery:u,clearQueries:s}}import{useMemo as _}from"react";import{isClient as D,FEATURE_STATUS as B}from"@donotdev/core";import{useAuthConfig as Y}from"@donotdev/core";function Z(e={}){let{auth:t,redirectTo:r,condition:n}=e,u=l(),s=Y(),o=m("user"),a=m("can"),i=m("status");return _(()=>{let f={shouldRedirect:!1,redirectTo:null,isChecking:!1};if(!D())return f;if(i===B.INITIALIZING)return{...f,isChecking:!0};if(n){let c=n(o,i);return{shouldRedirect:c,redirectTo:c&&r||null,isChecking:!1}}if(t!==!1&&t!==void 0){if(!a)return f;if(!a.navigate(t)){let c=null;if(typeof t=="object"&&t.required&&!o){let I=u.search?.includes("code=")||u.search?.includes("state=")||u.search?.includes("error="),P=s.authRoute;I?c=`${P}${u.search}`:c=P}else typeof t=="object"&&t.role?c=s.roleRoute:typeof t=="object"&&t.tier?c=s.tierRoute:c=s.roleRoute;return{shouldRedirect:!0,redirectTo:r||c,isChecking:!1}}}return f},[t,i,o,a,n,r,u.search,s.authRoute,s.roleRoute,s.tierRoute])}export{$ as useBack,l as useLocation,j as useMatch,d as useNavigate,g as useParams,K as usePrefetch,M as useQueryParams,Z as useRedirectGuard,U as useRefresh,q as useRouteParam,R as useSearchParams};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{useNavigate as y}from"react-router-dom";import{isClient as b,useOverlayStore as k,useAuthConfig as C,FEATURE_STATUS as G,getRoutes as N,safeSessionStorage as S}from"@donotdev/core";import*as x from"@donotdev/auth";import{DEGRADED_AUTH_API as I}from"@donotdev/core";var P=x?.useAuth;function T(e){return I[e]}function m(e){return P?P(e):T(e)}var W=x?.PasswordResetCallback??(()=>null);function w(e){try{let t=N();if(!t?.length)return!1;let r=t.find(n=>n.path===e||e.startsWith(n.path+"/"));return r?!!(r.auth===!0||typeof r.auth=="object"&&r.auth?.required):!1}catch{return!1}}function p(){let e=y(),t=k(o=>o.closeAll),r=m("user"),n=m("status"),a=C();return(o,s)=>o==="back"?(t(),e(-1)):!r&&n!==G.INITIALIZING&&w(o)?(S.setItem("dndev.auth.returnTo",o),S.setItem("dndev.auth.guardToast","1"),t(),e(a.authRoute,{replace:!0})):(t(),s?.replace?e(o,{replace:!0}):e(o))}function L(){let e=y();return()=>e(-1)}function U(){return()=>{b()&&window.location.reload()}}function K(){return e=>{}}import{useLocation as O}from"react-router-dom";function l(){return O()}import{useParams as $}from"react-router-dom";function d(){return $()}function E(e){let r=d()[e];if(typeof r=="string")return r;if(Array.isArray(r)&&r.length>0)return r[0]}import{useSearchParams as M}from"react-router-dom";function g(){return M()[0]}import{useMatch as Q}from"react-router-dom";function _(e){return Q(e)}import{useCallback as R}from"react";function j(){let e=g(),t=p(),r=l(),n=R((s,c)=>{let i=new URLSearchParams(e.toString());i.set(s,c);let h=i.toString(),u=`${r.pathname||"/"}${h?`?${h}`:""}`;t(u)},[e,t,r.pathname]),a=R(s=>{let c=new URLSearchParams(e.toString());c.delete(s);let i=c.toString(),f=`${r.pathname||"/"}${i?`?${i}`:""}`;t(f)},[e,t,r.pathname]),o=R(()=>{let s=r.pathname||"/";t(s)},[t,r.pathname]);return{query:e,setQuery:n,removeQuery:a,clearQueries:o}}import{useMemo as q}from"react";import{isClient as F,FEATURE_STATUS as D}from"@donotdev/core";import{useAuthConfig as B}from"@donotdev/core";function Z(e={}){let{auth:t,redirectTo:r,condition:n}=e,a=l(),o=B(),s=m("user"),c=m("can"),i=m("status");return q(()=>{let f={shouldRedirect:!1,redirectTo:null,isChecking:!1};if(!F())return f;if(i===D.INITIALIZING)return{...f,isChecking:!0};if(n){let u=n(s,i);return{shouldRedirect:u,redirectTo:u&&r||null,isChecking:!1}}if(t!==!1&&t!==void 0){if(!c)return f;if(!c.navigate(t)){let u=null;if(typeof t=="object"&&t.required&&!s){let v=a.search.includes("code=")||a.search.includes("state=")||a.search.includes("error="),A=o.authRoute;v?u=`${A}${a.search}`:u=A}else typeof t=="object"&&t.role?u=o.roleRoute:typeof t=="object"&&t.tier?u=o.tierRoute:u=o.roleRoute;return{shouldRedirect:!0,redirectTo:r||u,isChecking:!1}}}return f},[t,i,s,c,n,r,a.search,o.authRoute,o.roleRoute,o.tierRoute])}export{L as useBack,l as useLocation,_ as useMatch,p as useNavigate,d as useParams,K as usePrefetch,j as useQueryParams,Z as useRedirectGuard,U as useRefresh,E as useRouteParam,g as useSearchParams};
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { NavigateOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Navigation hook with auth interception.
|
|
4
|
+
*
|
|
5
|
+
* @grill-refuted Returns a new function ref each render (no useCallback). Safe because
|
|
6
|
+
* AuthGuard's useEffect that depends on navigate is guarded by `shouldRedirect && redirectTo` -
|
|
7
|
+
* the effect body is a no-op when not redirecting, and after redirect the component unmounts.
|
|
8
|
+
* React 19 - no useCallback unless profiler proves bottleneck.
|
|
9
|
+
*/
|
|
2
10
|
export declare function useNavigate(): (to: string, options?: NavigateOptions) => void;
|
|
3
11
|
export declare function useBack(): () => void;
|
|
4
12
|
export declare function useRefresh(): () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigate.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useNavigate.next.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNavigate.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useNavigate.next.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA8B/C;;;;;;;GAOG;AACH,wBAAgB,WAAW,KAOjB,IAAI,MAAM,EAAE,UAAU,eAAe,UAkC9C;AAED,wBAAgB,OAAO,eAGtB;AAED,wBAAgB,UAAU,eAGzB;AAED,wBAAgB,WAAW,KAEjB,IAAI,MAAM,UACnB"}
|