@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.
Files changed (138) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -0
  3. package/package.json +86 -0
  4. package/src/auth/README.md +962 -0
  5. package/src/auth/context/AuthContext.tsx +458 -0
  6. package/src/auth/context/index.ts +2 -0
  7. package/src/auth/context/types.ts +63 -0
  8. package/src/auth/hooks/index.ts +6 -0
  9. package/src/auth/hooks/useAuthForm.ts +329 -0
  10. package/src/auth/hooks/useAuthGuard.ts +23 -0
  11. package/src/auth/hooks/useAuthRedirect.ts +51 -0
  12. package/src/auth/hooks/useAutoAuth.ts +42 -0
  13. package/src/auth/hooks/useLocalStorage.ts +211 -0
  14. package/src/auth/hooks/useSessionStorage.ts +186 -0
  15. package/src/auth/index.ts +10 -0
  16. package/src/auth/middlewares/index.ts +1 -0
  17. package/src/auth/middlewares/proxy.ts +24 -0
  18. package/src/auth/server.ts +6 -0
  19. package/src/auth/utils/errors.ts +34 -0
  20. package/src/auth/utils/index.ts +2 -0
  21. package/src/auth/utils/validation.ts +14 -0
  22. package/src/index.ts +15 -0
  23. package/src/layouts/AppLayout/AppLayout.tsx +123 -0
  24. package/src/layouts/AppLayout/README.md +204 -0
  25. package/src/layouts/AppLayout/SUMMARY.md +240 -0
  26. package/src/layouts/AppLayout/USAGE.md +312 -0
  27. package/src/layouts/AppLayout/components/PageProgress.tsx +104 -0
  28. package/src/layouts/AppLayout/components/Seo.tsx +87 -0
  29. package/src/layouts/AppLayout/components/index.ts +6 -0
  30. package/src/layouts/AppLayout/context/AppContext.tsx +146 -0
  31. package/src/layouts/AppLayout/context/index.ts +5 -0
  32. package/src/layouts/AppLayout/hooks/index.ts +6 -0
  33. package/src/layouts/AppLayout/hooks/useLayoutMode.ts +26 -0
  34. package/src/layouts/AppLayout/hooks/useNavigation.ts +49 -0
  35. package/src/layouts/AppLayout/index.ts +31 -0
  36. package/src/layouts/AppLayout/layouts/AuthLayout/AuthContext.tsx +51 -0
  37. package/src/layouts/AppLayout/layouts/AuthLayout/AuthHelp.tsx +111 -0
  38. package/src/layouts/AppLayout/layouts/AuthLayout/AuthLayout.tsx +40 -0
  39. package/src/layouts/AppLayout/layouts/AuthLayout/IdentifierForm.tsx +330 -0
  40. package/src/layouts/AppLayout/layouts/AuthLayout/OTPForm.tsx +158 -0
  41. package/src/layouts/AppLayout/layouts/AuthLayout/index.ts +13 -0
  42. package/src/layouts/AppLayout/layouts/AuthLayout/types.ts +61 -0
  43. package/src/layouts/AppLayout/layouts/PrivateLayout/PrivateLayout.tsx +92 -0
  44. package/src/layouts/AppLayout/layouts/PrivateLayout/components/DashboardContent.tsx +60 -0
  45. package/src/layouts/AppLayout/layouts/PrivateLayout/components/DashboardHeader.tsx +170 -0
  46. package/src/layouts/AppLayout/layouts/PrivateLayout/components/DashboardSidebar.tsx +164 -0
  47. package/src/layouts/AppLayout/layouts/PrivateLayout/components/index.ts +7 -0
  48. package/src/layouts/AppLayout/layouts/PrivateLayout/index.ts +5 -0
  49. package/src/layouts/AppLayout/layouts/PublicLayout/PublicLayout.tsx +44 -0
  50. package/src/layouts/AppLayout/layouts/PublicLayout/components/DesktopUserMenu.tsx +136 -0
  51. package/src/layouts/AppLayout/layouts/PublicLayout/components/Footer.tsx +262 -0
  52. package/src/layouts/AppLayout/layouts/PublicLayout/components/MobileMenu.tsx +289 -0
  53. package/src/layouts/AppLayout/layouts/PublicLayout/components/Navigation.tsx +159 -0
  54. package/src/layouts/AppLayout/layouts/PublicLayout/index.ts +5 -0
  55. package/src/layouts/AppLayout/layouts/index.ts +7 -0
  56. package/src/layouts/AppLayout/providers/CoreProviders.tsx +47 -0
  57. package/src/layouts/AppLayout/providers/index.ts +5 -0
  58. package/src/layouts/AppLayout/types/config.ts +40 -0
  59. package/src/layouts/AppLayout/types/index.ts +10 -0
  60. package/src/layouts/AppLayout/types/layout.ts +47 -0
  61. package/src/layouts/AppLayout/types/navigation.ts +41 -0
  62. package/src/layouts/AppLayout/types/routes.ts +45 -0
  63. package/src/layouts/AppLayout/utils/index.ts +5 -0
  64. package/src/layouts/AppLayout/utils/routeDetection.ts +31 -0
  65. package/src/layouts/PaymentsLayout/PaymentsLayout.tsx +125 -0
  66. package/src/layouts/PaymentsLayout/README.md +133 -0
  67. package/src/layouts/PaymentsLayout/components/CreateApiKeyDialog.tsx +172 -0
  68. package/src/layouts/PaymentsLayout/components/CreatePaymentDialog.tsx +203 -0
  69. package/src/layouts/PaymentsLayout/components/DeleteApiKeyDialog.tsx +100 -0
  70. package/src/layouts/PaymentsLayout/components/index.ts +4 -0
  71. package/src/layouts/PaymentsLayout/events.ts +106 -0
  72. package/src/layouts/PaymentsLayout/index.ts +20 -0
  73. package/src/layouts/PaymentsLayout/types.ts +19 -0
  74. package/src/layouts/PaymentsLayout/views/apikeys/components/ApiKeyMetrics.tsx +109 -0
  75. package/src/layouts/PaymentsLayout/views/apikeys/components/ApiKeysList.tsx +194 -0
  76. package/src/layouts/PaymentsLayout/views/apikeys/components/index.ts +3 -0
  77. package/src/layouts/PaymentsLayout/views/apikeys/index.tsx +19 -0
  78. package/src/layouts/PaymentsLayout/views/overview/components/BalanceCard.tsx +99 -0
  79. package/src/layouts/PaymentsLayout/views/overview/components/MetricsCards.tsx +103 -0
  80. package/src/layouts/PaymentsLayout/views/overview/components/RecentPayments.tsx +138 -0
  81. package/src/layouts/PaymentsLayout/views/overview/components/index.ts +4 -0
  82. package/src/layouts/PaymentsLayout/views/overview/index.tsx +23 -0
  83. package/src/layouts/PaymentsLayout/views/payments/components/PaymentsList.tsx +282 -0
  84. package/src/layouts/PaymentsLayout/views/payments/components/index.ts +2 -0
  85. package/src/layouts/PaymentsLayout/views/payments/index.tsx +18 -0
  86. package/src/layouts/PaymentsLayout/views/tariffs/index.tsx +29 -0
  87. package/src/layouts/PaymentsLayout/views/transactions/index.tsx +29 -0
  88. package/src/layouts/ProfileLayout/ProfileLayout.tsx +110 -0
  89. package/src/layouts/ProfileLayout/components/AvatarSection.tsx +146 -0
  90. package/src/layouts/ProfileLayout/components/ProfileForm.tsx +208 -0
  91. package/src/layouts/ProfileLayout/components/index.ts +3 -0
  92. package/src/layouts/ProfileLayout/index.ts +3 -0
  93. package/src/layouts/SupportLayout/README.md +91 -0
  94. package/src/layouts/SupportLayout/SupportLayout.tsx +178 -0
  95. package/src/layouts/SupportLayout/components/CreateTicketDialog.tsx +154 -0
  96. package/src/layouts/SupportLayout/components/MessageInput.tsx +92 -0
  97. package/src/layouts/SupportLayout/components/MessageList.tsx +312 -0
  98. package/src/layouts/SupportLayout/components/TicketCard.tsx +96 -0
  99. package/src/layouts/SupportLayout/components/TicketList.tsx +152 -0
  100. package/src/layouts/SupportLayout/components/index.ts +6 -0
  101. package/src/layouts/SupportLayout/context/SupportLayoutContext.tsx +260 -0
  102. package/src/layouts/SupportLayout/context/index.ts +2 -0
  103. package/src/layouts/SupportLayout/events.ts +31 -0
  104. package/src/layouts/SupportLayout/hooks/index.ts +2 -0
  105. package/src/layouts/SupportLayout/hooks/useInfiniteMessages.ts +118 -0
  106. package/src/layouts/SupportLayout/hooks/useInfiniteTickets.ts +91 -0
  107. package/src/layouts/SupportLayout/index.ts +6 -0
  108. package/src/layouts/SupportLayout/types.ts +23 -0
  109. package/src/layouts/index.ts +9 -0
  110. package/src/snippets/AuthDialog/AuthDialog.tsx +88 -0
  111. package/src/snippets/AuthDialog/events.ts +21 -0
  112. package/src/snippets/AuthDialog/index.ts +3 -0
  113. package/src/snippets/AuthDialog/useAuthDialog.ts +27 -0
  114. package/src/snippets/Breadcrumbs.tsx +80 -0
  115. package/src/snippets/Chat/ChatUIContext.tsx +110 -0
  116. package/src/snippets/Chat/ChatWidget.tsx +476 -0
  117. package/src/snippets/Chat/README.md +122 -0
  118. package/src/snippets/Chat/components/MessageInput.tsx +124 -0
  119. package/src/snippets/Chat/components/MessageList.tsx +168 -0
  120. package/src/snippets/Chat/components/SessionList.tsx +192 -0
  121. package/src/snippets/Chat/components/index.ts +9 -0
  122. package/src/snippets/Chat/hooks/index.ts +6 -0
  123. package/src/snippets/Chat/hooks/useInfiniteSessions.ts +83 -0
  124. package/src/snippets/Chat/index.tsx +44 -0
  125. package/src/snippets/Chat/types.ts +79 -0
  126. package/src/snippets/VideoPlayer/README.md +203 -0
  127. package/src/snippets/VideoPlayer/VideoControls.tsx +133 -0
  128. package/src/snippets/VideoPlayer/VideoPlayer.tsx +114 -0
  129. package/src/snippets/VideoPlayer/index.ts +8 -0
  130. package/src/snippets/VideoPlayer/types.ts +61 -0
  131. package/src/snippets/index.ts +10 -0
  132. package/src/styles/dashboard.css +41 -0
  133. package/src/styles/index.css +20 -0
  134. package/src/styles/sources.css +6 -0
  135. package/src/types/index.ts +1 -0
  136. package/src/types/pageConfig.ts +103 -0
  137. package/src/utils/index.ts +6 -0
  138. 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,6 @@
1
+ /**
2
+ * Utils - Utility functions and helpers
3
+ */
4
+
5
+ export * from './logger';
6
+
@@ -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;