@donotdev/ui 0.0.2 → 0.0.3
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/AuthMenu.d.ts.map +1 -1
- package/dist/components/auth/AuthMenu.js +15 -28
- package/dist/components/common/FeatureCard.js +1 -1
- package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
- package/dist/components/cookie-consent/CookieConsent.js +2 -41
- package/dist/components/cookie-consent/index.d.ts +0 -1
- package/dist/components/cookie-consent/index.d.ts.map +1 -1
- package/dist/components/cookie-consent/index.js +1 -1
- package/dist/components/layout/components/DropdownNavigation.d.ts.map +1 -1
- package/dist/components/layout/components/header/ThemeToggle.d.ts +1 -1
- package/dist/components/layout/components/header/ThemeToggle.d.ts.map +1 -1
- package/dist/components/layout/components/header/ThemeToggle.js +5 -4
- package/dist/dndev.css +137 -120
- package/dist/index.js +4 -4
- package/dist/internal/devtools/DebugTools.d.ts.map +1 -1
- package/dist/internal/devtools/DebugTools.js +8 -4
- package/dist/internal/devtools/components/ConfigTab.d.ts.map +1 -1
- package/dist/internal/devtools/components/ConfigTab.js +31 -133
- package/dist/internal/devtools/components/DebugDialog.d.ts.map +1 -1
- package/dist/internal/devtools/components/DebugDialog.js +11 -520
- package/dist/internal/devtools/components/DesignTab.d.ts +2 -0
- package/dist/internal/devtools/components/DesignTab.d.ts.map +1 -0
- package/dist/internal/devtools/components/DesignTab.js +220 -0
- package/dist/internal/devtools/components/StoresTab.d.ts.map +1 -1
- package/dist/internal/devtools/components/StoresTab.js +54 -102
- package/dist/internal/devtools/components/index.d.ts +1 -6
- package/dist/internal/devtools/components/index.d.ts.map +1 -1
- package/dist/internal/devtools/components/index.js +1 -6
- package/dist/internal/devtools/utils/index.d.ts +0 -1
- package/dist/internal/devtools/utils/index.d.ts.map +1 -1
- package/dist/internal/devtools/utils/index.js +0 -1
- package/dist/internal/initializers/BaseStoresInitializer.d.ts.map +1 -1
- package/dist/internal/initializers/BaseStoresInitializer.js +25 -58
- package/dist/internal/layout/DnDevLayout.js +3 -3
- package/dist/internal/layout/components/footer/FooterBranding.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterBranding.js +3 -1
- package/dist/routing/AuthGuard.d.ts +14 -10
- package/dist/routing/AuthGuard.d.ts.map +1 -1
- package/dist/routing/AuthGuard.js +25 -22
- package/dist/routing/Link.d.ts +2 -2
- package/dist/routing/Link.js +2 -2
- package/dist/routing/hooks/hooks.next.js +1 -1
- package/dist/routing/hooks/hooks.vite.js +1 -1
- package/dist/routing/hooks/useRedirectGuard.next.d.ts +2 -36
- package/dist/routing/hooks/useRedirectGuard.next.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.next.js +14 -55
- package/dist/routing/hooks/useRedirectGuard.vite.d.ts +2 -36
- package/dist/routing/hooks/useRedirectGuard.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.vite.js +14 -55
- package/dist/routing/index.d.ts +0 -1
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +1 -1
- package/dist/styles/index.css +137 -120
- package/dist/utils/assetResolver.d.ts +5 -5
- package/dist/utils/assetResolver.js +4 -4
- package/dist/utils/useAuthSafe.d.ts +25 -12
- package/dist/utils/useAuthSafe.d.ts.map +1 -1
- package/dist/utils/useAuthSafe.js +3 -1
- package/dist/utils/useAuthVisibility.d.ts +3 -3
- package/dist/utils/useAuthVisibility.d.ts.map +1 -1
- package/dist/utils/useAuthVisibility.js +25 -21
- package/dist/utils/useBillingVisibility.d.ts +2 -2
- package/dist/utils/useBillingVisibility.d.ts.map +1 -1
- package/dist/utils/useBillingVisibility.js +12 -13
- package/dist/utils/useCrudSafe.d.ts +1 -1
- package/dist/utils/useCrudSafe.d.ts.map +1 -1
- package/dist/utils/useCrudSafe.js +26 -13
- package/dist/utils/useOAuthSafe.d.ts +25 -12
- package/dist/utils/useOAuthSafe.d.ts.map +1 -1
- package/dist/utils/useStripeBillingSafe.d.ts +30 -18
- package/dist/utils/useStripeBillingSafe.d.ts.map +1 -1
- package/dist/utils/useStripeBillingSafe.js +5 -6
- package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
- package/dist/vite-routing/AppRoutes.js +5 -5
- package/dist/vite-routing/RootLayout.d.ts.map +1 -1
- package/dist/vite-routing/RootLayout.js +34 -7
- package/package.json +9 -9
- package/dist/internal/devtools/components/AuthTab.d.ts +0 -2
- package/dist/internal/devtools/components/AuthTab.d.ts.map +0 -1
- package/dist/internal/devtools/components/AuthTab.js +0 -98
- package/dist/internal/devtools/components/ColorRatioTab.d.ts +0 -2
- package/dist/internal/devtools/components/ColorRatioTab.d.ts.map +0 -1
- package/dist/internal/devtools/components/ColorRatioTab.js +0 -322
- package/dist/internal/devtools/components/DebugToggle.d.ts +0 -2
- package/dist/internal/devtools/components/DebugToggle.d.ts.map +0 -1
- package/dist/internal/devtools/components/DebugToggle.js +0 -57
- package/dist/internal/devtools/components/EnvironmentTab.d.ts +0 -2
- package/dist/internal/devtools/components/EnvironmentTab.d.ts.map +0 -1
- package/dist/internal/devtools/components/EnvironmentTab.js +0 -26
- package/dist/internal/devtools/components/I18nTab.d.ts +0 -2
- package/dist/internal/devtools/components/I18nTab.d.ts.map +0 -1
- package/dist/internal/devtools/components/I18nTab.js +0 -76
- package/dist/internal/devtools/components/OAuthGuideButton.d.ts +0 -10
- package/dist/internal/devtools/components/OAuthGuideButton.d.ts.map +0 -1
- package/dist/internal/devtools/components/OAuthGuideButton.js +0 -71
- package/dist/internal/devtools/components/StripeDebugTab.d.ts +0 -2
- package/dist/internal/devtools/components/StripeDebugTab.d.ts.map +0 -1
- package/dist/internal/devtools/components/StripeDebugTab.js +0 -175
- package/dist/internal/devtools/components/ThemesTab.d.ts +0 -2
- package/dist/internal/devtools/components/ThemesTab.d.ts.map +0 -1
- package/dist/internal/devtools/components/ThemesTab.js +0 -77
- package/dist/internal/devtools/utils/spacingAnalyzer.d.ts +0 -15
- package/dist/internal/devtools/utils/spacingAnalyzer.d.ts.map +0 -1
- package/dist/internal/devtools/utils/spacingAnalyzer.js +0 -88
|
@@ -1,67 +1,26 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
// packages/ui/src/routing/hooks/useRedirectGuard.vite.ts
|
|
3
3
|
/**
|
|
4
|
-
|
|
5
|
-
* @
|
|
6
|
-
|
|
7
|
-
* @description Checks if redirect should happen before render, preventing content flash
|
|
8
|
-
|
|
4
|
+
* @fileoverview Vite Redirect Guard Hook
|
|
5
|
+
* @description Determines redirect state before render. Prevents content flash.
|
|
9
6
|
*
|
|
10
|
-
|
|
11
|
-
* @version 0.0.1
|
|
12
|
-
|
|
7
|
+
* @version 0.0.3
|
|
13
8
|
* @since 0.0.1
|
|
14
|
-
|
|
15
9
|
* @author AMBROISE PARK Consulting
|
|
16
|
-
|
|
17
10
|
*/
|
|
18
11
|
import { useMemo } from 'react';
|
|
19
|
-
import { isClient } from '@donotdev/core';
|
|
12
|
+
import { isClient, FEATURE_STATUS } from '@donotdev/core';
|
|
20
13
|
import { useAuthConfig } from '@donotdev/core';
|
|
21
14
|
import { useLocation } from './useLocation.vite';
|
|
22
15
|
import { useAuthSafe } from '../../utils/useAuthSafe';
|
|
23
16
|
/**
|
|
24
|
-
|
|
25
17
|
* Hook that checks if redirect should happen before render
|
|
26
|
-
|
|
27
18
|
*
|
|
28
|
-
|
|
29
19
|
* Prevents content flash by determining redirect state synchronously.
|
|
30
|
-
|
|
31
20
|
* Returns safe defaults on server (SSR-safe).
|
|
32
|
-
|
|
33
21
|
*
|
|
34
|
-
|
|
35
22
|
* @param options - Redirect guard configuration
|
|
36
|
-
|
|
37
23
|
* @returns Redirect guard state
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
|
|
41
|
-
* @example
|
|
42
|
-
|
|
43
|
-
* ```tsx
|
|
44
|
-
|
|
45
|
-
* // PricingPage: redirect authenticated users to /purchase
|
|
46
|
-
|
|
47
|
-
* const { shouldRedirect, redirectTo, isChecking } = useRedirectGuard({
|
|
48
|
-
|
|
49
|
-
* condition: (user) => !!user,
|
|
50
|
-
|
|
51
|
-
* redirectTo: '/purchase'
|
|
52
|
-
|
|
53
|
-
* });
|
|
54
|
-
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
* if (shouldRedirect || isChecking) {
|
|
58
|
-
|
|
59
|
-
* return <Loader />;
|
|
60
|
-
|
|
61
|
-
* }
|
|
62
|
-
|
|
63
|
-
* ```
|
|
64
|
-
|
|
65
24
|
*/
|
|
66
25
|
export function useRedirectGuard(options = {}) {
|
|
67
26
|
const { auth, redirectTo: customRedirectTo, condition } = options;
|
|
@@ -76,12 +35,12 @@ export function useRedirectGuard(options = {}) {
|
|
|
76
35
|
const location = useLocation();
|
|
77
36
|
const authConfig = useAuthConfig();
|
|
78
37
|
const user = useAuthSafe('user');
|
|
79
|
-
const
|
|
80
|
-
const
|
|
38
|
+
const can = useAuthSafe('can');
|
|
39
|
+
const status = useAuthSafe('status');
|
|
81
40
|
// Determine redirect state
|
|
82
41
|
const redirectState = useMemo(() => {
|
|
83
|
-
//
|
|
84
|
-
if (
|
|
42
|
+
// Only INITIALIZING = still checking. DEGRADED/ERROR/READY = auth resolved (proceed with current user)
|
|
43
|
+
if (status === FEATURE_STATUS.INITIALIZING) {
|
|
85
44
|
return {
|
|
86
45
|
shouldRedirect: false,
|
|
87
46
|
redirectTo: null,
|
|
@@ -90,7 +49,7 @@ export function useRedirectGuard(options = {}) {
|
|
|
90
49
|
}
|
|
91
50
|
// Custom condition provided
|
|
92
51
|
if (condition) {
|
|
93
|
-
const shouldRedirect = condition(user,
|
|
52
|
+
const shouldRedirect = condition(user, status);
|
|
94
53
|
return {
|
|
95
54
|
shouldRedirect,
|
|
96
55
|
redirectTo: shouldRedirect ? customRedirectTo || null : null,
|
|
@@ -99,15 +58,15 @@ export function useRedirectGuard(options = {}) {
|
|
|
99
58
|
}
|
|
100
59
|
// Use auth config to determine redirect
|
|
101
60
|
if (auth !== false && auth !== undefined) {
|
|
102
|
-
if (!
|
|
61
|
+
if (!can) {
|
|
103
62
|
return {
|
|
104
63
|
shouldRedirect: false,
|
|
105
64
|
redirectTo: null,
|
|
106
65
|
isChecking: false,
|
|
107
66
|
};
|
|
108
67
|
}
|
|
109
|
-
// Check if user can
|
|
110
|
-
if (!
|
|
68
|
+
// Check if user can navigate to this route
|
|
69
|
+
if (!can.navigate(auth)) {
|
|
111
70
|
let targetRoute = null;
|
|
112
71
|
// Authentication failure (not logged in)
|
|
113
72
|
if (typeof auth === 'object' && auth.required && !user) {
|
|
@@ -149,9 +108,9 @@ export function useRedirectGuard(options = {}) {
|
|
|
149
108
|
};
|
|
150
109
|
}, [
|
|
151
110
|
auth,
|
|
152
|
-
|
|
111
|
+
status,
|
|
153
112
|
user,
|
|
154
|
-
|
|
113
|
+
can,
|
|
155
114
|
condition,
|
|
156
115
|
customRedirectTo,
|
|
157
116
|
location.search,
|
package/dist/routing/index.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ export * from './AuthGuardFallback';
|
|
|
13
13
|
export * from './GoTo';
|
|
14
14
|
export { default as GoToWrapper } from './GoToWrapper';
|
|
15
15
|
export { default as GoToInput } from './GoToInput';
|
|
16
|
-
export { default as GoToDialog } from './GoToDialog';
|
|
17
16
|
export * from './DnDevNavigationMenu';
|
|
18
17
|
export { default as NotFoundPage } from './404';
|
|
19
18
|
export { useNavigate, useBack, useRefresh, usePrefetch, useLocation, useParams, useSearchParams, useMatch, useQueryParams, useRedirectGuard, } from '@donotdev/ui/routing/hooks';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAGH,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAGH,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,OAAO,CAAC;AAOhD,OAAO,EACL,WAAW,EACX,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,eAAe,EACf,QAAQ,EACR,cAAc,EACd,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC"}
|
package/dist/routing/index.js
CHANGED
|
@@ -15,7 +15,7 @@ export * from './AuthGuardFallback';
|
|
|
15
15
|
export * from './GoTo';
|
|
16
16
|
export { default as GoToWrapper } from './GoToWrapper';
|
|
17
17
|
export { default as GoToInput } from './GoToInput';
|
|
18
|
-
|
|
18
|
+
// GoToDialog intentionally NOT exported - lazy loaded by GoToWrapper
|
|
19
19
|
export * from './DnDevNavigationMenu';
|
|
20
20
|
export { default as NotFoundPage } from './404';
|
|
21
21
|
// Hooks - platform-specific via conditional exports
|