@djangocfg/layouts 2.1.227 → 2.1.228

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 (97) hide show
  1. package/README.md +3 -17
  2. package/package.json +18 -18
  3. package/src/components/errors/ErrorLayout.tsx +2 -2
  4. package/src/components/errors/ErrorsTracker/index.ts +1 -0
  5. package/src/components/errors/ErrorsTracker/utils/formatters.ts +23 -1
  6. package/src/hooks/useLogout.ts +9 -12
  7. package/src/layouts/AppLayout/AppLayout.tsx +20 -8
  8. package/src/layouts/AppLayout/BaseApp.tsx +5 -28
  9. package/src/layouts/AuthLayout/AuthLayout.tsx +51 -22
  10. package/src/layouts/AuthLayout/README.md +78 -0
  11. package/src/layouts/AuthLayout/components/shared/AuthDivider.tsx +2 -2
  12. package/src/layouts/AuthLayout/components/shared/AuthError.tsx +10 -2
  13. package/src/layouts/AuthLayout/components/shared/AuthFooter.tsx +2 -2
  14. package/src/layouts/AuthLayout/components/shared/AuthHeader.tsx +3 -2
  15. package/src/layouts/AuthLayout/components/shared/AuthOTPInput.tsx +4 -1
  16. package/src/layouts/AuthLayout/components/shared/TermsCheckbox.tsx +2 -2
  17. package/src/layouts/AuthLayout/components/shared/index.ts +0 -2
  18. package/src/layouts/AuthLayout/components/steps/IdentifierStep.tsx +25 -80
  19. package/src/layouts/AuthLayout/components/steps/OTPStep.tsx +8 -13
  20. package/src/layouts/AuthLayout/components/steps/SetupStep/SetupComplete.tsx +2 -2
  21. package/src/layouts/AuthLayout/components/steps/SetupStep/SetupLoading.tsx +2 -2
  22. package/src/layouts/AuthLayout/components/steps/SetupStep/SetupQRCode.tsx +2 -2
  23. package/src/layouts/AuthLayout/components/steps/TwoFactorStep.tsx +61 -42
  24. package/src/layouts/AuthLayout/context.tsx +0 -2
  25. package/src/layouts/AuthLayout/index.ts +9 -6
  26. package/src/layouts/AuthLayout/styles/auth.css +265 -120
  27. package/src/layouts/AuthLayout/types.ts +60 -7
  28. package/src/layouts/ProfileLayout/.claude/.sidecar/activity.jsonl +2 -0
  29. package/src/layouts/ProfileLayout/.claude/.sidecar/history/2026-03-15.md +35 -0
  30. package/src/layouts/ProfileLayout/.claude/.sidecar/review.md +35 -0
  31. package/src/layouts/ProfileLayout/.claude/.sidecar/scan.log +3 -0
  32. package/src/layouts/ProfileLayout/.claude/.sidecar/tasks/T-001.md +18 -0
  33. package/src/layouts/ProfileLayout/.claude/.sidecar/tasks/T-002.md +19 -0
  34. package/src/layouts/ProfileLayout/.claude/.sidecar/tasks/T-003.md +18 -0
  35. package/src/layouts/ProfileLayout/.claude/.sidecar/tasks/T-004.md +18 -0
  36. package/src/layouts/ProfileLayout/.claude/.sidecar/tasks/T-005.md +18 -0
  37. package/src/layouts/ProfileLayout/.claude/.sidecar/usage.json +5 -0
  38. package/src/layouts/ProfileLayout/ProfileLayout.tsx +52 -403
  39. package/src/layouts/ProfileLayout/components/ActionButton.tsx +38 -0
  40. package/src/layouts/ProfileLayout/components/DeleteAccountSection.tsx +109 -148
  41. package/src/layouts/ProfileLayout/components/EditableField.tsx +119 -0
  42. package/src/layouts/ProfileLayout/components/Section.tsx +22 -0
  43. package/src/layouts/ProfileLayout/components/index.ts +4 -1
  44. package/src/layouts/ProfileLayout/context.tsx +31 -0
  45. package/src/layouts/PublicLayout/components/PublicMobileDrawer.tsx +2 -2
  46. package/src/layouts/PublicLayout/components/PublicNavigation.tsx +2 -2
  47. package/src/layouts/_components/UserMenu.tsx +2 -2
  48. package/src/layouts/types/README.md +0 -20
  49. package/src/layouts/types/index.ts +2 -2
  50. package/src/layouts/types/layout.types.ts +2 -5
  51. package/src/layouts/types/providers.types.ts +0 -27
  52. package/src/snippets/AuthDialog/AuthDialog.tsx +2 -2
  53. package/src/snippets/Breadcrumbs.tsx +2 -2
  54. package/src/snippets/index.ts +0 -67
  55. package/src/layouts/AuthLayout/components/shared/ChannelToggle.tsx +0 -56
  56. package/src/snippets/McpChat/README.md +0 -441
  57. package/src/snippets/McpChat/components/AIChatWidget.tsx +0 -361
  58. package/src/snippets/McpChat/components/AskAIButton.tsx +0 -92
  59. package/src/snippets/McpChat/components/ChatMessages.tsx +0 -138
  60. package/src/snippets/McpChat/components/ChatPanel.tsx +0 -131
  61. package/src/snippets/McpChat/components/ChatSidebar.tsx +0 -156
  62. package/src/snippets/McpChat/components/ChatWidget.tsx +0 -115
  63. package/src/snippets/McpChat/components/MessageBubble.tsx +0 -142
  64. package/src/snippets/McpChat/components/MessageInput.tsx +0 -140
  65. package/src/snippets/McpChat/components/index.ts +0 -24
  66. package/src/snippets/McpChat/config.ts +0 -94
  67. package/src/snippets/McpChat/context/AIChatContext.tsx +0 -327
  68. package/src/snippets/McpChat/context/ChatContext.tsx +0 -361
  69. package/src/snippets/McpChat/context/index.ts +0 -7
  70. package/src/snippets/McpChat/hooks/index.ts +0 -6
  71. package/src/snippets/McpChat/hooks/useAIChat.ts +0 -503
  72. package/src/snippets/McpChat/hooks/useChatLayout.ts +0 -442
  73. package/src/snippets/McpChat/hooks/useMcpChat.ts +0 -90
  74. package/src/snippets/McpChat/index.ts +0 -79
  75. package/src/snippets/McpChat/types.ts +0 -189
  76. package/src/snippets/PWAInstall/@docs/README.md +0 -92
  77. package/src/snippets/PWAInstall/@docs/research/ios-android-install-flows.md +0 -576
  78. package/src/snippets/PWAInstall/README.md +0 -235
  79. package/src/snippets/PWAInstall/components/A2HSHint.tsx +0 -236
  80. package/src/snippets/PWAInstall/components/DesktopGuide.tsx +0 -234
  81. package/src/snippets/PWAInstall/components/IOSGuide.tsx +0 -29
  82. package/src/snippets/PWAInstall/components/IOSGuideDrawer.tsx +0 -103
  83. package/src/snippets/PWAInstall/components/IOSGuideModal.tsx +0 -103
  84. package/src/snippets/PWAInstall/components/PWAPageResumeManager.tsx +0 -33
  85. package/src/snippets/PWAInstall/context/InstallContext.tsx +0 -102
  86. package/src/snippets/PWAInstall/hooks/useInstallPrompt.ts +0 -168
  87. package/src/snippets/PWAInstall/hooks/useIsPWA.ts +0 -116
  88. package/src/snippets/PWAInstall/hooks/usePWAPageResume.ts +0 -163
  89. package/src/snippets/PWAInstall/index.ts +0 -80
  90. package/src/snippets/PWAInstall/types/components.ts +0 -95
  91. package/src/snippets/PWAInstall/types/config.ts +0 -29
  92. package/src/snippets/PWAInstall/types/index.ts +0 -26
  93. package/src/snippets/PWAInstall/types/install.ts +0 -38
  94. package/src/snippets/PWAInstall/types/platform.ts +0 -29
  95. package/src/snippets/PWAInstall/utils/localStorage.ts +0 -181
  96. package/src/snippets/PWAInstall/utils/logger.ts +0 -149
  97. package/src/snippets/PWAInstall/utils/platform.ts +0 -151
@@ -12,71 +12,4 @@ export * from './Analytics';
12
12
  export { MonitorProvider } from '@djangocfg/monitor/client';
13
13
  export type { MonitorProviderProps } from '@djangocfg/monitor/client';
14
14
 
15
- // MCP Chat (AI-powered documentation assistant)
16
- export {
17
- AIChatWidget,
18
- ChatPanel,
19
- MessageBubble,
20
- AIMessageInput,
21
- AIChatProvider,
22
- useAIChatContext,
23
- useAIChatContextOptional,
24
- useAIChat,
25
- useChatLayout,
26
- useMcpChat,
27
- AskAIButton,
28
- } from './McpChat';
29
- export type {
30
- AIChatWidgetProps,
31
- MessageBubbleProps,
32
- AIMessageInputProps,
33
- AIChatContextState,
34
- AIChatContextActions,
35
- AIChatContextValue,
36
- AIChatProviderProps,
37
- ChatLayoutConfig,
38
- UseChatLayoutReturn,
39
- AIChatMessage,
40
- AIChatSource,
41
- AIMessageRole,
42
- AIChatApiResponse,
43
- UseAIChatOptions,
44
- UseAIChatReturn,
45
- ChatWidgetConfig,
46
- McpChatContextType,
47
- McpChatEventDetail,
48
- UseMcpChatReturn,
49
- AskAIButtonProps,
50
- } from './McpChat';
51
-
52
- // PWA Install (Progressive Web App Installation)
53
- export {
54
- PwaProvider,
55
- useInstall,
56
- A2HSHint,
57
- IOSGuide,
58
- DesktopGuide,
59
- useIsPWA,
60
- clearIsPWACache,
61
- clearAllPWAInstallData,
62
- isStandalone,
63
- isStandaloneReliable,
64
- isMobileDevice,
65
- hasValidManifest,
66
- getDisplayMode,
67
- onDisplayModeChange,
68
- } from './PWAInstall';
69
- export type {
70
- PlatformInfo,
71
- InstallPromptState,
72
- BeforeInstallPromptEvent,
73
- InstallOutcome,
74
- IOSGuideState,
75
- InstallContextType,
76
- InstallManagerProps,
77
- AndroidInstallButtonProps,
78
- IOSGuideModalProps,
79
- InstallStep,
80
- UseIsPWAOptions,
81
- } from './PWAInstall';
82
15
 
@@ -1,56 +0,0 @@
1
- 'use client';
2
-
3
- import { Mail, Phone } from 'lucide-react';
4
- import React, { useMemo } from 'react';
5
-
6
- import { useTypedT, type I18nTranslations } from '@djangocfg/i18n';
7
-
8
- import type { AuthChannel } from '../../types';
9
-
10
- export interface ChannelToggleProps {
11
- channel: AuthChannel;
12
- onChange: (channel: AuthChannel) => void;
13
- disabled?: boolean;
14
- className?: string;
15
- }
16
-
17
- /**
18
- * ChannelToggle - Apple-style segmented control for email/phone
19
- */
20
- export const ChannelToggle: React.FC<ChannelToggleProps> = ({
21
- channel,
22
- onChange,
23
- disabled = false,
24
- className = '',
25
- }) => {
26
- const t = useTypedT<I18nTranslations>();
27
- const labels = useMemo(() => ({
28
- email: t('layouts.auth.identifier.channel.email'),
29
- phone: t('layouts.auth.identifier.channel.phone'),
30
- }), [t]);
31
-
32
- return (
33
- <div className={`auth-channel-toggle ${className}`}>
34
- <button
35
- type="button"
36
- className="auth-channel-option"
37
- data-active={channel === 'email'}
38
- onClick={() => onChange('email')}
39
- disabled={disabled}
40
- >
41
- <Mail />
42
- {labels.email}
43
- </button>
44
- <button
45
- type="button"
46
- className="auth-channel-option"
47
- data-active={channel === 'phone'}
48
- onClick={() => onChange('phone')}
49
- disabled={disabled}
50
- >
51
- <Phone />
52
- {labels.phone}
53
- </button>
54
- </div>
55
- );
56
- };
@@ -1,441 +0,0 @@
1
- # MCP Chat - AI Assistant Integration
2
-
3
- AI-powered chat widget with global trigger system for seamless integration throughout your application.
4
-
5
- ## Features
6
-
7
- - 🎯 **Global Trigger System** - Call chat from anywhere using `useMcpChat()` hook
8
- - 🤖 **Simple AI Button** - Universal `AskAIButton` component with AI assistant icon
9
- - 💬 **Multiple Display Modes** - Floating panel, sidebar, or closed
10
- - 🔄 **Streaming Responses** - Real-time AI responses
11
- - 📱 **Mobile Responsive** - Optimized for all devices
12
- - 🎭 **Context-Aware** - Send structured context with messages
13
- - 🔌 **Easy Integration** - Drop-in component with minimal setup
14
-
15
- ## Quick Start
16
-
17
- ### 1. Setup Provider (once in your app)
18
-
19
- ```tsx
20
- // app/layout.tsx
21
- import { AIChatProvider, AIChatWidget } from '@djangocfg/layouts/snippets/McpChat';
22
-
23
- export default function RootLayout({ children }) {
24
- return (
25
- <html>
26
- <body>
27
- <AIChatProvider>
28
- {children}
29
- <AIChatWidget />
30
- </AIChatProvider>
31
- </body>
32
- </html>
33
- );
34
- }
35
- ```
36
-
37
- ### 2. Use Anywhere
38
-
39
- #### Option A: Ready-to-use Button (Recommended)
40
-
41
- ```tsx
42
- import { AskAIButton } from '@djangocfg/layouts/snippets/McpChat';
43
-
44
- // Simple usage
45
- <AskAIButton message="Explain this feature">
46
- Ask AI
47
- </AskAIButton>
48
-
49
- // With context data
50
- <AskAIButton
51
- message="Why is this failing?"
52
- contextData={{ error: error.stack, component: 'UserForm' }}
53
- source="ErrorBoundary"
54
- >
55
- Explain error
56
- </AskAIButton>
57
-
58
- // Custom styling
59
- <AskAIButton
60
- message="Help me optimize this"
61
- contextData={{ topic: "database-performance" }}
62
- variant="default"
63
- size="lg"
64
- >
65
- Get advice
66
- </AskAIButton>
67
- ```
68
-
69
- #### Option B: Custom Hook
70
-
71
- ```tsx
72
- import { useMcpChat } from '@djangocfg/layouts/snippets/McpChat';
73
-
74
- function MyComponent() {
75
- const { sendToChat } = useMcpChat();
76
-
77
- const handleClick = () => {
78
- sendToChat({
79
- message: 'Explain this error',
80
- context: {
81
- data: { error: errorDetails },
82
- source: 'MyComponent'
83
- }
84
- });
85
- };
86
-
87
- return <button onClick={handleClick}>Ask AI</button>;
88
- }
89
- ```
90
-
91
- ## Components
92
-
93
- ### AskAIButton
94
-
95
- Universal AI chat trigger button with Bot icon:
96
-
97
- ```tsx
98
- <AskAIButton
99
- message="Your question or prompt"
100
- contextData={{ /* optional context */ }}
101
- source="ComponentName"
102
- variant="outline"
103
- size="default"
104
- >
105
- Button text
106
- </AskAIButton>
107
- ```
108
-
109
- **Props:**
110
- - `message` - Question or prompt to send to AI (required)
111
- - `contextData` - Additional context object (optional)
112
- - `source` - Source component name for tracking (optional)
113
- - `autoSend` - Auto-send message after opening (default: `true`)
114
- - `showIcon` - Show Bot icon (default: `true`)
115
- - All standard Button props (`variant`, `size`, `className`, etc.)
116
-
117
- ### useMcpChat Hook
118
-
119
- Custom hook for programmatic chat triggering:
120
-
121
- ```tsx
122
- const { sendToChat, isChatAvailable } = useMcpChat();
123
-
124
- sendToChat({
125
- message: 'Your message',
126
- context: {
127
- data: { /* contextual data */ },
128
- source: 'ComponentName'
129
- },
130
- autoSend: true,
131
- displayMode: 'floating' | 'sidebar'
132
- });
133
- ```
134
-
135
- ## Real-World Examples
136
-
137
- ### Error Handling
138
-
139
- ```tsx
140
- function ErrorBoundary({ error, children }) {
141
- if (error) {
142
- return (
143
- <div>
144
- <h2>Error: {error.message}</h2>
145
- <AskAIButton
146
- message="Explain this error and how to fix it"
147
- contextData={{
148
- error: error.message,
149
- stack: error.stack,
150
- component: 'UserForm'
151
- }}
152
- source="ErrorBoundary"
153
- >
154
- Explain error
155
- </AskAIButton>
156
- </div>
157
- );
158
- }
159
- return children;
160
- }
161
- ```
162
-
163
- ### Feature Documentation
164
-
165
- ```tsx
166
- function FeatureCard({ feature }) {
167
- return (
168
- <Card>
169
- <CardHeader>{feature.name}</CardHeader>
170
- <CardContent>{feature.description}</CardContent>
171
- <CardFooter>
172
- <AskAIButton
173
- message={`Explain how ${feature.name} works`}
174
- contextData={{
175
- feature: feature.name,
176
- version: feature.version
177
- }}
178
- source="FeatureCard"
179
- >
180
- Learn more
181
- </AskAIButton>
182
- </CardFooter>
183
- </Card>
184
- );
185
- }
186
- ```
187
-
188
- ### Settings Page
189
-
190
- ```tsx
191
- function DatabaseSettings() {
192
- return (
193
- <div>
194
- <h3>Database Configuration</h3>
195
- <form>{/* form fields */}</form>
196
- <AskAIButton
197
- message="What are the best practices for PostgreSQL optimization?"
198
- contextData={{
199
- topic: "database-optimization",
200
- dbType: "PostgreSQL"
201
- }}
202
- source="DatabaseSettings"
203
- >
204
- Get tips
205
- </AskAIButton>
206
- </div>
207
- );
208
- }
209
- ```
210
-
211
- ### Pricing Comparison
212
-
213
- ```tsx
214
- function PricingSection() {
215
- return (
216
- <div>
217
- {/* pricing cards */}
218
- <AskAIButton
219
- message="Which package is right for my team?"
220
- contextData={{
221
- packages: ["starter", "professional", "enterprise"],
222
- intent: "decision-making"
223
- }}
224
- source="PricingSection"
225
- >
226
- Which package?
227
- </AskAIButton>
228
- </div>
229
- );
230
- }
231
- ```
232
-
233
- ### Installation Help
234
-
235
- ```tsx
236
- function QuickStart() {
237
- return (
238
- <div>
239
- <h2>Installation</h2>
240
- <pre>{installCommands}</pre>
241
- <AskAIButton
242
- message="I need help with Django-CFG installation"
243
- contextData={{
244
- topic: "installation",
245
- os: detectedOS
246
- }}
247
- source="QuickStart"
248
- >
249
- Installation help?
250
- </AskAIButton>
251
- </div>
252
- );
253
- }
254
- ```
255
-
256
- ## Architecture
257
-
258
- ```
259
- ┌─────────────────────────────────────┐
260
- │ Any Component │
261
- │ ┌──────────────────────────────┐ │
262
- │ │ AskAIButton / useMcpChat() │ │
263
- │ │ sendToChat({ message, ... }) │ │
264
- │ └──────────────┬───────────────┘ │
265
- └─────────────────┼───────────────────┘
266
-
267
- │ CustomEvent
268
- │ 'mcp:chat:send'
269
-
270
- ┌─────────────────────────────────────┐
271
- │ AIChatProvider (Event Listener) │
272
- │ ┌──────────────────────────────┐ │
273
- │ │ 1. Receives event │ │
274
- │ │ 2. Sends confirmation │ │
275
- │ │ 3. Opens chat │ │
276
- │ │ 4. Sends message to AI │ │
277
- │ └──────────────────────────────┘ │
278
- └─────────────────────────────────────┘
279
-
280
-
281
- ┌─────────────────────────────────────┐
282
- │ AIChatWidget (UI) │
283
- │ - Floating panel or sidebar │
284
- │ - Message display │
285
- │ - Streaming responses │
286
- └─────────────────────────────────────┘
287
- ```
288
-
289
- ## API
290
-
291
- ### AskAIButton Props
292
-
293
- ```tsx
294
- interface AskAIButtonProps extends ButtonProps {
295
- /** Message to send to AI */
296
- message: string;
297
- /** Additional context data */
298
- contextData?: Record<string, any>;
299
- /** Source component name */
300
- source?: string;
301
- /** Auto-send message (default: true) */
302
- autoSend?: boolean;
303
- /** Show icon (default: true) */
304
- showIcon?: boolean;
305
- /** Callback after sending */
306
- onSent?: () => void;
307
- }
308
- ```
309
-
310
- ### McpChatEventDetail
311
-
312
- ```tsx
313
- interface McpChatEventDetail {
314
- message: string;
315
- context?: {
316
- data?: Record<string, any>;
317
- source?: string;
318
- };
319
- autoSend?: boolean;
320
- displayMode?: 'floating' | 'sidebar' | 'closed';
321
- }
322
- ```
323
-
324
- ### UseMcpChatReturn
325
-
326
- ```tsx
327
- interface UseMcpChatReturn {
328
- /** Send message to chat */
329
- sendToChat: (detail: McpChatEventDetail) => void;
330
- /** Check if chat is available */
331
- isChatAvailable: () => boolean;
332
- }
333
- ```
334
-
335
- ## Best Practices
336
-
337
- 1. **Always provide source** - Helps track where requests come from
338
- ```tsx
339
- <AskAIButton message="..." source="ComponentName">
340
- ```
341
-
342
- 2. **Include contextData** - More context = better AI responses
343
- ```tsx
344
- <AskAIButton
345
- message="..."
346
- contextData={{ feature: "auth", version: "2.0" }}
347
- >
348
- ```
349
-
350
- 3. **Keep messages clear** - Write clear questions or prompts
351
- ```tsx
352
- // Good
353
- message="Why is Django faster than FastAPI in enterprise scenarios?"
354
-
355
- // Too vague
356
- message="Explain this"
357
- ```
358
-
359
- 4. **Short button labels** - Keep button text concise (max 3 words)
360
- ```tsx
361
- <AskAIButton message="...">
362
- Explain this {/* Good */}
363
- </AskAIButton>
364
- ```
365
-
366
- 5. **Check availability** - Use `isChatAvailable()` for conditional UI
367
- ```tsx
368
- const { isChatAvailable } = useMcpChat();
369
- if (!isChatAvailable()) {
370
- return <p>Chat loading...</p>;
371
- }
372
- ```
373
-
374
- ## Error Handling
375
-
376
- If chat is not available:
377
- - Console error logged
378
- - Alert shown to user
379
- - Button automatically disabled
380
-
381
- ```tsx
382
- const { sendToChat, isChatAvailable } = useMcpChat();
383
-
384
- if (!isChatAvailable()) {
385
- console.log('Chat not loaded');
386
- }
387
- ```
388
-
389
- ## TypeScript Support
390
-
391
- Fully typed with TypeScript for excellent IDE support:
392
-
393
- ```tsx
394
- import type {
395
- McpChatEventDetail,
396
- UseMcpChatReturn,
397
- AskAIButtonProps
398
- } from '@djangocfg/layouts/snippets/McpChat';
399
- ```
400
-
401
- ## Common Use Cases
402
-
403
- ### Documentation Pages
404
- ```tsx
405
- <AskAIButton message="How do I set this up?">
406
- Setup help?
407
- </AskAIButton>
408
- ```
409
-
410
- ### Comparison Tables
411
- ```tsx
412
- <AskAIButton message="Why is option A better than option B?">
413
- Explain difference
414
- </AskAIButton>
415
- ```
416
-
417
- ### Feature Sections
418
- ```tsx
419
- <AskAIButton message="Which features should I explore first?">
420
- Explore features?
421
- </AskAIButton>
422
- ```
423
-
424
- ### Benchmarks
425
- ```tsx
426
- <AskAIButton message="Why is this faster in production?">
427
- Explain benchmarks?
428
- </AskAIButton>
429
- ```
430
-
431
- ## Contributing
432
-
433
- When adding new features:
434
- 1. Update type definitions in `types.ts`
435
- 2. Add examples to this README
436
- 3. Test with different scenarios
437
- 4. Keep the API simple and consistent
438
-
439
- ## License
440
-
441
- MIT - Part of DjangoCFG project