@donotdev/ui 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/auth/AuthHeader.js +1 -93
- package/dist/components/auth/AuthMenu.d.ts.map +1 -1
- package/dist/components/auth/AuthMenu.js +3 -286
- package/dist/components/auth/index.js +1 -9
- package/dist/components/common/FeatureCard.d.ts.map +1 -1
- package/dist/components/common/FeatureCard.js +1 -86
- package/dist/components/common/FeatureDisabled.js +1 -67
- package/dist/components/common/IconPlaceholder.d.ts +24 -0
- package/dist/components/common/IconPlaceholder.d.ts.map +1 -0
- package/dist/components/common/IconPlaceholder.js +1 -0
- package/dist/components/common/LazyLucideIcon.d.ts +39 -0
- package/dist/components/common/LazyLucideIcon.d.ts.map +1 -0
- package/dist/components/common/LazyLucideIcon.js +1 -0
- package/dist/components/common/ProgressBar.js +1 -84
- package/dist/components/common/RedirectOverlay.js +1 -243
- package/dist/components/common/Skeleton.js +1 -144
- package/dist/components/common/TechBento.d.ts.map +1 -1
- package/dist/components/common/TechBento.js +1 -53
- package/dist/components/common/icon.d.ts +1 -1
- package/dist/components/common/icon.d.ts.map +1 -1
- package/dist/components/common/icon.js +1 -84
- package/dist/components/common/iconByName.d.ts +33 -0
- package/dist/components/common/iconByName.d.ts.map +1 -0
- package/dist/components/common/iconByName.js +1 -0
- package/dist/components/common/index.js +1 -16
- package/dist/components/cookie-consent/ConsentBanner.d.ts +3 -1
- package/dist/components/cookie-consent/ConsentBanner.d.ts.map +1 -1
- package/dist/components/cookie-consent/ConsentBanner.js +1 -31
- package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
- package/dist/components/cookie-consent/CookieConsent.js +1 -183
- package/dist/components/cookie-consent/index.js +1 -11
- package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts +7 -0
- package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts.map +1 -0
- package/dist/components/cookie-consent/useCookieNoticeRequired.js +1 -0
- package/dist/components/index.js +1 -13
- package/dist/components/layout/GameContainer.d.ts.map +1 -1
- package/dist/components/layout/GameContainer.js +1 -72
- package/dist/components/layout/GameFlow.d.ts.map +1 -1
- package/dist/components/layout/GameFlow.js +1 -93
- package/dist/components/layout/PageConfig.d.ts.map +1 -1
- package/dist/components/layout/PageConfig.js +1 -47
- package/dist/components/layout/PageContainer.d.ts.map +1 -1
- package/dist/components/layout/PageContainer.js +1 -38
- package/dist/components/layout/components/Breadcrumbs.d.ts +2 -1
- package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
- package/dist/components/layout/components/Breadcrumbs.js +1 -89
- package/dist/components/layout/components/DropdownNavigation.d.ts.map +1 -1
- package/dist/components/layout/components/DropdownNavigation.js +1 -30
- package/dist/components/layout/components/FloatingLanguageSwitcher.d.ts.map +1 -1
- package/dist/components/layout/components/FloatingLanguageSwitcher.js +1 -26
- package/dist/components/layout/components/Notifications.js +1 -182
- package/dist/components/layout/components/header/AppBranding.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppBranding.js +1 -54
- package/dist/components/layout/components/header/AppIcon.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppIcon.js +1 -59
- package/dist/components/layout/components/header/AppTitle.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppTitle.js +1 -40
- package/dist/components/layout/components/header/CacheSettings.js +1 -225
- package/dist/components/layout/components/header/GameTitle.d.ts.map +1 -1
- package/dist/components/layout/components/header/GameTitle.js +1 -66
- package/dist/components/layout/components/header/HeaderMenu.d.ts +17 -16
- package/dist/components/layout/components/header/HeaderMenu.d.ts.map +1 -1
- package/dist/components/layout/components/header/HeaderMenu.js +1 -47
- package/dist/components/layout/components/header/HeaderNavigation.d.ts.map +1 -1
- package/dist/components/layout/components/header/HeaderNavigation.js +1 -66
- package/dist/components/layout/components/header/SettingsMenu.d.ts.map +1 -1
- package/dist/components/layout/components/header/SettingsMenu.js +1 -85
- package/dist/components/layout/components/header/ThemeToggle.d.ts.map +1 -1
- package/dist/components/layout/components/header/ThemeToggle.js +1 -93
- package/dist/components/layout/components/index.js +1 -25
- package/dist/components/layout/index.js +1 -14
- package/dist/crud/components/ChildRowsPicker.js +1 -68
- package/dist/crud/components/CrudCardLink.js +1 -14
- package/dist/crud/components/EntityCardList.js +1 -184
- package/dist/crud/components/EntityDisplayRenderer.js +1 -130
- package/dist/crud/components/EntityFormRenderer.js +1 -433
- package/dist/crud/components/EntityList.js +1 -521
- package/dist/crud/components/EntityRecommendations.js +1 -87
- package/dist/crud/components/EntityWorkflow.js +1 -55
- package/dist/crud/components/Form.d.ts.map +1 -1
- package/dist/crud/components/Form.js +1 -198
- package/dist/crud/components/cellEditFor.js +1 -74
- package/dist/crud/components/entityParent.js +1 -76
- package/dist/crud/components/index.js +1 -16
- package/dist/crud/components/useRecordBreadcrumb.d.ts.map +1 -1
- package/dist/crud/components/useRecordBreadcrumb.js +1 -43
- package/dist/crud/crudImports.js +1 -51
- package/dist/crud/index.js +1 -11
- package/dist/data/techLogos.js +1 -99
- package/dist/dndev-next.css +104 -17
- package/dist/dndev.css +104 -17
- package/dist/index.js +1 -5
- package/dist/internal/common/DnDevErrorBoundary.js +1 -55
- package/dist/internal/common/ErrorFallback.js +3 -214
- package/dist/internal/common/GlobalErrorFallback.js +1 -45
- package/dist/internal/common/RouteErrorFallback.js +3 -140
- package/dist/internal/devtools/DebugTools.js +1 -131
- package/dist/internal/devtools/components/AuthDebugButton.js +1 -72
- package/dist/internal/devtools/components/ConfigTab.js +1 -61
- package/dist/internal/devtools/components/CookieTab.js +1 -156
- package/dist/internal/devtools/components/DebugDialog.js +1 -48
- package/dist/internal/devtools/components/DesignTab.js +1 -469
- package/dist/internal/devtools/components/LayoutReset.js +1 -214
- package/dist/internal/devtools/components/MaskedValue.js +1 -39
- package/dist/internal/devtools/components/StoresTab.js +1 -90
- package/dist/internal/devtools/components/index.js +1 -16
- package/dist/internal/devtools/index.js +1 -13
- package/dist/internal/devtools/types.js +0 -2
- package/dist/internal/devtools/utils/envVarDiscovery.js +1 -106
- package/dist/internal/devtools/utils/index.js +1 -12
- package/dist/internal/devtools/utils/maskSensitive.js +1 -59
- package/dist/internal/devtools/utils/virtualModuleInspector.js +1 -309
- package/dist/internal/initializers/BaseStoresInitializer.js +1 -367
- package/dist/internal/initializers/NextJsStoresInitializer.js +1 -78
- package/dist/internal/initializers/ViteStoresInitializer.js +1 -20
- package/dist/internal/initializers/index.js +1 -11
- package/dist/internal/layout/DnDevLayout.js +1 -321
- package/dist/internal/layout/components/AutoMetaTags.d.ts +2 -0
- package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/AutoMetaTags.js +1 -338
- package/dist/internal/layout/components/FaviconHead.js +1 -60
- package/dist/internal/layout/components/FontPreloadLinks.js +1 -31
- package/dist/internal/layout/components/HeadTags.js +1 -20
- package/dist/internal/layout/components/PWAUpdateNotification.js +1 -131
- package/dist/internal/layout/components/footer/FooterBranding.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterBranding.js +1 -35
- package/dist/internal/layout/components/footer/FooterCopyright.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterCopyright.js +1 -37
- package/dist/internal/layout/components/footer/FooterLegalLinks.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterLegalLinks.js +1 -44
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts +4 -2
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/useLegalLinks.js +1 -21
- package/dist/internal/layout/components/i18nSeoMeta.js +1 -53
- package/dist/internal/layout/components/index.js +1 -13
- package/dist/internal/layout/config/defaults.js +1 -47
- package/dist/internal/layout/config/index.js +1 -11
- package/dist/internal/layout/config/presets/admin.js +1 -35
- package/dist/internal/layout/config/presets/blog.js +1 -31
- package/dist/internal/layout/config/presets/docs.js +1 -51
- package/dist/internal/layout/config/presets/game.js +1 -53
- package/dist/internal/layout/config/presets/index.js +1 -24
- package/dist/internal/layout/config/presets/landing.js +1 -42
- package/dist/internal/layout/config/presets/moolti.js +1 -52
- package/dist/internal/layout/config/presets/plain.js +1 -25
- package/dist/internal/layout/renderers/index.js +0 -10
- package/dist/internal/layout/zones/DnDevFooter.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevFooter.js +1 -67
- package/dist/internal/layout/zones/DnDevHeader.js +1 -41
- package/dist/internal/layout/zones/DnDevMergedBar.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevMergedBar.js +1 -52
- package/dist/internal/layout/zones/DnDevSidebar.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevSidebar.js +1 -181
- package/dist/internal/layout/zones/index.js +1 -14
- package/dist/internal/providers/NavigationProvider.d.ts.map +1 -1
- package/dist/internal/providers/NavigationProvider.js +1 -71
- package/dist/internal/providers/SentryInitializer.d.ts.map +1 -1
- package/dist/internal/providers/SentryInitializer.js +1 -36
- package/dist/internal/providers/UIProviders.js +1 -79
- package/dist/internal/providers/index.js +1 -12
- package/dist/next.js +1 -11
- package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
- package/dist/providers/NextJsAppProviders.js +1 -107
- package/dist/providers/ViteAppProviders.d.ts.map +1 -1
- package/dist/providers/ViteAppProviders.js +1 -117
- package/dist/providers/index.js +1 -11
- package/dist/routing/404.js +1 -108
- package/dist/routing/AuthGuard.js +1 -178
- package/dist/routing/AuthGuardFallback.d.ts.map +1 -1
- package/dist/routing/AuthGuardFallback.js +1 -67
- package/dist/routing/AuthReturnTo.js +1 -68
- package/dist/routing/DnDevNavigationMenu.d.ts.map +1 -1
- package/dist/routing/DnDevNavigationMenu.js +1 -138
- package/dist/routing/GoTo.d.ts.map +1 -1
- package/dist/routing/GoTo.js +1 -38
- package/dist/routing/GoToDialog.d.ts.map +1 -1
- package/dist/routing/GoToDialog.js +1 -97
- package/dist/routing/GoToInput.d.ts.map +1 -1
- package/dist/routing/GoToInput.js +1 -49
- package/dist/routing/GoToWrapper.d.ts.map +1 -1
- package/dist/routing/GoToWrapper.js +1 -59
- package/dist/routing/Link.d.ts +10 -2
- package/dist/routing/Link.d.ts.map +1 -1
- package/dist/routing/Link.js +1 -109
- package/dist/routing/NavigationItem.d.ts.map +1 -1
- package/dist/routing/NavigationItem.js +1 -44
- package/dist/routing/NotFoundDocument.d.ts +33 -0
- package/dist/routing/NotFoundDocument.d.ts.map +1 -0
- package/dist/routing/NotFoundDocument.js +1 -0
- package/dist/routing/SignedInRedirect.js +1 -47
- package/dist/routing/hooks/hooks.vite.js +1 -1
- package/dist/routing/hooks/index.js +1 -26
- package/dist/routing/hooks/types.js +0 -2
- package/dist/routing/hooks/useLocation.next.js +1 -35
- package/dist/routing/hooks/useLocation.vite.js +1 -13
- package/dist/routing/hooks/useMatch.next.js +1 -31
- package/dist/routing/hooks/useMatch.vite.js +1 -6
- package/dist/routing/hooks/useNavigate.next.js +1 -64
- package/dist/routing/hooks/useNavigate.vite.js +1 -61
- package/dist/routing/hooks/useParams.next.js +1 -9
- package/dist/routing/hooks/useParams.vite.js +1 -6
- package/dist/routing/hooks/useQueryParams.next.js +1 -66
- package/dist/routing/hooks/useQueryParams.vite.js +1 -66
- package/dist/routing/hooks/useRedirectGuard.next.js +1 -119
- package/dist/routing/hooks/useRedirectGuard.vite.js +1 -117
- package/dist/routing/hooks/useRouteParam.next.js +1 -38
- package/dist/routing/hooks/useRouteParam.vite.js +1 -38
- package/dist/routing/hooks/useRoutePath.next.js +1 -36
- package/dist/routing/hooks/useRoutePath.vite.js +1 -25
- package/dist/routing/hooks/useSearchParams.next.js +1 -22
- package/dist/routing/hooks/useSearchParams.vite.js +1 -22
- package/dist/routing/hooks/useUrlLanguage.next.js +1 -50
- package/dist/routing/hooks/useUrlLanguage.vite.js +1 -41
- package/dist/routing/index.d.ts +1 -0
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +1 -32
- package/dist/routing/link/InternalLink.next.d.ts +23 -0
- package/dist/routing/link/InternalLink.next.d.ts.map +1 -0
- package/dist/routing/link/InternalLink.next.js +1 -0
- package/dist/routing/link/InternalLink.vite.d.ts +22 -0
- package/dist/routing/link/InternalLink.vite.d.ts.map +1 -0
- package/dist/routing/link/InternalLink.vite.js +1 -0
- package/dist/routing/link/absolutePath.d.ts +17 -0
- package/dist/routing/link/absolutePath.d.ts.map +1 -0
- package/dist/routing/link/absolutePath.js +1 -0
- package/dist/routing/link/link.next.d.ts +12 -0
- package/dist/routing/link/link.next.d.ts.map +1 -0
- package/dist/routing/link/link.next.js +1 -0
- package/dist/routing/link/link.vite.d.ts +12 -0
- package/dist/routing/link/link.vite.d.ts.map +1 -0
- package/dist/routing/link/link.vite.js +1 -0
- package/dist/routing/link/types.d.ts +30 -0
- package/dist/routing/link/types.d.ts.map +1 -0
- package/dist/routing/link/types.js +0 -0
- package/dist/routing/parentRoute.js +1 -43
- package/dist/routing/useGoTo.d.ts.map +1 -1
- package/dist/routing/useGoTo.js +1 -59
- package/dist/routing/useNavigation.d.ts.map +1 -1
- package/dist/routing/useNavigation.js +1 -114
- package/dist/routing/useRouteDiscovery.d.ts +1 -0
- package/dist/routing/useRouteDiscovery.d.ts.map +1 -1
- package/dist/routing/useRouteDiscovery.js +1 -313
- package/dist/rsc.d.ts +28 -0
- package/dist/rsc.d.ts.map +1 -0
- package/dist/rsc.js +1 -0
- package/dist/styles/index.css +104 -17
- package/dist/styles/index.js +1 -10
- package/dist/styles/layoutConstants.js +1 -134
- package/dist/symbol-index.json +1 -1
- package/dist/utils/assetResolver.d.ts.map +1 -1
- package/dist/utils/assetResolver.js +1 -297
- package/dist/utils/index.js +1 -23
- package/dist/utils/sanitizeSvg.js +1 -51
- package/dist/utils/tList.js +1 -42
- package/dist/utils/useAISafe.d.ts.map +1 -1
- package/dist/utils/useAISafe.js +1 -53
- package/dist/utils/useAuthSafe.d.ts.map +1 -1
- package/dist/utils/useAuthSafe.js +1 -78
- package/dist/utils/useAuthVisibility.d.ts.map +1 -1
- package/dist/utils/useAuthVisibility.js +1 -63
- package/dist/utils/useBillingVisibility.d.ts.map +1 -1
- package/dist/utils/useBillingVisibility.js +1 -57
- package/dist/utils/useCrudSafe.d.ts.map +1 -1
- package/dist/utils/useCrudSafe.js +1 -75
- package/dist/utils/useDeleteAccountSafe.js +1 -52
- package/dist/utils/useFormStoreSafe.d.ts.map +1 -1
- package/dist/utils/useFormStoreSafe.js +1 -85
- package/dist/utils/useOAuthSafe.d.ts.map +1 -1
- package/dist/utils/useOAuthSafe.js +1 -38
- package/dist/utils/useSeo.js +1 -151
- package/dist/utils/useStripeBillingSafe.d.ts.map +1 -1
- package/dist/utils/useStripeBillingSafe.js +1 -81
- package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
- package/dist/vite-routing/AppRoutes.js +1 -235
- package/dist/vite-routing/RootLayout.d.ts.map +1 -1
- package/dist/vite-routing/RootLayout.js +1 -205
- package/dist/vite-routing/index.js +1 -11
- package/dist/vite.js +1 -10
- package/guidelines/COMPONENTS.md +4 -4
- package/guidelines/PAGES.md +3 -0
- package/guidelines/ROUTING.md +15 -0
- package/guidelines/SEO.md +4 -1
- package/package.json +18 -8
- package/dist/ChildRowsPicker-63M4EQUQ.js +0 -1
- package/dist/ChildRowsPicker-ISP365ON.js +0 -1
- package/dist/ChildRowsPicker-PQFE6NCR.js +0 -1
- package/dist/ChildRowsPicker-XXFFSMWY.js +0 -1
- package/dist/CookieConsent-QOUAY6B4.js +0 -1
- package/dist/GoToDialog-KSBGOIWO.js +0 -1
- package/dist/GoToDialog-XBK5EZF4.js +0 -1
- package/dist/chunk-3CIZFGST.js +0 -1
- package/dist/chunk-LHMKU342.js +0 -1
- package/dist/chunk-MS7ZIW5Z.js +0 -1
- package/dist/chunk-O2XFH626.js +0 -1
- package/dist/chunk-P2DHZWPY.js +0 -1
- package/dist/components/common/lucideIconByName.d.ts +0 -9
- package/dist/components/common/lucideIconByName.d.ts.map +0 -1
- package/dist/components/common/lucideIconByName.js +0 -32
- package/dist/internal/layout/components/PerformanceHints.d.ts +0 -71
- package/dist/internal/layout/components/PerformanceHints.d.ts.map +0 -1
- package/dist/internal/layout/components/PerformanceHints.js +0 -71
|
@@ -1,93 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
// packages/ui/src/components/auth/AuthHeader.tsx
|
|
4
|
-
/**
|
|
5
|
-
* @fileoverview Auth Header Component
|
|
6
|
-
* @description Authentication header component for navigation. Provides user authentication status, login/logout buttons, and user menu with lazy-loaded authentication modal.
|
|
7
|
-
*
|
|
8
|
-
* @version 0.1.0
|
|
9
|
-
* @since 0.0.1
|
|
10
|
-
* @author AMBROISE PARK Consulting
|
|
11
|
-
*/
|
|
12
|
-
import { User } from 'lucide-react';
|
|
13
|
-
import React, { Suspense, lazy, useState } from 'react';
|
|
14
|
-
import { Button, BUTTON_VARIANT, DropdownMenu, Dialog, DISPLAY, } from '@donotdev/components';
|
|
15
|
-
import { useTranslation } from '@donotdev/core';
|
|
16
|
-
import { useAuthConfig } from '@donotdev/core';
|
|
17
|
-
import { getEnabledAuthPartners } from '@donotdev/core';
|
|
18
|
-
import { AuthMenu } from './AuthMenu';
|
|
19
|
-
import { Link } from '../../routing';
|
|
20
|
-
import { useAuthSafe, useAuthVisibility } from '../../utils';
|
|
21
|
-
// Lazy load auth components for code splitting; degrade to null if auth pkg missing
|
|
22
|
-
const NullComponent = () => null;
|
|
23
|
-
function SignInButton({ display, variant = BUTTON_VARIANT.OUTLINE, signInLabel, className, style, children, ...props }) {
|
|
24
|
-
return (_jsx(Button, { variant: variant, icon: User, display: display, tooltip: signInLabel, className: className, style: style, ...props, children: children ?? signInLabel }));
|
|
25
|
-
}
|
|
26
|
-
const AuthPartnerButton = lazy(async () => {
|
|
27
|
-
try {
|
|
28
|
-
const module = await import('@donotdev/auth');
|
|
29
|
-
return { default: module.AuthPartnerButton };
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
return { default: NullComponent };
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
const MultipleAuthProviders = lazy(async () => {
|
|
36
|
-
try {
|
|
37
|
-
const module = await import('@donotdev/auth');
|
|
38
|
-
return { default: module.MultipleAuthProviders };
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
return { default: NullComponent };
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
/**
|
|
45
|
-
* Auth header component
|
|
46
|
-
*
|
|
47
|
-
* @version 0.1.0
|
|
48
|
-
* @since 0.0.1
|
|
49
|
-
* @author AMBROISE PARK Consulting
|
|
50
|
-
*/
|
|
51
|
-
export const AuthHeader = ({ display = DISPLAY.AUTO, variant = BUTTON_VARIANT.OUTLINE, className, style, }) => {
|
|
52
|
-
const { t } = useTranslation('dndev');
|
|
53
|
-
const { shouldHide, isLoading, isReady, isAuthenticated } = useAuthVisibility();
|
|
54
|
-
const authConfig = useAuthConfig();
|
|
55
|
-
const enabled = getEnabledAuthPartners();
|
|
56
|
-
const [dialogOpen, setDialogOpen] = useState(false);
|
|
57
|
-
const loginPath = authConfig.loginPath;
|
|
58
|
-
const signInLabel = t('auth.signIn', { defaultValue: 'Sign In' });
|
|
59
|
-
const loadingLabel = t('auth.loading', { defaultValue: 'Loading...' });
|
|
60
|
-
const hasPasswordProvider = enabled.includes('password') || enabled.includes('emailLink');
|
|
61
|
-
if (shouldHide || !isReady) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
// NOT AUTHENTICATED
|
|
65
|
-
// Button's display prop + CSS container queries handle responsive label visibility
|
|
66
|
-
if (!isAuthenticated) {
|
|
67
|
-
if (loginPath !== undefined) {
|
|
68
|
-
return (_jsx(Link, { path: loginPath, prefetch: true, children: _jsx(SignInButton, { display: display, variant: variant, signInLabel: signInLabel, className: className, style: style }) }));
|
|
69
|
-
}
|
|
70
|
-
const targetProvider = enabled[0];
|
|
71
|
-
// Use Dialog if password/emailLink provider is present (better UX for forms)
|
|
72
|
-
if (hasPasswordProvider) {
|
|
73
|
-
return (_jsx(Dialog, { trigger: _jsx(SignInButton, { display: display, signInLabel: signInLabel, className: className, style: style }), title: signInLabel, open: dialogOpen, onOpenChange: setDialogOpen, "data-content-size": "form", children: _jsx(Suspense, { fallback: _jsx("div", { style: {
|
|
74
|
-
padding: 'var(--gap-md)',
|
|
75
|
-
fontSize: 'var(--font-size-sm)',
|
|
76
|
-
color: 'var(--muted-foreground)',
|
|
77
|
-
}, children: loadingLabel }), children: _jsx(MultipleAuthProviders, { spacing: "medium", onSuccess: () => setDialogOpen(false) }) }) }));
|
|
78
|
-
}
|
|
79
|
-
// Use DropdownMenu if multiple OAuth providers (no password/emailLink)
|
|
80
|
-
if (enabled.length > 1) {
|
|
81
|
-
return (_jsx(DropdownMenu, { trigger: _jsx(SignInButton, { display: display, signInLabel: signInLabel, className: className, style: style }), children: _jsx(Suspense, { fallback: _jsx("div", { style: {
|
|
82
|
-
padding: 'var(--gap-md)',
|
|
83
|
-
fontSize: 'var(--font-size-sm)',
|
|
84
|
-
color: 'var(--muted-foreground)',
|
|
85
|
-
}, children: loadingLabel }), children: _jsx(MultipleAuthProviders, { spacing: "tight" }) }) }));
|
|
86
|
-
}
|
|
87
|
-
// Normal case: single non-password provider → use AuthPartnerButton directly
|
|
88
|
-
return (_jsx(Suspense, { fallback: _jsx(SignInButton, { display: display, signInLabel: signInLabel, className: className, style: style, disabled: isLoading, tooltip: isLoading ? loadingLabel : signInLabel, children: isLoading ? loadingLabel : signInLabel }), children: _jsx(AuthPartnerButton, { partnerId: targetProvider, display: display, className: className, style: style }) }));
|
|
89
|
-
}
|
|
90
|
-
// AUTHENTICATED - Delegate to AuthMenu
|
|
91
|
-
return (_jsx(AuthMenu, { display: display, loginPath: loginPath, className: className, style: style }));
|
|
92
|
-
};
|
|
93
|
-
export default AuthHeader;
|
|
1
|
+
"use client";import{User as B}from"lucide-react";import{Suspense as m,lazy as y,useState as N}from"react";import{Button as C,BUTTON_VARIANT as h,DropdownMenu as b,Dialog as O,DISPLAY as k}from"@donotdev/components";import{useTranslation as D}from"@donotdev/core";import{useAuthConfig as R}from"@donotdev/core";import{getEnabledAuthPartners as U}from"@donotdev/core";import{AuthMenu as M}from"./AuthMenu.js";import{Link as V}from"../../routing/index.js";import{useAuthVisibility as w}from"../../utils/index.js";import{jsx as t}from"react/jsx-runtime";var A=()=>null;function u({display:e,variant:l=h.OUTLINE,signInLabel:o,className:n,style:i,children:d,...a}){return t(C,{variant:l,icon:B,display:e,tooltip:o,className:n,style:i,...a,children:d??o})}var z=y(async()=>{try{return{default:(await import("@donotdev/auth")).AuthPartnerButton}}catch{return{default:A}}}),g=y(async()=>{try{return{default:(await import("@donotdev/auth")).MultipleAuthProviders}}catch{return{default:A}}}),Y=({display:e=k.AUTO,variant:l=h.OUTLINE,className:o,style:n})=>{let{t:i}=D("dndev"),{shouldHide:d,isLoading:a,isReady:P,isAuthenticated:I}=w(),S=R(),s=U(),[v,c]=N(!1),f=S.loginPath,r=i("auth.signIn",{defaultValue:"Sign In"}),p=i("auth.loading",{defaultValue:"Loading..."}),T=s.includes("password")||s.includes("emailLink");if(d||!P)return null;if(!I){if(f!==void 0)return t(V,{path:f,prefetch:!0,children:t(u,{display:e,variant:l,signInLabel:r,className:o,style:n})});let L=s[0];return T?t(O,{trigger:t(u,{display:e,signInLabel:r,className:o,style:n}),title:r,open:v,onOpenChange:c,"data-content-size":"form",children:t(m,{fallback:t("div",{style:{padding:"var(--gap-md)",fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:p}),children:t(g,{spacing:"medium",onSuccess:()=>c(!1)})})}):s.length>1?t(b,{trigger:t(u,{display:e,signInLabel:r,className:o,style:n}),children:t(m,{fallback:t("div",{style:{padding:"var(--gap-md)",fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:p}),children:t(g,{spacing:"tight"})})}):t(m,{fallback:t(u,{display:e,signInLabel:r,className:o,style:n,disabled:a,tooltip:a?p:r,children:a?p:r}),children:t(z,{partnerId:L,display:e,className:o,style:n})})}return t(M,{display:e,loginPath:f,className:o,style:n})},X=Y;export{Y as AuthHeader,X as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthMenu.d.ts","sourceRoot":"","sources":["../../../src/components/auth/AuthMenu.tsx"],"names":[],"mappings":"AAyEA,OAAO,KAAkC,MAAM,OAAO,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAML,OAAO,EACR,MAAM,sBAAsB,CAAC;AAwC9B;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IACjC,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IAEjD,sBAAsB;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;OAIG;IACH,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAEnC,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;
|
|
1
|
+
{"version":3,"file":"AuthMenu.d.ts","sourceRoot":"","sources":["../../../src/components/auth/AuthMenu.tsx"],"names":[],"mappings":"AAyEA,OAAO,KAAkC,MAAM,OAAO,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAML,OAAO,EACR,MAAM,sBAAsB,CAAC;AAwC9B;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IACjC,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IAEjD,sBAAsB;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;OAIG;IACH,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAEnC,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAqBD,eAAO,MAAM,QAAQ,GAAI,iFAOtB,aAAa,6BAyOf,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,286 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @fileoverview AuthMenu component for authenticated user menu
|
|
6
|
-
* @description Config-driven authentication menu component that reads from appConfig.auth.
|
|
7
|
-
* Provides user profile display, menu items from config, and mandatory GDPR/UX actions (Sign Out, Delete Account).
|
|
8
|
-
*
|
|
9
|
-
* **Key Features:**
|
|
10
|
-
* - Config-driven: Reads profilePath and authMenuItems from appConfig.auth
|
|
11
|
-
* - Self-aware: Automatically detects authentication status via useAuthVisibility()
|
|
12
|
-
* - User profile header: Avatar, name, email, role, email verification status
|
|
13
|
-
* - Dynamic menu: Profile (if configured) → authMenuItems → customItems → Delete → Sign Out
|
|
14
|
-
* - Custom menu items: Support for paths (auto-Link) or onClick handlers with icons
|
|
15
|
-
* - DISPLAY variants: COMPACT (icon-only), FULL (with label), AUTO (responsive)
|
|
16
|
-
* - Account deletion: Full flow with reauthentication and confirmation dialogs
|
|
17
|
-
* - Graceful degradation: Works without @donotdev/auth package installed
|
|
18
|
-
*
|
|
19
|
-
* **Menu Item Order:**
|
|
20
|
-
* 1. Profile (if appConfig.auth.profilePath configured)
|
|
21
|
-
* 2. Items from appConfig.auth.authMenuItems
|
|
22
|
-
* 3. Custom items from customItems prop
|
|
23
|
-
* 4. Delete Account (always shown - mandatory GDPR/UX)
|
|
24
|
-
* 5. Sign Out (always shown - mandatory GDPR/UX)
|
|
25
|
-
*
|
|
26
|
-
* **Configuration:**
|
|
27
|
-
* Configure menu items in appConfig.auth (route-based only):
|
|
28
|
-
* ```typescript
|
|
29
|
-
* const APP_CONFIG = {
|
|
30
|
-
* auth: {
|
|
31
|
-
* profilePath: '/profile',
|
|
32
|
-
* authMenuItems: [
|
|
33
|
-
* { path: '/dashboard' }, // icon auto-resolved from route
|
|
34
|
-
* { path: '/settings', label: 'Settings' }, // override label, icon from route
|
|
35
|
-
* { path: '/billing', icon: 'CreditCard' } // override icon
|
|
36
|
-
* ]
|
|
37
|
-
* }
|
|
38
|
-
* };
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* **Custom Menu Items:**
|
|
42
|
-
* Add custom items via props for runtime handlers:
|
|
43
|
-
* ```typescript
|
|
44
|
-
* <AuthMenu
|
|
45
|
-
* customItems={[
|
|
46
|
-
* { label: 'Billing', icon: CreditCard, onClick: () => navigate('/billing') },
|
|
47
|
-
* { path: '/settings', label: 'Settings', icon: 'Settings' }
|
|
48
|
-
* ]}
|
|
49
|
-
* />
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* **Icons:**
|
|
53
|
-
* Icons can be Lucide icon name strings (e.g., 'Settings', 'CreditCard') or React components.
|
|
54
|
-
* String names are resolved dynamically from lucide-react.
|
|
55
|
-
*
|
|
56
|
-
* **Authentication States:**
|
|
57
|
-
* - Authenticated: Shows UserCheck icon → dropdown with profile header + menu items
|
|
58
|
-
* - Unauthenticated: Shows sign-in button (if loginPath) or AuthPartnerButton
|
|
59
|
-
* - Loading: Shows loading state during auth operations
|
|
60
|
-
* - Hidden: Returns null if shouldHide or !isReady
|
|
61
|
-
*
|
|
62
|
-
* **Accessibility:**
|
|
63
|
-
* - Proper ARIA labels and roles
|
|
64
|
-
* - Keyboard navigation support
|
|
65
|
-
* - Screen reader friendly
|
|
66
|
-
* - Focus management
|
|
67
|
-
*
|
|
68
|
-
* @version 0.1.0
|
|
69
|
-
* @since 0.0.1
|
|
70
|
-
* @author AMBROISE PARK Consulting
|
|
71
|
-
*/
|
|
72
|
-
import { User, LogOut, Settings, UserCheck, Trash2 } from 'lucide-react';
|
|
73
|
-
import React, { useMemo, lazy, Suspense } from 'react';
|
|
74
|
-
import { Avatar, Button, BUTTON_VARIANT, DropdownMenu, Text, DISPLAY, } from '@donotdev/components';
|
|
75
|
-
import { useTranslation } from '@donotdev/core';
|
|
76
|
-
import { getEnabledAuthPartners, useAuthConfig } from '@donotdev/core';
|
|
77
|
-
import { useBreakpoint } from '@donotdev/core';
|
|
78
|
-
import { useNavigate } from '@donotdev/ui/routing/hooks';
|
|
79
|
-
import { useNavigationItems } from '../../routing';
|
|
80
|
-
import { useAuthSafe, useAuthVisibility } from '../../utils';
|
|
81
|
-
import { useDeleteAccountSafe } from '../../utils/useDeleteAccountSafe';
|
|
82
|
-
import { findLucideIcon } from '../common/lucideIconByName';
|
|
83
|
-
const NullComponent = () => null;
|
|
84
|
-
const ReauthDialog = lazy(async () => {
|
|
85
|
-
try {
|
|
86
|
-
const module = await import('@donotdev/auth');
|
|
87
|
-
return { default: module.ReauthDialog };
|
|
88
|
-
}
|
|
89
|
-
catch {
|
|
90
|
-
return { default: NullComponent };
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
const ConfirmDeleteDialog = lazy(async () => {
|
|
94
|
-
try {
|
|
95
|
-
const module = await import('@donotdev/auth');
|
|
96
|
-
return { default: module.ConfirmDeleteDialog };
|
|
97
|
-
}
|
|
98
|
-
catch {
|
|
99
|
-
return { default: NullComponent };
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
/**
|
|
103
|
-
* Resolves Lucide icon component from string name or component reference
|
|
104
|
-
*
|
|
105
|
-
* Supports:
|
|
106
|
-
* - String names (e.g., 'Settings', 'CreditCard') - resolved dynamically from lucide-react
|
|
107
|
-
* - React component references - returned as-is
|
|
108
|
-
* - Undefined/null - returns Settings as fallback
|
|
109
|
-
*
|
|
110
|
-
* @param iconName - Lucide icon name string, React component, or undefined
|
|
111
|
-
* @returns Lucide icon component (or Settings fallback)
|
|
112
|
-
*/
|
|
113
|
-
const getIcon = (iconName) => {
|
|
114
|
-
if (!iconName)
|
|
115
|
-
return Settings;
|
|
116
|
-
if (typeof iconName === 'function')
|
|
117
|
-
return iconName;
|
|
118
|
-
const cleanIconName = iconName.replace(/['"]/g, '');
|
|
119
|
-
const resolved = findLucideIcon(cleanIconName);
|
|
120
|
-
if (!resolved && process.env.NODE_ENV === 'development') {
|
|
121
|
-
console.warn(`[AuthMenu] Icon name "${cleanIconName}" not found in Lucide icons, falling back to Settings.`);
|
|
122
|
-
}
|
|
123
|
-
return resolved || Settings;
|
|
124
|
-
};
|
|
125
|
-
export const AuthMenu = ({ loginPath, display = DISPLAY.AUTO, 'no-tooltip': noTooltip = false, customItems = [], className, style, }) => {
|
|
126
|
-
const { t } = useTranslation('dndev');
|
|
127
|
-
const { shouldHide, isReady, isAuthenticated } = useAuthVisibility();
|
|
128
|
-
const authConfig = useAuthConfig();
|
|
129
|
-
// Get real auth state from the store (self-aware)
|
|
130
|
-
const user = useAuthSafe('user');
|
|
131
|
-
const signOut = useAuthSafe('signOut');
|
|
132
|
-
const isLaptop = useBreakpoint('isLaptop');
|
|
133
|
-
const navigationItems = useNavigationItems();
|
|
134
|
-
const navigate = useNavigate();
|
|
135
|
-
const profilePath = authConfig.profilePath;
|
|
136
|
-
const configMenuItems = authConfig.authMenuItems || [];
|
|
137
|
-
// Extract role from user (declared early so getUserTooltip can reference it)
|
|
138
|
-
const role = user?.role;
|
|
139
|
-
// Account deletion flow - managed by useDeleteAccountSafe hook
|
|
140
|
-
const deletion = useDeleteAccountSafe();
|
|
141
|
-
/**
|
|
142
|
-
* Get user display name with fallbacks
|
|
143
|
-
*/
|
|
144
|
-
const getUserDisplayName = () => {
|
|
145
|
-
if (!user)
|
|
146
|
-
return 'User';
|
|
147
|
-
return user.displayName || user.email?.split('@')[0] || 'User';
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
150
|
-
* Get user avatar initials
|
|
151
|
-
*/
|
|
152
|
-
const getUserInitials = () => {
|
|
153
|
-
const name = getUserDisplayName();
|
|
154
|
-
return name
|
|
155
|
-
.split(' ')
|
|
156
|
-
.map((word) => word.charAt(0))
|
|
157
|
-
.slice(0, 2)
|
|
158
|
-
.join('')
|
|
159
|
-
.toUpperCase();
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Get user tooltip text with account info (desktop only)
|
|
163
|
-
*/
|
|
164
|
-
const getUserTooltip = () => {
|
|
165
|
-
if (!user)
|
|
166
|
-
return t('auth.userMenu', { defaultValue: 'User menu' });
|
|
167
|
-
const parts = [getUserDisplayName()];
|
|
168
|
-
if (user.email)
|
|
169
|
-
parts.push(user.email);
|
|
170
|
-
if (role && role !== 'guest')
|
|
171
|
-
parts.push(`Role: ${role}`);
|
|
172
|
-
return parts.join('\n');
|
|
173
|
-
};
|
|
174
|
-
/**
|
|
175
|
-
* Build menu items list: Profile → configMenuItems → customItems → Delete → SignOut
|
|
176
|
-
*/
|
|
177
|
-
const menuItems = useMemo(() => {
|
|
178
|
-
const items = [];
|
|
179
|
-
// Mobile: Add disabled info item as first entry
|
|
180
|
-
if (!isLaptop && user) {
|
|
181
|
-
items.push({
|
|
182
|
-
// Use Text component as children instead of label
|
|
183
|
-
children: (_jsx(Text, { variant: "muted", as: "span", children: `${getUserDisplayName()}${user.email ? `\n${user.email}` : ''}` })),
|
|
184
|
-
disabled: true,
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
// Profile (if configured in appConfig.auth)
|
|
188
|
-
if (profilePath) {
|
|
189
|
-
items.push({
|
|
190
|
-
label: t('auth.profile', { defaultValue: 'Profile' }),
|
|
191
|
-
icon: User,
|
|
192
|
-
onClick: () => navigate(profilePath),
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
// Config menu items (if configured in appConfig.auth.authMenuItems)
|
|
196
|
-
// Icons are auto-resolved from route discovery if not provided
|
|
197
|
-
configMenuItems.forEach((item) => {
|
|
198
|
-
const navItem = navigationItems.find((nav) => nav.path === item.path);
|
|
199
|
-
const label = item.label || navItem?.label || item.path.split('/').pop() || 'Menu';
|
|
200
|
-
// Use route discovery icon if item.icon not provided, otherwise use item.icon
|
|
201
|
-
const Icon = item.icon
|
|
202
|
-
? getIcon(item.icon)
|
|
203
|
-
: navItem?.icon &&
|
|
204
|
-
(typeof navItem.icon === 'string' ||
|
|
205
|
-
typeof navItem.icon === 'function')
|
|
206
|
-
? getIcon(navItem.icon)
|
|
207
|
-
: Settings;
|
|
208
|
-
items.push({
|
|
209
|
-
label,
|
|
210
|
-
icon: Icon,
|
|
211
|
-
onClick: () => navigate(item.path),
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
// Custom items from props (merged with config items)
|
|
215
|
-
customItems.forEach((item) => {
|
|
216
|
-
if (item.path) {
|
|
217
|
-
// Route-based item
|
|
218
|
-
const navItem = navigationItems.find((nav) => nav.path === item.path);
|
|
219
|
-
const label = item.label || navItem?.label || item.path.split('/').pop() || 'Menu';
|
|
220
|
-
const Icon = item.icon ? getIcon(item.icon) : Settings;
|
|
221
|
-
items.push({
|
|
222
|
-
label,
|
|
223
|
-
icon: Icon,
|
|
224
|
-
onClick: () => navigate(item.path),
|
|
225
|
-
disabled: item.disabled,
|
|
226
|
-
style: item.style,
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
else if (item.onClick) {
|
|
230
|
-
// Custom item with onClick
|
|
231
|
-
const Icon = item.icon ? getIcon(item.icon) : Settings;
|
|
232
|
-
items.push({
|
|
233
|
-
label: item.label,
|
|
234
|
-
icon: Icon,
|
|
235
|
-
onClick: item.onClick,
|
|
236
|
-
disabled: item.disabled,
|
|
237
|
-
style: item.style,
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
// Delete Account (always show - mandatory GDPR/UX)
|
|
242
|
-
items.push({
|
|
243
|
-
label: t('auth.deleteAccount.label', { defaultValue: 'Delete Account' }),
|
|
244
|
-
icon: Trash2,
|
|
245
|
-
onClick: deletion.startDeleteFlow,
|
|
246
|
-
variant: 'destructive',
|
|
247
|
-
});
|
|
248
|
-
// Sign out (always show - mandatory GDPR/UX)
|
|
249
|
-
items.push({
|
|
250
|
-
label: t('auth.signOut', { defaultValue: 'Sign Out' }),
|
|
251
|
-
icon: LogOut,
|
|
252
|
-
onClick: () => signOut(),
|
|
253
|
-
variant: 'destructive',
|
|
254
|
-
});
|
|
255
|
-
return items;
|
|
256
|
-
}, [
|
|
257
|
-
profilePath,
|
|
258
|
-
configMenuItems,
|
|
259
|
-
customItems,
|
|
260
|
-
signOut,
|
|
261
|
-
deletion,
|
|
262
|
-
t,
|
|
263
|
-
navigationItems,
|
|
264
|
-
isLaptop,
|
|
265
|
-
user,
|
|
266
|
-
role,
|
|
267
|
-
getUserDisplayName,
|
|
268
|
-
navigate,
|
|
269
|
-
]);
|
|
270
|
-
// Get enabled providers
|
|
271
|
-
const enabled = getEnabledAuthPartners();
|
|
272
|
-
// If no providers enabled or should hide or not ready, render nothing
|
|
273
|
-
if (enabled.length === 0 || shouldHide || !isReady) {
|
|
274
|
-
return null;
|
|
275
|
-
}
|
|
276
|
-
// Return null when unauthenticated - AuthHeader handles unauthenticated state
|
|
277
|
-
if (!isAuthenticated) {
|
|
278
|
-
return null;
|
|
279
|
-
}
|
|
280
|
-
return (_jsxs(_Fragment, { children: [_jsx(Suspense, { fallback: null, children: _jsx(ReauthDialog, { open: deletion.showPasswordDialog, isLoading: deletion.isDeleting, error: deletion.error, onReauth: (password) => deletion.confirmDelete(password), onCancel: deletion.cancel }) }), _jsx(Suspense, { fallback: null, children: _jsx(ConfirmDeleteDialog, { open: deletion.showConfirmDialog, isLoading: deletion.isDeleting, error: deletion.error, onConfirm: () => deletion.confirmDelete(), onCancel: deletion.cancel }) }), _jsx(DropdownMenu, { trigger: _jsx(Button, { variant: BUTTON_VARIANT.OUTLINE, icon: user ? (_jsx(Avatar, { src: user.photoURL ?? undefined, fallback: getUserInitials(), alt: getUserDisplayName(), style: { margin: '-4px 0' } })) : (UserCheck), display: display, "aria-label": t('auth.userMenu', { defaultValue: 'User menu' }), tooltip: !noTooltip && isLaptop && user
|
|
281
|
-
? getUserTooltip()
|
|
282
|
-
: !noTooltip
|
|
283
|
-
? t('auth.userMenu', { defaultValue: 'User menu' })
|
|
284
|
-
: undefined, className: className, style: style, children: getUserDisplayName() }), items: menuItems, contentAlign: "end" })] }));
|
|
285
|
-
};
|
|
286
|
-
export default AuthMenu;
|
|
1
|
+
"use client";import{User as B,LogOut as E,Settings as u,UserCheck as $,Trash2 as Y}from"lucide-react";import{useMemo as j,lazy as S,Suspense as v}from"react";import{Avatar as z,Button as F,BUTTON_VARIANT as H,DropdownMenu as _,Text as q,DISPLAY as G}from"@donotdev/components";import{useTranslation as J}from"@donotdev/core";import{getEnabledAuthPartners as K,useAuthConfig as Q}from"@donotdev/core";import{useBreakpoint as W}from"@donotdev/core";import{useNavigate as X}from"@donotdev/ui/routing/hooks";import{useNavigationItems as Z}from"../../routing/index.js";import{useAuthSafe as M,useAuthVisibility as ee}from"../../utils/index.js";import{useDeleteAccountSafe as te}from"../../utils/useDeleteAccountSafe.js";import{iconByName as oe}from"../common/iconByName.js";import{Fragment as le,jsx as s,jsxs as re}from"react/jsx-runtime";var k=()=>null,ne=S(async()=>{try{return{default:(await import("@donotdev/auth")).ReauthDialog}}catch{return{default:k}}}),ae=S(async()=>{try{return{default:(await import("@donotdev/auth")).ConfirmDeleteDialog}}catch{return{default:k}}}),f=l=>l?typeof l=="function"?l:oe(l,u):u,se=({loginPath:l,display:T=G.AUTO,"no-tooltip":D=!1,customItems:b=[],className:U,style:R})=>{let{t:r}=J("dndev"),{shouldHide:N,isReady:w,isAuthenticated:L}=ee(),I=Q(),o=M("user"),A=M("signOut"),m=W("isLaptop"),d=Z(),p=X(),h=I.profilePath,P=I.authMenuItems||[],c=o?.role,n=te(),i=()=>o&&(o.displayName||o.email?.split("@")[0])||"User",O=()=>i().split(" ").map(e=>e.charAt(0)).slice(0,2).join("").toUpperCase(),V=()=>{if(!o)return r("auth.userMenu",{defaultValue:"User menu"});let t=[i()];return o.email&&t.push(o.email),c&&c!=="guest"&&t.push(`Role: ${c}`),t.join(`
|
|
2
|
+
`)},x=j(()=>{let t=[];return!m&&o&&t.push({children:s(q,{variant:"muted",as:"span",children:`${i()}${o.email?`
|
|
3
|
+
${o.email}`:""}`}),disabled:!0}),h&&t.push({label:r("auth.profile",{defaultValue:"Profile"}),icon:B,onClick:()=>p(h)}),P.forEach(e=>{let a=d.find(C=>C.path===e.path),g=e.label||a?.label||e.path.split("/").pop()||"Menu",y=e.icon?f(e.icon):a?.icon&&(typeof a.icon=="string"||typeof a.icon=="function")?f(a.icon):u;t.push({label:g,icon:y,onClick:()=>p(e.path)})}),b.forEach(e=>{if(e.path){let a=d.find(C=>C.path===e.path),g=e.label||a?.label||e.path.split("/").pop()||"Menu",y=e.icon?f(e.icon):u;t.push({label:g,icon:y,onClick:()=>p(e.path),disabled:e.disabled,style:e.style})}else if(e.onClick){let a=e.icon?f(e.icon):u;t.push({label:e.label,icon:a,onClick:e.onClick,disabled:e.disabled,style:e.style})}}),t.push({label:r("auth.deleteAccount.label",{defaultValue:"Delete Account"}),icon:Y,onClick:n.startDeleteFlow,variant:"destructive"}),t.push({label:r("auth.signOut",{defaultValue:"Sign Out"}),icon:E,onClick:()=>A(),variant:"destructive"}),t},[h,P,b,A,n,r,d,m,o,c,i,p]);return K().length===0||N||!w||!L?null:re(le,{children:[s(v,{fallback:null,children:s(ne,{open:n.showPasswordDialog,isLoading:n.isDeleting,error:n.error,onReauth:t=>n.confirmDelete(t),onCancel:n.cancel})}),s(v,{fallback:null,children:s(ae,{open:n.showConfirmDialog,isLoading:n.isDeleting,error:n.error,onConfirm:()=>n.confirmDelete(),onCancel:n.cancel})}),s(_,{trigger:s(F,{variant:H.OUTLINE,icon:o?s(z,{src:o.photoURL??void 0,fallback:O(),alt:i(),style:{margin:"-4px 0"}}):$,display:T,"aria-label":r("auth.userMenu",{defaultValue:"User menu"}),tooltip:!D&&m&&o?V():D?void 0:r("auth.userMenu",{defaultValue:"User menu"}),className:U,style:R,children:i()}),items:x,contentAlign:"end"})]})},Ie=se;export{se as AuthMenu,Ie as default};
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Auth Components - Layout components that compose core and features
|
|
4
|
-
*
|
|
5
|
-
* These are layout components, not page templates.
|
|
6
|
-
* @packageDocumentation
|
|
7
|
-
*/
|
|
8
|
-
export { AuthHeader } from './AuthHeader';
|
|
9
|
-
export { AuthMenu } from './AuthMenu';
|
|
1
|
+
import{AuthHeader as t}from"./AuthHeader.js";import{AuthMenu as u}from"./AuthMenu.js";export{t as AuthHeader,u as AuthMenu};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureCard.d.ts","sourceRoot":"","sources":["../../../src/components/common/FeatureCard.tsx"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAStD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIhF,gEAAgE;AAChE,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAE7C,2CAA2C;AAC3C,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,SAAS,EACT,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,CACvD;IACC,uBAAuB;IACvB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uHAAuH;IACvH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,QAAA,MAAM,WAAW,GAAI,mIAelB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"FeatureCard.d.ts","sourceRoot":"","sources":["../../../src/components/common/FeatureCard.tsx"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAStD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIhF,gEAAgE;AAChE,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAE7C,2CAA2C;AAC3C,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,SAAS,EACT,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,CACvD;IACC,uBAAuB;IACvB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uHAAuH;IACvH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,QAAA,MAAM,WAAW,GAAI,mIAelB,gBAAgB,gCA8IlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,86 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Card, IconBox, Stack, Text, renderCardContent, } from '@donotdev/components';
|
|
4
|
-
import { Link } from '../../routing';
|
|
5
|
-
/**
|
|
6
|
-
* FeatureCard - Card wrapper with content array and routing
|
|
7
|
-
*
|
|
8
|
-
* Uses Card component internally. Routing via Link when href provided.
|
|
9
|
-
*/
|
|
10
|
-
const FeatureCard = ({ icon, title, subtitle, content, href, variant, elevated, onClick, className, footer, style, clickable, maxLines = 2, ...cardProps }) => {
|
|
11
|
-
const contentNode = renderCardContent(content);
|
|
12
|
-
const n = maxLines;
|
|
13
|
-
const titleRowHeight = n <= 0
|
|
14
|
-
? 'auto'
|
|
15
|
-
: `calc(var(--font-size-lg) * var(--line-height) * ${n} + var(--gap-md))`;
|
|
16
|
-
const subtitleRowHeight = n <= 0
|
|
17
|
-
? 'auto'
|
|
18
|
-
: `calc(var(--font-size-base) * var(--line-height) * ${n} + var(--gap-md))`;
|
|
19
|
-
const gridTemplateRows = `${titleRowHeight} ${subtitleRowHeight} 1fr${footer ? ' auto' : ''}`;
|
|
20
|
-
const clampBlock = (lines) => lines <= 0
|
|
21
|
-
? {
|
|
22
|
-
display: 'block',
|
|
23
|
-
overflow: 'visible',
|
|
24
|
-
wordBreak: 'break-word',
|
|
25
|
-
lineHeight: 'var(--line-height)',
|
|
26
|
-
WebkitLineClamp: 'unset',
|
|
27
|
-
WebkitBoxOrient: 'unset',
|
|
28
|
-
}
|
|
29
|
-
: {
|
|
30
|
-
display: '-webkit-box',
|
|
31
|
-
WebkitLineClamp: lines,
|
|
32
|
-
WebkitBoxOrient: 'vertical',
|
|
33
|
-
overflow: 'hidden',
|
|
34
|
-
textOverflow: 'ellipsis',
|
|
35
|
-
wordBreak: 'break-word',
|
|
36
|
-
lineHeight: 'var(--line-height)',
|
|
37
|
-
};
|
|
38
|
-
const titleStyle = {
|
|
39
|
-
...clampBlock(n),
|
|
40
|
-
fontSize: 'var(--font-size-lg)',
|
|
41
|
-
fontWeight: 600,
|
|
42
|
-
color: 'inherit',
|
|
43
|
-
margin: 0,
|
|
44
|
-
textAlign: 'start',
|
|
45
|
-
flex: 1,
|
|
46
|
-
minWidth: 0,
|
|
47
|
-
};
|
|
48
|
-
const subtitleStyle = {
|
|
49
|
-
...clampBlock(n),
|
|
50
|
-
fontSize: 'var(--font-size-base)',
|
|
51
|
-
fontWeight: n <= 0 ? 500 : 600,
|
|
52
|
-
color: 'var(--muted-foreground)',
|
|
53
|
-
margin: 0,
|
|
54
|
-
};
|
|
55
|
-
const titleContent = icon ? (_jsxs(Stack, { direction: "row", align: n <= 0 ? 'start' : 'center', style: { width: '100%' }, children: [_jsx(IconBox, { icon: icon }), _jsx(Text, { as: "div", level: "h3", style: titleStyle, children: title })] })) : (_jsx(Text, { as: "div", level: "h3", style: titleStyle, children: title }));
|
|
56
|
-
const card = (_jsx(Card, { variant: variant, elevated: elevated, onClick: onClick, className: className, "data-clickable": href || onClick || clickable ? 'true' : undefined, style: {
|
|
57
|
-
paddingInlineStart: 'var(--gap-md)',
|
|
58
|
-
paddingInlineEnd: 'var(--gap-md)',
|
|
59
|
-
gap: 'var(--gap-md)',
|
|
60
|
-
height: '100%',
|
|
61
|
-
textAlign: 'start',
|
|
62
|
-
...style,
|
|
63
|
-
}, ...cardProps, children: _jsxs("div", { style: {
|
|
64
|
-
display: 'grid',
|
|
65
|
-
gridTemplateRows: gridTemplateRows,
|
|
66
|
-
gap: 'var(--gap-md)',
|
|
67
|
-
width: '100%',
|
|
68
|
-
}, children: [_jsx("div", { style: {
|
|
69
|
-
display: 'flex',
|
|
70
|
-
alignItems: n <= 0 ? 'flex-start' : 'center',
|
|
71
|
-
justifyContent: 'flex-start',
|
|
72
|
-
}, children: titleContent }), _jsx("div", { style: {
|
|
73
|
-
display: 'flex',
|
|
74
|
-
alignItems: 'flex-start',
|
|
75
|
-
justifyContent: 'flex-start',
|
|
76
|
-
}, children: _jsx(Text, { as: "div", level: "body", style: subtitleStyle, children: subtitle }) }), _jsx("div", { children: contentNode }), footer && _jsx("div", { children: footer })] }) }));
|
|
77
|
-
if (href && !onClick) {
|
|
78
|
-
return (_jsx(Link, { path: href, style: {
|
|
79
|
-
display: 'block',
|
|
80
|
-
textDecoration: 'none',
|
|
81
|
-
height: '100%',
|
|
82
|
-
}, "aria-label": title ? `Learn more about ${title}` : undefined, children: card }));
|
|
83
|
-
}
|
|
84
|
-
return card;
|
|
85
|
-
};
|
|
86
|
-
export default FeatureCard;
|
|
1
|
+
"use client";import{Card as z,IconBox as B,Stack as N,Text as n,renderCardContent as T}from"@donotdev/components";import{Link as I}from"../../routing/index.js";import{jsx as t,jsxs as v}from"react/jsx-runtime";var L=({icon:o,title:l,subtitle:g,content:m,href:i,variant:f,elevated:h,onClick:a,className:u,footer:r,style:C,clickable:b,maxLines:x=2,...y})=>{let k=T(m),e=x,w=e<=0?"auto":`calc(var(--font-size-lg) * var(--line-height) * ${e} + var(--gap-md))`,S=e<=0?"auto":`calc(var(--font-size-base) * var(--line-height) * ${e} + var(--gap-md))`,P=`${w} ${S} 1fr${r?" auto":""}`,d=p=>p<=0?{display:"block",overflow:"visible",wordBreak:"break-word",lineHeight:"var(--line-height)",WebkitLineClamp:"unset",WebkitBoxOrient:"unset"}:{display:"-webkit-box",WebkitLineClamp:p,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",wordBreak:"break-word",lineHeight:"var(--line-height)"},s={...d(e),fontSize:"var(--font-size-lg)",fontWeight:600,color:"inherit",margin:0,textAlign:"start",flex:1,minWidth:0},R={...d(e),fontSize:"var(--font-size-base)",fontWeight:e<=0?500:600,color:"var(--muted-foreground)",margin:0},W=o?v(N,{direction:"row",align:e<=0?"start":"center",style:{width:"100%"},children:[t(B,{icon:o}),t(n,{as:"div",level:"h3",style:s,children:l})]}):t(n,{as:"div",level:"h3",style:s,children:l}),c=t(z,{variant:f,elevated:h,onClick:a,className:u,"data-clickable":i||a||b?"true":void 0,style:{paddingInlineStart:"var(--gap-md)",paddingInlineEnd:"var(--gap-md)",gap:"var(--gap-md)",height:"100%",textAlign:"start",...C},...y,children:v("div",{style:{display:"grid",gridTemplateRows:P,gap:"var(--gap-md)",width:"100%"},children:[t("div",{style:{display:"flex",alignItems:e<=0?"flex-start":"center",justifyContent:"flex-start"},children:W}),t("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"flex-start"},children:t(n,{as:"div",level:"body",style:R,children:g})}),t("div",{children:k}),r&&t("div",{children:r})]})});return i&&!a?t(I,{path:i,style:{display:"block",textDecoration:"none",height:"100%"},children:c}):c},H=L;export{H as default};
|
|
@@ -1,67 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
// packages/ui/src/components/common/FeatureDisabled.tsx
|
|
4
|
-
/**
|
|
5
|
-
* @fileoverview FeatureDisabled Component
|
|
6
|
-
* @description Reusable component for displaying feature unavailable/disabled states
|
|
7
|
-
*
|
|
8
|
-
* This component provides a consistent UI for when features are not available,
|
|
9
|
-
* whether due to missing packages, disabled configuration, or other reasons.
|
|
10
|
-
*
|
|
11
|
-
* @version 0.1.0
|
|
12
|
-
* @since 0.0.1
|
|
13
|
-
* @author AMBROISE PARK Consulting
|
|
14
|
-
*/
|
|
15
|
-
import { AlertCircle, RefreshCw, Mail, Cookie } from 'lucide-react';
|
|
16
|
-
import { Card, Button, BUTTON_VARIANT, Stack } from '@donotdev/components';
|
|
17
|
-
import { useTranslation } from '@donotdev/core';
|
|
18
|
-
/**
|
|
19
|
-
* FeatureDisabled - Component for displaying feature unavailable states
|
|
20
|
-
*
|
|
21
|
-
* Provides a consistent UI pattern for when features are disabled or unavailable.
|
|
22
|
-
* Includes options for review cookies, contact support, and retry actions.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```tsx
|
|
26
|
-
* <FeatureDisabled
|
|
27
|
-
* featureName="Billing"
|
|
28
|
-
* description="Stripe billing is not configured"
|
|
29
|
-
* showContactSupport={true}
|
|
30
|
-
* showRetry={true}
|
|
31
|
-
* onRetry={() => window.location.reload()}
|
|
32
|
-
* />
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* @param props - FeatureDisabled component props
|
|
36
|
-
* @returns React component
|
|
37
|
-
*
|
|
38
|
-
* @version 0.1.0
|
|
39
|
-
* @since 0.0.1
|
|
40
|
-
* @author AMBROISE PARK Consulting
|
|
41
|
-
*/
|
|
42
|
-
function FeatureDisabled({ featureName, title, description, showReviewCookies = false, showContactSupport = true, showRetry = false, supportEmail = 'support@example.com', onRetry, onReviewCookies, customActions, className = '', }) {
|
|
43
|
-
const { t } = useTranslation('ui');
|
|
44
|
-
const defaultDescription = description ||
|
|
45
|
-
t('featureDisabled.description', '{featureName} is not available. This may be due to missing configuration or disabled features.', { featureName });
|
|
46
|
-
const handleReviewCookies = () => {
|
|
47
|
-
if (onReviewCookies) {
|
|
48
|
-
onReviewCookies();
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
// Default: try to open cookie consent if available
|
|
52
|
-
const event = new CustomEvent('openCookieConsent');
|
|
53
|
-
window.dispatchEvent(event);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const handleContactSupport = () => {
|
|
57
|
-
window.location.href = `mailto:${supportEmail}?subject=${encodeURIComponent(`Feature Unavailable: ${featureName}`)}&body=${encodeURIComponent(`I'm experiencing an issue with ${featureName} not being available.`)}`;
|
|
58
|
-
};
|
|
59
|
-
return (_jsxs(Card, { className: className, title: _jsxs(Stack, { direction: "row", align: "center", gap: "tight", children: [_jsx(AlertCircle, { className: "dndev-size-md", style: { color: 'var(--destructive)' } }), title || featureName] }), subtitle: defaultDescription, children: [' ', _jsxs("div", { style: { display: 'grid', gap: 'var(--gap-md)' }, children: [(showReviewCookies ||
|
|
60
|
-
showContactSupport ||
|
|
61
|
-
showRetry ||
|
|
62
|
-
customActions) && (_jsxs(Stack, { direction: "row", wrap: "wrap", gap: "tight", children: [showReviewCookies && (_jsx(Button, { variant: BUTTON_VARIANT.OUTLINE, onClick: handleReviewCookies, icon: Cookie, children: t('featureDisabled.reviewCookies', 'Review Cookies') })), showContactSupport && (_jsx(Button, { variant: BUTTON_VARIANT.OUTLINE, onClick: handleContactSupport, icon: Mail, children: t('featureDisabled.contactSupport', 'Contact Support') })), showRetry && (_jsx(Button, { variant: BUTTON_VARIANT.OUTLINE, onClick: onRetry, icon: RefreshCw, children: t('featureDisabled.retry', 'Retry') })), customActions] })), _jsx("p", { style: {
|
|
63
|
-
fontSize: 'var(--font-size-sm)',
|
|
64
|
-
color: 'var(--muted-foreground)',
|
|
65
|
-
}, children: t('featureDisabled.helpText', 'If you believe this is an error, please contact support or try refreshing the page.') })] })] }));
|
|
66
|
-
}
|
|
67
|
-
export default FeatureDisabled;
|
|
1
|
+
"use client";import{AlertCircle as y,RefreshCw as k,Mail as R,Cookie as D}from"lucide-react";import{Card as N,Button as a,BUTTON_VARIANT as r,Stack as p}from"@donotdev/components";import{useTranslation as T}from"@donotdev/core";import{jsx as t,jsxs as i}from"react/jsx-runtime";function I({featureName:o,title:u,description:f,showReviewCookies:n=!1,showContactSupport:s=!0,showRetry:l=!1,supportEmail:m="support@example.com",onRetry:v,onReviewCookies:c,customActions:d,className:b=""}){let{t:e}=T("ui"),g=f||e("featureDisabled.description","{featureName} is not available. This may be due to missing configuration or disabled features.",{featureName:o}),C=()=>{if(c)c();else{let h=new CustomEvent("openCookieConsent");window.dispatchEvent(h)}},w=()=>{window.location.href=`mailto:${m}?subject=${encodeURIComponent(`Feature Unavailable: ${o}`)}&body=${encodeURIComponent(`I'm experiencing an issue with ${o} not being available.`)}`};return i(N,{className:b,title:i(p,{direction:"row",align:"center",gap:"tight",children:[t(y,{className:"dndev-size-md",style:{color:"var(--destructive)"}}),u||o]}),subtitle:g,children:[" ",i("div",{style:{display:"grid",gap:"var(--gap-md)"},children:[(n||s||l||d)&&i(p,{direction:"row",wrap:"wrap",gap:"tight",children:[n&&t(a,{variant:r.OUTLINE,onClick:C,icon:D,children:e("featureDisabled.reviewCookies","Review Cookies")}),s&&t(a,{variant:r.OUTLINE,onClick:w,icon:R,children:e("featureDisabled.contactSupport","Contact Support")}),l&&t(a,{variant:r.OUTLINE,onClick:v,icon:k,children:e("featureDisabled.retry","Retry")}),d]}),t("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:e("featureDisabled.helpText","If you believe this is an error, please contact support or try refreshing the page.")})]})]})}var B=I;export{B as default};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Icon placeholder
|
|
3
|
+
* @description Empty box with the icon's class and style, shown while a lazy icon loads.
|
|
4
|
+
* Internal to @donotdev/ui (not re-exported).
|
|
5
|
+
*
|
|
6
|
+
* @version 0.1.0
|
|
7
|
+
* @since 0.3.2
|
|
8
|
+
* @author AMBROISE PARK Consulting
|
|
9
|
+
*/
|
|
10
|
+
import type { CSSProperties, ReactElement } from 'react';
|
|
11
|
+
/** Props of {@link IconPlaceholder}: the sizing props of the icon it stands for. */
|
|
12
|
+
export interface IconPlaceholderProps {
|
|
13
|
+
className?: string;
|
|
14
|
+
style?: CSSProperties;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Same-size stand-in for an icon that is not loaded yet (decorative).
|
|
18
|
+
*
|
|
19
|
+
* @version 0.1.0
|
|
20
|
+
* @since 0.3.2
|
|
21
|
+
* @author AMBROISE PARK Consulting
|
|
22
|
+
*/
|
|
23
|
+
export declare function IconPlaceholder({ className, style, }: IconPlaceholderProps): ReactElement;
|
|
24
|
+
//# sourceMappingURL=IconPlaceholder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconPlaceholder.d.ts","sourceRoot":"","sources":["../../../src/components/common/IconPlaceholder.tsx"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAEzD,oFAAoF;AACpF,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,KAAK,GACN,EAAE,oBAAoB,GAAG,YAAY,CAQrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as l}from"react/jsx-runtime";function o({className:e,style:r}){return l("span",{className:e,style:{display:"inline-block",flexShrink:0,...r},"aria-hidden":"true"})}export{o as IconPlaceholder};
|