@djangocfg/layouts 1.0.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/LICENSE +21 -0
- package/README.md +77 -0
- package/package.json +86 -0
- package/src/auth/README.md +962 -0
- package/src/auth/context/AuthContext.tsx +458 -0
- package/src/auth/context/index.ts +2 -0
- package/src/auth/context/types.ts +63 -0
- package/src/auth/hooks/index.ts +6 -0
- package/src/auth/hooks/useAuthForm.ts +329 -0
- package/src/auth/hooks/useAuthGuard.ts +23 -0
- package/src/auth/hooks/useAuthRedirect.ts +51 -0
- package/src/auth/hooks/useAutoAuth.ts +42 -0
- package/src/auth/hooks/useLocalStorage.ts +211 -0
- package/src/auth/hooks/useSessionStorage.ts +186 -0
- package/src/auth/index.ts +10 -0
- package/src/auth/middlewares/index.ts +1 -0
- package/src/auth/middlewares/proxy.ts +24 -0
- package/src/auth/server.ts +6 -0
- package/src/auth/utils/errors.ts +34 -0
- package/src/auth/utils/index.ts +2 -0
- package/src/auth/utils/validation.ts +14 -0
- package/src/index.ts +15 -0
- package/src/layouts/AppLayout/AppLayout.tsx +123 -0
- package/src/layouts/AppLayout/README.md +204 -0
- package/src/layouts/AppLayout/SUMMARY.md +240 -0
- package/src/layouts/AppLayout/USAGE.md +312 -0
- package/src/layouts/AppLayout/components/PageProgress.tsx +104 -0
- package/src/layouts/AppLayout/components/Seo.tsx +87 -0
- package/src/layouts/AppLayout/components/index.ts +6 -0
- package/src/layouts/AppLayout/context/AppContext.tsx +146 -0
- package/src/layouts/AppLayout/context/index.ts +5 -0
- package/src/layouts/AppLayout/hooks/index.ts +6 -0
- package/src/layouts/AppLayout/hooks/useLayoutMode.ts +26 -0
- package/src/layouts/AppLayout/hooks/useNavigation.ts +49 -0
- package/src/layouts/AppLayout/index.ts +31 -0
- package/src/layouts/AppLayout/layouts/AuthLayout/AuthContext.tsx +51 -0
- package/src/layouts/AppLayout/layouts/AuthLayout/AuthHelp.tsx +111 -0
- package/src/layouts/AppLayout/layouts/AuthLayout/AuthLayout.tsx +40 -0
- package/src/layouts/AppLayout/layouts/AuthLayout/IdentifierForm.tsx +330 -0
- package/src/layouts/AppLayout/layouts/AuthLayout/OTPForm.tsx +158 -0
- package/src/layouts/AppLayout/layouts/AuthLayout/index.ts +13 -0
- package/src/layouts/AppLayout/layouts/AuthLayout/types.ts +61 -0
- package/src/layouts/AppLayout/layouts/PrivateLayout/PrivateLayout.tsx +92 -0
- package/src/layouts/AppLayout/layouts/PrivateLayout/components/DashboardContent.tsx +60 -0
- package/src/layouts/AppLayout/layouts/PrivateLayout/components/DashboardHeader.tsx +170 -0
- package/src/layouts/AppLayout/layouts/PrivateLayout/components/DashboardSidebar.tsx +164 -0
- package/src/layouts/AppLayout/layouts/PrivateLayout/components/index.ts +7 -0
- package/src/layouts/AppLayout/layouts/PrivateLayout/index.ts +5 -0
- package/src/layouts/AppLayout/layouts/PublicLayout/PublicLayout.tsx +44 -0
- package/src/layouts/AppLayout/layouts/PublicLayout/components/DesktopUserMenu.tsx +136 -0
- package/src/layouts/AppLayout/layouts/PublicLayout/components/Footer.tsx +262 -0
- package/src/layouts/AppLayout/layouts/PublicLayout/components/MobileMenu.tsx +289 -0
- package/src/layouts/AppLayout/layouts/PublicLayout/components/Navigation.tsx +159 -0
- package/src/layouts/AppLayout/layouts/PublicLayout/index.ts +5 -0
- package/src/layouts/AppLayout/layouts/index.ts +7 -0
- package/src/layouts/AppLayout/providers/CoreProviders.tsx +47 -0
- package/src/layouts/AppLayout/providers/index.ts +5 -0
- package/src/layouts/AppLayout/types/config.ts +40 -0
- package/src/layouts/AppLayout/types/index.ts +10 -0
- package/src/layouts/AppLayout/types/layout.ts +47 -0
- package/src/layouts/AppLayout/types/navigation.ts +41 -0
- package/src/layouts/AppLayout/types/routes.ts +45 -0
- package/src/layouts/AppLayout/utils/index.ts +5 -0
- package/src/layouts/AppLayout/utils/routeDetection.ts +31 -0
- package/src/layouts/PaymentsLayout/PaymentsLayout.tsx +125 -0
- package/src/layouts/PaymentsLayout/README.md +133 -0
- package/src/layouts/PaymentsLayout/components/CreateApiKeyDialog.tsx +172 -0
- package/src/layouts/PaymentsLayout/components/CreatePaymentDialog.tsx +203 -0
- package/src/layouts/PaymentsLayout/components/DeleteApiKeyDialog.tsx +100 -0
- package/src/layouts/PaymentsLayout/components/index.ts +4 -0
- package/src/layouts/PaymentsLayout/events.ts +106 -0
- package/src/layouts/PaymentsLayout/index.ts +20 -0
- package/src/layouts/PaymentsLayout/types.ts +19 -0
- package/src/layouts/PaymentsLayout/views/apikeys/components/ApiKeyMetrics.tsx +109 -0
- package/src/layouts/PaymentsLayout/views/apikeys/components/ApiKeysList.tsx +194 -0
- package/src/layouts/PaymentsLayout/views/apikeys/components/index.ts +3 -0
- package/src/layouts/PaymentsLayout/views/apikeys/index.tsx +19 -0
- package/src/layouts/PaymentsLayout/views/overview/components/BalanceCard.tsx +99 -0
- package/src/layouts/PaymentsLayout/views/overview/components/MetricsCards.tsx +103 -0
- package/src/layouts/PaymentsLayout/views/overview/components/RecentPayments.tsx +138 -0
- package/src/layouts/PaymentsLayout/views/overview/components/index.ts +4 -0
- package/src/layouts/PaymentsLayout/views/overview/index.tsx +23 -0
- package/src/layouts/PaymentsLayout/views/payments/components/PaymentsList.tsx +282 -0
- package/src/layouts/PaymentsLayout/views/payments/components/index.ts +2 -0
- package/src/layouts/PaymentsLayout/views/payments/index.tsx +18 -0
- package/src/layouts/PaymentsLayout/views/tariffs/index.tsx +29 -0
- package/src/layouts/PaymentsLayout/views/transactions/index.tsx +29 -0
- package/src/layouts/ProfileLayout/ProfileLayout.tsx +110 -0
- package/src/layouts/ProfileLayout/components/AvatarSection.tsx +146 -0
- package/src/layouts/ProfileLayout/components/ProfileForm.tsx +208 -0
- package/src/layouts/ProfileLayout/components/index.ts +3 -0
- package/src/layouts/ProfileLayout/index.ts +3 -0
- package/src/layouts/SupportLayout/README.md +91 -0
- package/src/layouts/SupportLayout/SupportLayout.tsx +178 -0
- package/src/layouts/SupportLayout/components/CreateTicketDialog.tsx +154 -0
- package/src/layouts/SupportLayout/components/MessageInput.tsx +92 -0
- package/src/layouts/SupportLayout/components/MessageList.tsx +312 -0
- package/src/layouts/SupportLayout/components/TicketCard.tsx +96 -0
- package/src/layouts/SupportLayout/components/TicketList.tsx +152 -0
- package/src/layouts/SupportLayout/components/index.ts +6 -0
- package/src/layouts/SupportLayout/context/SupportLayoutContext.tsx +260 -0
- package/src/layouts/SupportLayout/context/index.ts +2 -0
- package/src/layouts/SupportLayout/events.ts +31 -0
- package/src/layouts/SupportLayout/hooks/index.ts +2 -0
- package/src/layouts/SupportLayout/hooks/useInfiniteMessages.ts +118 -0
- package/src/layouts/SupportLayout/hooks/useInfiniteTickets.ts +91 -0
- package/src/layouts/SupportLayout/index.ts +6 -0
- package/src/layouts/SupportLayout/types.ts +23 -0
- package/src/layouts/index.ts +9 -0
- package/src/snippets/AuthDialog/AuthDialog.tsx +88 -0
- package/src/snippets/AuthDialog/events.ts +21 -0
- package/src/snippets/AuthDialog/index.ts +3 -0
- package/src/snippets/AuthDialog/useAuthDialog.ts +27 -0
- package/src/snippets/Breadcrumbs.tsx +80 -0
- package/src/snippets/Chat/ChatUIContext.tsx +110 -0
- package/src/snippets/Chat/ChatWidget.tsx +476 -0
- package/src/snippets/Chat/README.md +122 -0
- package/src/snippets/Chat/components/MessageInput.tsx +124 -0
- package/src/snippets/Chat/components/MessageList.tsx +168 -0
- package/src/snippets/Chat/components/SessionList.tsx +192 -0
- package/src/snippets/Chat/components/index.ts +9 -0
- package/src/snippets/Chat/hooks/index.ts +6 -0
- package/src/snippets/Chat/hooks/useInfiniteSessions.ts +83 -0
- package/src/snippets/Chat/index.tsx +44 -0
- package/src/snippets/Chat/types.ts +79 -0
- package/src/snippets/VideoPlayer/README.md +203 -0
- package/src/snippets/VideoPlayer/VideoControls.tsx +133 -0
- package/src/snippets/VideoPlayer/VideoPlayer.tsx +114 -0
- package/src/snippets/VideoPlayer/index.ts +8 -0
- package/src/snippets/VideoPlayer/types.ts +61 -0
- package/src/snippets/index.ts +10 -0
- package/src/styles/dashboard.css +41 -0
- package/src/styles/index.css +20 -0
- package/src/styles/sources.css +6 -0
- package/src/types/index.ts +1 -0
- package/src/types/pageConfig.ts +103 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/logger.ts +57 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
// Configuration for the AppBar
|
|
4
|
+
export interface AppBarConfig {
|
|
5
|
+
label?: string;
|
|
6
|
+
showSidebarToggle?: boolean;
|
|
7
|
+
onSidebarToggle?: () => void;
|
|
8
|
+
hideAuthButtons?: boolean;
|
|
9
|
+
hideNavigation?: boolean;
|
|
10
|
+
actions?: ReactNode;
|
|
11
|
+
showPageScrollProgress?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// OpenGraph configuration
|
|
15
|
+
export interface OpenGraphConfig {
|
|
16
|
+
title?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
images?: Array<{
|
|
20
|
+
url: string;
|
|
21
|
+
width?: number;
|
|
22
|
+
height?: number;
|
|
23
|
+
alt?: string;
|
|
24
|
+
}>;
|
|
25
|
+
siteName?: string;
|
|
26
|
+
locale?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Twitter configuration
|
|
30
|
+
export interface TwitterConfig {
|
|
31
|
+
card?: 'summary' | 'summary_large_image' | 'app' | 'player';
|
|
32
|
+
title?: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
images?: string[];
|
|
35
|
+
creator?: string;
|
|
36
|
+
site?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Configuration for a Page using the App3 layout
|
|
40
|
+
export interface PageConfig {
|
|
41
|
+
projectName?: string;
|
|
42
|
+
title?: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
keywords?: string;
|
|
45
|
+
jsonLd?: Record<string, any>;
|
|
46
|
+
appBar?: AppBarConfig;
|
|
47
|
+
protected?: boolean;
|
|
48
|
+
themeMode?: 'light' | 'dark';
|
|
49
|
+
ogImage?: {
|
|
50
|
+
title?: string;
|
|
51
|
+
subtitle?: string;
|
|
52
|
+
};
|
|
53
|
+
openGraph?: OpenGraphConfig;
|
|
54
|
+
twitter?: TwitterConfig;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Type for a Page component that includes page configuration
|
|
58
|
+
export type PageWithConfig<T = {}> = FC<T> & {
|
|
59
|
+
pageConfig?: PageConfig;
|
|
60
|
+
[key: string]: any;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// --- Helper Function ---
|
|
64
|
+
export const determinePageConfig = (
|
|
65
|
+
Component: PageWithConfig,
|
|
66
|
+
pageProps: Record<string, any>, // Use a general type for pageProps
|
|
67
|
+
defaultTitle?: string,
|
|
68
|
+
defaultDescription?: string,
|
|
69
|
+
): PageConfig => {
|
|
70
|
+
const defaultPageConfig: PageConfig = {
|
|
71
|
+
title: defaultTitle,
|
|
72
|
+
description: defaultDescription,
|
|
73
|
+
protected: false,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const configFromProps = pageProps.pageConfig as PageConfig | undefined;
|
|
77
|
+
const configFromStatic = Component.pageConfig as PageConfig | undefined;
|
|
78
|
+
|
|
79
|
+
let finalConfig: PageConfig = { ...defaultPageConfig };
|
|
80
|
+
|
|
81
|
+
// Merge static config first
|
|
82
|
+
if (configFromStatic) {
|
|
83
|
+
finalConfig = {
|
|
84
|
+
...finalConfig,
|
|
85
|
+
...configFromStatic,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Merge dynamic config from props (overrides static)
|
|
90
|
+
if (configFromProps) {
|
|
91
|
+
finalConfig = {
|
|
92
|
+
...finalConfig,
|
|
93
|
+
...configFromProps,
|
|
94
|
+
appBar: {
|
|
95
|
+
...finalConfig.appBar,
|
|
96
|
+
...configFromProps.appBar,
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return finalConfig;
|
|
102
|
+
};
|
|
103
|
+
// --- End Helper Function ---
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createConsola } from 'consola';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Universal logger for @djangocfg/layouts
|
|
5
|
+
* Uses consola for beautiful console logging
|
|
6
|
+
*
|
|
7
|
+
* Log levels:
|
|
8
|
+
* - 0: silent
|
|
9
|
+
* - 1: fatal, error
|
|
10
|
+
* - 2: warn
|
|
11
|
+
* - 3: log, info
|
|
12
|
+
* - 4: debug
|
|
13
|
+
* - 5: trace, verbose
|
|
14
|
+
*/
|
|
15
|
+
export const logger = createConsola({
|
|
16
|
+
level: process.env.NODE_ENV === 'production' ? 3 : 4,
|
|
17
|
+
}).withTag('layouts');
|
|
18
|
+
|
|
19
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
20
|
+
// Module-specific loggers
|
|
21
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Auth-specific logger
|
|
25
|
+
*/
|
|
26
|
+
export const authLogger = logger.withTag('auth');
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Chat-specific logger
|
|
30
|
+
*/
|
|
31
|
+
export const chatLogger = logger.withTag('chat');
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Support-specific logger
|
|
35
|
+
*/
|
|
36
|
+
export const supportLogger = logger.withTag('support');
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Payments-specific logger
|
|
40
|
+
*/
|
|
41
|
+
export const paymentsLogger = logger.withTag('payments');
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Profile-specific logger
|
|
45
|
+
*/
|
|
46
|
+
export const profileLogger = logger.withTag('profile');
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Dashboard-specific logger
|
|
50
|
+
*/
|
|
51
|
+
export const dashboardLogger = logger.withTag('dashboard');
|
|
52
|
+
|
|
53
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
54
|
+
// Export default
|
|
55
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
56
|
+
|
|
57
|
+
export default logger;
|