@djangocfg/ui-nextjs 2.1.90 → 2.1.92
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/README.md +6 -15
- package/package.json +6 -25
- package/src/blocks/SplitHero/SplitHeroMedia.tsx +1 -1
- package/src/components/index.ts +0 -40
- package/src/hooks/index.ts +0 -6
- package/src/index.ts +2 -11
- package/src/components/button-download.tsx +0 -277
- package/src/components/markdown/MarkdownMessage.tsx +0 -340
- package/src/components/markdown/index.ts +0 -5
- package/src/components/menubar.tsx +0 -275
- package/src/components/multi-select-pro/async.tsx +0 -598
- package/src/components/multi-select-pro/helpers.tsx +0 -84
- package/src/components/multi-select-pro/index.tsx +0 -612
- package/src/components/navigation-menu.tsx +0 -154
- package/src/components/otp/index.tsx +0 -197
- package/src/components/otp/types.ts +0 -133
- package/src/components/otp/use-otp-input.ts +0 -225
- package/src/components/phone-input.tsx +0 -277
- package/src/components/sonner.tsx +0 -32
- package/src/hooks/useLocalStorage.ts +0 -300
- package/src/hooks/useSessionStorage.ts +0 -290
- package/src/lib/index.ts +0 -5
- package/src/lib/logger/index.ts +0 -10
- package/src/lib/logger/logStore.ts +0 -122
- package/src/lib/logger/logger.ts +0 -175
- package/src/lib/logger/types.ts +0 -82
- package/src/stores/index.ts +0 -8
- package/src/stores/mediaCache.ts +0 -534
- package/src/tools/AudioPlayer/README.md +0 -206
- package/src/tools/AudioPlayer/components/HybridAudioPlayer.tsx +0 -216
- package/src/tools/AudioPlayer/components/HybridSimplePlayer.tsx +0 -280
- package/src/tools/AudioPlayer/components/HybridWaveform.tsx +0 -279
- package/src/tools/AudioPlayer/components/ReactiveCover/AudioReactiveCover.tsx +0 -149
- package/src/tools/AudioPlayer/components/ReactiveCover/effects/GlowEffect.tsx +0 -110
- package/src/tools/AudioPlayer/components/ReactiveCover/effects/MeshEffect.tsx +0 -58
- package/src/tools/AudioPlayer/components/ReactiveCover/effects/OrbsEffect.tsx +0 -45
- package/src/tools/AudioPlayer/components/ReactiveCover/effects/SpotlightEffect.tsx +0 -82
- package/src/tools/AudioPlayer/components/ReactiveCover/effects/index.ts +0 -8
- package/src/tools/AudioPlayer/components/ReactiveCover/index.ts +0 -6
- package/src/tools/AudioPlayer/components/index.ts +0 -22
- package/src/tools/AudioPlayer/context/HybridAudioProvider.tsx +0 -158
- package/src/tools/AudioPlayer/context/index.ts +0 -16
- package/src/tools/AudioPlayer/effects/index.ts +0 -412
- package/src/tools/AudioPlayer/hooks/index.ts +0 -35
- package/src/tools/AudioPlayer/hooks/useHybridAudio.ts +0 -387
- package/src/tools/AudioPlayer/hooks/useHybridAudioAnalysis.ts +0 -95
- package/src/tools/AudioPlayer/hooks/useVisualization.tsx +0 -207
- package/src/tools/AudioPlayer/index.ts +0 -133
- package/src/tools/AudioPlayer/types/effects.ts +0 -73
- package/src/tools/AudioPlayer/types/index.ts +0 -27
- package/src/tools/AudioPlayer/utils/debug.ts +0 -14
- package/src/tools/AudioPlayer/utils/formatTime.ts +0 -10
- package/src/tools/AudioPlayer/utils/index.ts +0 -6
- package/src/tools/ImageViewer/@refactoring/00-PLAN.md +0 -71
- package/src/tools/ImageViewer/@refactoring/01-TYPES.md +0 -121
- package/src/tools/ImageViewer/@refactoring/02-UTILS.md +0 -143
- package/src/tools/ImageViewer/@refactoring/03-HOOKS.md +0 -261
- package/src/tools/ImageViewer/@refactoring/04-COMPONENTS.md +0 -427
- package/src/tools/ImageViewer/@refactoring/05-EXECUTION-CHECKLIST.md +0 -126
- package/src/tools/ImageViewer/README.md +0 -200
- package/src/tools/ImageViewer/components/ImageInfo.tsx +0 -44
- package/src/tools/ImageViewer/components/ImageToolbar.tsx +0 -150
- package/src/tools/ImageViewer/components/ImageViewer.tsx +0 -241
- package/src/tools/ImageViewer/components/index.ts +0 -7
- package/src/tools/ImageViewer/hooks/index.ts +0 -9
- package/src/tools/ImageViewer/hooks/useImageLoading.ts +0 -204
- package/src/tools/ImageViewer/hooks/useImageTransform.ts +0 -101
- package/src/tools/ImageViewer/index.ts +0 -60
- package/src/tools/ImageViewer/types.ts +0 -81
- package/src/tools/ImageViewer/utils/constants.ts +0 -59
- package/src/tools/ImageViewer/utils/debug.ts +0 -14
- package/src/tools/ImageViewer/utils/index.ts +0 -17
- package/src/tools/ImageViewer/utils/lqip.ts +0 -47
- package/src/tools/JsonForm/JsonSchemaForm.tsx +0 -197
- package/src/tools/JsonForm/examples/BotConfigExample.tsx +0 -249
- package/src/tools/JsonForm/examples/RealBotConfigExample.tsx +0 -161
- package/src/tools/JsonForm/index.ts +0 -46
- package/src/tools/JsonForm/templates/ArrayFieldItemTemplate.tsx +0 -47
- package/src/tools/JsonForm/templates/ArrayFieldTemplate.tsx +0 -74
- package/src/tools/JsonForm/templates/BaseInputTemplate.tsx +0 -107
- package/src/tools/JsonForm/templates/ErrorListTemplate.tsx +0 -35
- package/src/tools/JsonForm/templates/FieldTemplate.tsx +0 -62
- package/src/tools/JsonForm/templates/ObjectFieldTemplate.tsx +0 -116
- package/src/tools/JsonForm/templates/index.ts +0 -12
- package/src/tools/JsonForm/types.ts +0 -83
- package/src/tools/JsonForm/utils.ts +0 -213
- package/src/tools/JsonForm/widgets/CheckboxWidget.tsx +0 -37
- package/src/tools/JsonForm/widgets/ColorWidget.tsx +0 -219
- package/src/tools/JsonForm/widgets/NumberWidget.tsx +0 -89
- package/src/tools/JsonForm/widgets/SelectWidget.tsx +0 -97
- package/src/tools/JsonForm/widgets/SliderWidget.tsx +0 -148
- package/src/tools/JsonForm/widgets/SwitchWidget.tsx +0 -35
- package/src/tools/JsonForm/widgets/TextWidget.tsx +0 -96
- package/src/tools/JsonForm/widgets/index.ts +0 -14
- package/src/tools/JsonTree/index.tsx +0 -243
- package/src/tools/LottiePlayer/LottiePlayer.client.tsx +0 -213
- package/src/tools/LottiePlayer/index.tsx +0 -55
- package/src/tools/LottiePlayer/types.ts +0 -108
- package/src/tools/LottiePlayer/useLottie.ts +0 -164
- package/src/tools/Mermaid/Mermaid.client.tsx +0 -82
- package/src/tools/Mermaid/components/MermaidCodeViewer.tsx +0 -95
- package/src/tools/Mermaid/components/MermaidFullscreenModal.tsx +0 -103
- package/src/tools/Mermaid/hooks/index.ts +0 -4
- package/src/tools/Mermaid/hooks/useMermaidCleanup.ts +0 -73
- package/src/tools/Mermaid/hooks/useMermaidFullscreen.ts +0 -46
- package/src/tools/Mermaid/hooks/useMermaidRenderer.ts +0 -226
- package/src/tools/Mermaid/hooks/useMermaidValidation.ts +0 -29
- package/src/tools/Mermaid/index.tsx +0 -41
- package/src/tools/Mermaid/utils/mermaid-helpers.ts +0 -33
- package/src/tools/OpenapiViewer/components/EndpointInfo.tsx +0 -149
- package/src/tools/OpenapiViewer/components/EndpointsLibrary.tsx +0 -263
- package/src/tools/OpenapiViewer/components/PlaygroundLayout.tsx +0 -125
- package/src/tools/OpenapiViewer/components/PlaygroundStepper.tsx +0 -100
- package/src/tools/OpenapiViewer/components/RequestBuilder.tsx +0 -157
- package/src/tools/OpenapiViewer/components/RequestParametersForm.tsx +0 -253
- package/src/tools/OpenapiViewer/components/ResponseViewer.tsx +0 -173
- package/src/tools/OpenapiViewer/components/VersionSelector.tsx +0 -68
- package/src/tools/OpenapiViewer/components/index.ts +0 -14
- package/src/tools/OpenapiViewer/constants.ts +0 -39
- package/src/tools/OpenapiViewer/context/PlaygroundContext.tsx +0 -337
- package/src/tools/OpenapiViewer/hooks/index.ts +0 -8
- package/src/tools/OpenapiViewer/hooks/useMobile.ts +0 -10
- package/src/tools/OpenapiViewer/hooks/useOpenApiSchema.ts +0 -199
- package/src/tools/OpenapiViewer/index.tsx +0 -38
- package/src/tools/OpenapiViewer/types.ts +0 -151
- package/src/tools/OpenapiViewer/utils/apiKeyManager.ts +0 -149
- package/src/tools/OpenapiViewer/utils/formatters.ts +0 -71
- package/src/tools/OpenapiViewer/utils/index.ts +0 -9
- package/src/tools/OpenapiViewer/utils/versionManager.ts +0 -161
- package/src/tools/PrettyCode/PrettyCode.client.tsx +0 -208
- package/src/tools/PrettyCode/index.tsx +0 -45
- package/src/tools/VideoPlayer/@refactoring/00-PLAN.md +0 -91
- package/src/tools/VideoPlayer/@refactoring/01-TYPES.md +0 -284
- package/src/tools/VideoPlayer/@refactoring/02-UTILS.md +0 -141
- package/src/tools/VideoPlayer/@refactoring/03-HOOKS.md +0 -178
- package/src/tools/VideoPlayer/@refactoring/04-COMPONENTS.md +0 -95
- package/src/tools/VideoPlayer/@refactoring/05-EXECUTION-CHECKLIST.md +0 -139
- package/src/tools/VideoPlayer/README.md +0 -264
- package/src/tools/VideoPlayer/components/VideoControls.tsx +0 -138
- package/src/tools/VideoPlayer/components/VideoErrorFallback.tsx +0 -174
- package/src/tools/VideoPlayer/components/VideoPlayer.tsx +0 -201
- package/src/tools/VideoPlayer/components/index.ts +0 -14
- package/src/tools/VideoPlayer/context/VideoPlayerContext.tsx +0 -52
- package/src/tools/VideoPlayer/context/index.ts +0 -8
- package/src/tools/VideoPlayer/hooks/index.ts +0 -12
- package/src/tools/VideoPlayer/hooks/useVideoPlayerSettings.ts +0 -70
- package/src/tools/VideoPlayer/hooks/useVideoPositionCache.ts +0 -116
- package/src/tools/VideoPlayer/index.ts +0 -77
- package/src/tools/VideoPlayer/providers/NativeProvider.tsx +0 -284
- package/src/tools/VideoPlayer/providers/StreamProvider.tsx +0 -505
- package/src/tools/VideoPlayer/providers/VidstackProvider.tsx +0 -400
- package/src/tools/VideoPlayer/providers/index.ts +0 -8
- package/src/tools/VideoPlayer/types/index.ts +0 -38
- package/src/tools/VideoPlayer/types/player.ts +0 -116
- package/src/tools/VideoPlayer/types/provider.ts +0 -93
- package/src/tools/VideoPlayer/types/sources.ts +0 -97
- package/src/tools/VideoPlayer/utils/debug.ts +0 -14
- package/src/tools/VideoPlayer/utils/fileSource.ts +0 -78
- package/src/tools/VideoPlayer/utils/index.ts +0 -12
- package/src/tools/VideoPlayer/utils/resolvers.ts +0 -75
- package/src/tools/index.ts +0 -170
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import ReactMarkdown from 'react-markdown';
|
|
5
|
-
import remarkGfm from 'remark-gfm';
|
|
6
|
-
|
|
7
|
-
import { CopyButton } from '@djangocfg/ui-core/components';
|
|
8
|
-
|
|
9
|
-
import { useResolvedTheme } from '../../hooks/useResolvedTheme';
|
|
10
|
-
import Mermaid from '../../tools/Mermaid';
|
|
11
|
-
import PrettyCode from '../../tools/PrettyCode';
|
|
12
|
-
|
|
13
|
-
import type { Components } from 'react-markdown';
|
|
14
|
-
|
|
15
|
-
// Helper function to extract text content from React children
|
|
16
|
-
const extractTextFromChildren = (children: React.ReactNode): string => {
|
|
17
|
-
if (typeof children === 'string') {
|
|
18
|
-
return children;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (typeof children === 'number') {
|
|
22
|
-
return String(children);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (React.isValidElement(children)) {
|
|
26
|
-
const props = children.props as { children?: React.ReactNode };
|
|
27
|
-
return extractTextFromChildren(props.children);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (Array.isArray(children)) {
|
|
31
|
-
return children.map(extractTextFromChildren).join('');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return '';
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export interface MarkdownMessageProps {
|
|
38
|
-
/** Markdown content to render */
|
|
39
|
-
content: string;
|
|
40
|
-
/** Additional CSS classes */
|
|
41
|
-
className?: string;
|
|
42
|
-
/** Whether the message is from the user (affects styling) */
|
|
43
|
-
isUser?: boolean;
|
|
44
|
-
/** Use compact size (text-xs instead of text-sm) */
|
|
45
|
-
isCompact?: boolean;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Code block component with copy functionality
|
|
49
|
-
interface CodeBlockProps {
|
|
50
|
-
code: string;
|
|
51
|
-
language: string;
|
|
52
|
-
isUser: boolean;
|
|
53
|
-
isCompact?: boolean;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const CodeBlock: React.FC<CodeBlockProps> = ({ code, language, isUser, isCompact = false }) => {
|
|
57
|
-
const theme = useResolvedTheme();
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<div className="relative group my-3">
|
|
61
|
-
{/* Copy button */}
|
|
62
|
-
<CopyButton
|
|
63
|
-
value={code}
|
|
64
|
-
variant="ghost"
|
|
65
|
-
className={`
|
|
66
|
-
absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity
|
|
67
|
-
h-8 w-8
|
|
68
|
-
${isUser
|
|
69
|
-
? 'hover:bg-white/20 text-white'
|
|
70
|
-
: 'hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground'
|
|
71
|
-
}
|
|
72
|
-
`}
|
|
73
|
-
title="Copy code"
|
|
74
|
-
/>
|
|
75
|
-
|
|
76
|
-
{/* Code content */}
|
|
77
|
-
<PrettyCode
|
|
78
|
-
data={code}
|
|
79
|
-
language={language}
|
|
80
|
-
className={isCompact ? 'text-xs' : 'text-sm'}
|
|
81
|
-
customBg={isUser ? "bg-white/10" : "bg-muted dark:bg-muted"}
|
|
82
|
-
mode={theme}
|
|
83
|
-
isCompact={isCompact}
|
|
84
|
-
/>
|
|
85
|
-
</div>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// Custom components for markdown in chat
|
|
90
|
-
// Base size: text-sm (14px) for normal, text-xs (12px) for compact
|
|
91
|
-
const createMarkdownComponents = (isUser: boolean = false, isCompact: boolean = false): Components => {
|
|
92
|
-
// Text size classes based on compact mode
|
|
93
|
-
const textSize = isCompact ? 'text-xs' : 'text-sm';
|
|
94
|
-
const headingBase = isCompact ? 'text-sm' : 'text-base';
|
|
95
|
-
const headingSm = isCompact ? 'text-xs' : 'text-sm';
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
// Headings - scaled for chat context
|
|
99
|
-
h1: ({ children }) => (
|
|
100
|
-
<h1 className={`${headingBase} font-bold mb-2 mt-3 first:mt-0`}>{children}</h1>
|
|
101
|
-
),
|
|
102
|
-
h2: ({ children }) => (
|
|
103
|
-
<h2 className={`${headingSm} font-bold mb-2 mt-3 first:mt-0`}>{children}</h2>
|
|
104
|
-
),
|
|
105
|
-
h3: ({ children }) => (
|
|
106
|
-
<h3 className={`${headingSm} font-semibold mb-1 mt-2 first:mt-0`}>{children}</h3>
|
|
107
|
-
),
|
|
108
|
-
h4: ({ children }) => (
|
|
109
|
-
<h4 className={`${headingSm} font-semibold mb-1 mt-2 first:mt-0`}>{children}</h4>
|
|
110
|
-
),
|
|
111
|
-
h5: ({ children }) => (
|
|
112
|
-
<h5 className={`${headingSm} font-medium mb-1 mt-2 first:mt-0`}>{children}</h5>
|
|
113
|
-
),
|
|
114
|
-
h6: ({ children }) => (
|
|
115
|
-
<h6 className={`${headingSm} font-medium mb-1 mt-2 first:mt-0`}>{children}</h6>
|
|
116
|
-
),
|
|
117
|
-
|
|
118
|
-
// Paragraphs - compact spacing for chat
|
|
119
|
-
p: ({ children }) => (
|
|
120
|
-
<p className={`${textSize} mb-2 last:mb-0 leading-relaxed break-words`}>{children}</p>
|
|
121
|
-
),
|
|
122
|
-
|
|
123
|
-
// Lists - compact
|
|
124
|
-
ul: ({ children }) => (
|
|
125
|
-
<ul className={`list-disc list-inside mb-2 space-y-1 ${textSize}`}>{children}</ul>
|
|
126
|
-
),
|
|
127
|
-
ol: ({ children }) => (
|
|
128
|
-
<ol className={`list-decimal list-inside mb-2 space-y-1 ${textSize}`}>{children}</ol>
|
|
129
|
-
),
|
|
130
|
-
li: ({ children }) => (
|
|
131
|
-
<li className="break-words">{children}</li>
|
|
132
|
-
),
|
|
133
|
-
|
|
134
|
-
// Links - appropriate for chat context
|
|
135
|
-
a: ({ href, children }) => (
|
|
136
|
-
<a
|
|
137
|
-
href={href}
|
|
138
|
-
className={`${textSize} text-primary underline hover:text-primary/80 transition-colors break-all`}
|
|
139
|
-
target={href?.startsWith('http') ? '_blank' : undefined}
|
|
140
|
-
rel={href?.startsWith('http') ? 'noopener noreferrer' : undefined}
|
|
141
|
-
>
|
|
142
|
-
{children}
|
|
143
|
-
</a>
|
|
144
|
-
),
|
|
145
|
-
|
|
146
|
-
// Code blocks - using CodeBlock component with copy functionality
|
|
147
|
-
pre: ({ children }) => {
|
|
148
|
-
// Extract code content and language
|
|
149
|
-
let codeContent = '';
|
|
150
|
-
let language = 'plaintext';
|
|
151
|
-
|
|
152
|
-
if (React.isValidElement(children)) {
|
|
153
|
-
const child = children;
|
|
154
|
-
|
|
155
|
-
if (child.type === 'code' || (typeof child.type === 'function' && child.type.name === 'code')) {
|
|
156
|
-
const codeProps = child.props as { className?: string; children?: React.ReactNode };
|
|
157
|
-
const rawClassName = codeProps.className;
|
|
158
|
-
language = rawClassName?.replace(/language-/, '').trim() || 'plaintext';
|
|
159
|
-
codeContent = extractTextFromChildren(codeProps.children).trim();
|
|
160
|
-
} else {
|
|
161
|
-
codeContent = extractTextFromChildren(children).trim();
|
|
162
|
-
}
|
|
163
|
-
} else {
|
|
164
|
-
codeContent = extractTextFromChildren(children).trim();
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// If still no content, show placeholder
|
|
168
|
-
if (!codeContent) {
|
|
169
|
-
return (
|
|
170
|
-
<div className="my-3 p-3 bg-muted rounded text-sm text-muted-foreground">
|
|
171
|
-
No content available
|
|
172
|
-
</div>
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Handle Mermaid diagrams separately
|
|
177
|
-
if (language === 'mermaid') {
|
|
178
|
-
return (
|
|
179
|
-
<div className="my-3 max-w-full overflow-x-auto">
|
|
180
|
-
<Mermaid chart={codeContent} className="max-w-[600px] mx-auto" isCompact={isCompact} />
|
|
181
|
-
</div>
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Try to use CodeBlock component, fallback to simple pre if it fails
|
|
186
|
-
try {
|
|
187
|
-
return <CodeBlock code={codeContent} language={language} isUser={isUser} isCompact={isCompact} />;
|
|
188
|
-
} catch (error) {
|
|
189
|
-
// Fallback to simple pre element with copy button
|
|
190
|
-
console.warn('CodeBlock failed, using fallback:', error);
|
|
191
|
-
return (
|
|
192
|
-
<div className="relative group my-3">
|
|
193
|
-
<CopyButton
|
|
194
|
-
value={codeContent}
|
|
195
|
-
variant="ghost"
|
|
196
|
-
className={`
|
|
197
|
-
absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity
|
|
198
|
-
h-8 w-8
|
|
199
|
-
${isUser
|
|
200
|
-
? 'hover:bg-white/20 text-white'
|
|
201
|
-
: 'hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground'
|
|
202
|
-
}
|
|
203
|
-
`}
|
|
204
|
-
title="Copy code"
|
|
205
|
-
/>
|
|
206
|
-
<pre className={`
|
|
207
|
-
p-3 rounded text-xs font-mono overflow-x-auto
|
|
208
|
-
${isUser
|
|
209
|
-
? 'bg-white/10 text-white'
|
|
210
|
-
: 'bg-muted text-foreground'
|
|
211
|
-
}
|
|
212
|
-
`}>
|
|
213
|
-
<code>{codeContent}</code>
|
|
214
|
-
</pre>
|
|
215
|
-
</div>
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
|
|
220
|
-
// Inline code
|
|
221
|
-
code: ({ children, className }) => {
|
|
222
|
-
// If it's inside a pre tag, let pre handle it
|
|
223
|
-
if (className?.includes('language-')) {
|
|
224
|
-
return <code className={className}>{children}</code>;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// Extract text content safely
|
|
228
|
-
const codeContent = extractTextFromChildren(children);
|
|
229
|
-
|
|
230
|
-
// Inline code styling
|
|
231
|
-
return (
|
|
232
|
-
<code className="px-1.5 py-0.5 rounded text-xs font-mono bg-muted text-foreground break-all">
|
|
233
|
-
{codeContent}
|
|
234
|
-
</code>
|
|
235
|
-
);
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
// Blockquotes
|
|
239
|
-
blockquote: ({ children }) => (
|
|
240
|
-
<blockquote className={`${textSize} border-l-2 border-border pl-3 my-2 italic text-muted-foreground break-words`}>
|
|
241
|
-
{children}
|
|
242
|
-
</blockquote>
|
|
243
|
-
),
|
|
244
|
-
|
|
245
|
-
// Tables - compact for chat
|
|
246
|
-
table: ({ children }) => (
|
|
247
|
-
<div className="overflow-x-auto my-3">
|
|
248
|
-
<table className={`min-w-full ${textSize} border-collapse`}>
|
|
249
|
-
{children}
|
|
250
|
-
</table>
|
|
251
|
-
</div>
|
|
252
|
-
),
|
|
253
|
-
thead: ({ children }) => (
|
|
254
|
-
<thead className="bg-muted/50">
|
|
255
|
-
{children}
|
|
256
|
-
</thead>
|
|
257
|
-
),
|
|
258
|
-
tbody: ({ children }) => (
|
|
259
|
-
<tbody>{children}</tbody>
|
|
260
|
-
),
|
|
261
|
-
tr: ({ children }) => (
|
|
262
|
-
<tr className="border-b border-border/50">{children}</tr>
|
|
263
|
-
),
|
|
264
|
-
th: ({ children }) => (
|
|
265
|
-
<th className="px-2 py-1 text-left font-medium break-words">{children}</th>
|
|
266
|
-
),
|
|
267
|
-
td: ({ children }) => (
|
|
268
|
-
<td className="px-2 py-1 break-words">{children}</td>
|
|
269
|
-
),
|
|
270
|
-
|
|
271
|
-
// Horizontal rule
|
|
272
|
-
hr: () => (
|
|
273
|
-
<hr className="my-3 border-0 h-px bg-border" />
|
|
274
|
-
),
|
|
275
|
-
|
|
276
|
-
// Strong and emphasis
|
|
277
|
-
strong: ({ children }) => (
|
|
278
|
-
<strong className="font-semibold">{children}</strong>
|
|
279
|
-
),
|
|
280
|
-
em: ({ children }) => (
|
|
281
|
-
<em className="italic">{children}</em>
|
|
282
|
-
),
|
|
283
|
-
};};
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* MarkdownMessage - Renders markdown content with syntax highlighting and GFM support
|
|
287
|
-
*
|
|
288
|
-
* Features:
|
|
289
|
-
* - GitHub Flavored Markdown (GFM) support
|
|
290
|
-
* - Syntax highlighted code blocks with copy button
|
|
291
|
-
* - Mermaid diagram rendering
|
|
292
|
-
* - Tables, lists, blockquotes
|
|
293
|
-
* - User/assistant styling modes
|
|
294
|
-
*
|
|
295
|
-
* @example
|
|
296
|
-
* ```tsx
|
|
297
|
-
* <MarkdownMessage content="# Hello\n\nThis is **bold** text." />
|
|
298
|
-
*
|
|
299
|
-
* // User message styling
|
|
300
|
-
* <MarkdownMessage content="Some content" isUser />
|
|
301
|
-
* ```
|
|
302
|
-
*/
|
|
303
|
-
export const MarkdownMessage: React.FC<MarkdownMessageProps> = ({
|
|
304
|
-
content,
|
|
305
|
-
className = "",
|
|
306
|
-
isUser = false,
|
|
307
|
-
isCompact = false,
|
|
308
|
-
}) => {
|
|
309
|
-
const components = React.useMemo(() => createMarkdownComponents(isUser, isCompact), [isUser, isCompact]);
|
|
310
|
-
|
|
311
|
-
const textSizeClass = isCompact ? 'text-xs' : 'text-sm';
|
|
312
|
-
const proseClass = isCompact ? 'prose-xs' : 'prose-sm';
|
|
313
|
-
|
|
314
|
-
return (
|
|
315
|
-
<div
|
|
316
|
-
className={`
|
|
317
|
-
prose ${proseClass} max-w-none break-words overflow-hidden ${textSizeClass}
|
|
318
|
-
${isUser ? 'prose-invert' : 'dark:prose-invert'}
|
|
319
|
-
${className}
|
|
320
|
-
`}
|
|
321
|
-
style={{
|
|
322
|
-
// Inherit colors from parent - fixes issues with external CSS variables
|
|
323
|
-
'--tw-prose-body': 'inherit',
|
|
324
|
-
'--tw-prose-headings': 'inherit',
|
|
325
|
-
'--tw-prose-bold': 'inherit',
|
|
326
|
-
'--tw-prose-links': 'inherit',
|
|
327
|
-
color: 'inherit',
|
|
328
|
-
} as React.CSSProperties}
|
|
329
|
-
>
|
|
330
|
-
<ReactMarkdown
|
|
331
|
-
remarkPlugins={[remarkGfm]}
|
|
332
|
-
components={components}
|
|
333
|
-
>
|
|
334
|
-
{content}
|
|
335
|
-
</ReactMarkdown>
|
|
336
|
-
</div>
|
|
337
|
-
);
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
export default MarkdownMessage;
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { Check, ChevronRight, Circle } from 'lucide-react';
|
|
4
|
-
import Link from 'next/link';
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
|
|
7
|
-
import { cn } from '@djangocfg/ui-core/lib';
|
|
8
|
-
import * as MenubarPrimitive from '@radix-ui/react-menubar';
|
|
9
|
-
|
|
10
|
-
function MenubarMenu({
|
|
11
|
-
...props
|
|
12
|
-
}: React.ComponentProps<typeof MenubarPrimitive.Menu>) {
|
|
13
|
-
return <MenubarPrimitive.Menu {...props} />
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function MenubarGroup({
|
|
17
|
-
...props
|
|
18
|
-
}: React.ComponentProps<typeof MenubarPrimitive.Group>) {
|
|
19
|
-
return <MenubarPrimitive.Group {...props} />
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function MenubarPortal({
|
|
23
|
-
...props
|
|
24
|
-
}: React.ComponentProps<typeof MenubarPrimitive.Portal>) {
|
|
25
|
-
return <MenubarPrimitive.Portal {...props} />
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function MenubarRadioGroup({
|
|
29
|
-
...props
|
|
30
|
-
}: React.ComponentProps<typeof MenubarPrimitive.RadioGroup>) {
|
|
31
|
-
return <MenubarPrimitive.RadioGroup {...props} />
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function MenubarSub({
|
|
35
|
-
...props
|
|
36
|
-
}: React.ComponentProps<typeof MenubarPrimitive.Sub>) {
|
|
37
|
-
return <MenubarPrimitive.Sub data-slot="menubar-sub" {...props} />
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const Menubar = React.forwardRef<
|
|
41
|
-
React.ElementRef<typeof MenubarPrimitive.Root>,
|
|
42
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Root>
|
|
43
|
-
>(({ className, ...props }, ref) => (
|
|
44
|
-
<MenubarPrimitive.Root
|
|
45
|
-
ref={ref}
|
|
46
|
-
className={cn(
|
|
47
|
-
"flex h-9 items-center space-x-1 rounded-md border bg-background p-1 shadow-sm",
|
|
48
|
-
className
|
|
49
|
-
)}
|
|
50
|
-
{...props}
|
|
51
|
-
/>
|
|
52
|
-
))
|
|
53
|
-
Menubar.displayName = MenubarPrimitive.Root.displayName
|
|
54
|
-
|
|
55
|
-
const MenubarTrigger = React.forwardRef<
|
|
56
|
-
React.ElementRef<typeof MenubarPrimitive.Trigger>,
|
|
57
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Trigger>
|
|
58
|
-
>(({ className, ...props }, ref) => (
|
|
59
|
-
<MenubarPrimitive.Trigger
|
|
60
|
-
ref={ref}
|
|
61
|
-
className={cn(
|
|
62
|
-
"flex cursor-default select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
|
63
|
-
className
|
|
64
|
-
)}
|
|
65
|
-
{...props}
|
|
66
|
-
/>
|
|
67
|
-
))
|
|
68
|
-
MenubarTrigger.displayName = MenubarPrimitive.Trigger.displayName
|
|
69
|
-
|
|
70
|
-
const MenubarSubTrigger = React.forwardRef<
|
|
71
|
-
React.ElementRef<typeof MenubarPrimitive.SubTrigger>,
|
|
72
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubTrigger> & {
|
|
73
|
-
inset?: boolean
|
|
74
|
-
}
|
|
75
|
-
>(({ className, inset, children, ...props }, ref) => (
|
|
76
|
-
<MenubarPrimitive.SubTrigger
|
|
77
|
-
ref={ref}
|
|
78
|
-
className={cn(
|
|
79
|
-
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
|
80
|
-
inset && "pl-8",
|
|
81
|
-
className
|
|
82
|
-
)}
|
|
83
|
-
{...props}
|
|
84
|
-
>
|
|
85
|
-
{children}
|
|
86
|
-
<ChevronRight className="ml-auto h-4 w-4" />
|
|
87
|
-
</MenubarPrimitive.SubTrigger>
|
|
88
|
-
))
|
|
89
|
-
MenubarSubTrigger.displayName = MenubarPrimitive.SubTrigger.displayName
|
|
90
|
-
|
|
91
|
-
const MenubarSubContent = React.forwardRef<
|
|
92
|
-
React.ElementRef<typeof MenubarPrimitive.SubContent>,
|
|
93
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubContent>
|
|
94
|
-
>(({ className, ...props }, ref) => (
|
|
95
|
-
<MenubarPrimitive.SubContent
|
|
96
|
-
ref={ref}
|
|
97
|
-
className={cn(
|
|
98
|
-
"z-150 min-w-32 overflow-hidden rounded-md border bg-popover backdrop-blur-xl p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
99
|
-
className
|
|
100
|
-
)}
|
|
101
|
-
{...props}
|
|
102
|
-
/>
|
|
103
|
-
))
|
|
104
|
-
MenubarSubContent.displayName = MenubarPrimitive.SubContent.displayName
|
|
105
|
-
|
|
106
|
-
const MenubarContent = React.forwardRef<
|
|
107
|
-
React.ElementRef<typeof MenubarPrimitive.Content>,
|
|
108
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Content>
|
|
109
|
-
>(
|
|
110
|
-
(
|
|
111
|
-
{ className, align = "start", alignOffset = -4, sideOffset = 8, ...props },
|
|
112
|
-
ref
|
|
113
|
-
) => (
|
|
114
|
-
<MenubarPrimitive.Portal>
|
|
115
|
-
<MenubarPrimitive.Content
|
|
116
|
-
ref={ref}
|
|
117
|
-
align={align}
|
|
118
|
-
alignOffset={alignOffset}
|
|
119
|
-
sideOffset={sideOffset}
|
|
120
|
-
className={cn(
|
|
121
|
-
"z-150 min-w-48 overflow-hidden rounded-md border bg-popover backdrop-blur-xl p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
122
|
-
className
|
|
123
|
-
)}
|
|
124
|
-
{...props}
|
|
125
|
-
/>
|
|
126
|
-
</MenubarPrimitive.Portal>
|
|
127
|
-
)
|
|
128
|
-
)
|
|
129
|
-
MenubarContent.displayName = MenubarPrimitive.Content.displayName
|
|
130
|
-
|
|
131
|
-
const MenubarItem = React.forwardRef<
|
|
132
|
-
React.ElementRef<typeof MenubarPrimitive.Item>,
|
|
133
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Item> & {
|
|
134
|
-
inset?: boolean
|
|
135
|
-
href?: string
|
|
136
|
-
key?: React.Key
|
|
137
|
-
}
|
|
138
|
-
>(({ className, inset, href, children, ...props }, ref) => {
|
|
139
|
-
const classes = cn(
|
|
140
|
-
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
141
|
-
inset && "pl-8",
|
|
142
|
-
className
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
if (href) {
|
|
146
|
-
return (
|
|
147
|
-
<MenubarPrimitive.Item asChild ref={ref} {...props}>
|
|
148
|
-
<Link href={href} className={classes}>
|
|
149
|
-
{children}
|
|
150
|
-
</Link>
|
|
151
|
-
</MenubarPrimitive.Item>
|
|
152
|
-
)
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return (
|
|
156
|
-
<MenubarPrimitive.Item
|
|
157
|
-
ref={ref}
|
|
158
|
-
className={classes}
|
|
159
|
-
{...props}
|
|
160
|
-
>
|
|
161
|
-
{children}
|
|
162
|
-
</MenubarPrimitive.Item>
|
|
163
|
-
)
|
|
164
|
-
})
|
|
165
|
-
MenubarItem.displayName = MenubarPrimitive.Item.displayName
|
|
166
|
-
|
|
167
|
-
const MenubarCheckboxItem = React.forwardRef<
|
|
168
|
-
React.ElementRef<typeof MenubarPrimitive.CheckboxItem>,
|
|
169
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.CheckboxItem> & { key?: React.Key }
|
|
170
|
-
>(({ className, children, checked, ...props }, ref) => (
|
|
171
|
-
<MenubarPrimitive.CheckboxItem
|
|
172
|
-
ref={ref}
|
|
173
|
-
className={cn(
|
|
174
|
-
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
175
|
-
className
|
|
176
|
-
)}
|
|
177
|
-
checked={checked}
|
|
178
|
-
{...props}
|
|
179
|
-
>
|
|
180
|
-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
181
|
-
<MenubarPrimitive.ItemIndicator>
|
|
182
|
-
<Check className="h-4 w-4" />
|
|
183
|
-
</MenubarPrimitive.ItemIndicator>
|
|
184
|
-
</span>
|
|
185
|
-
{children}
|
|
186
|
-
</MenubarPrimitive.CheckboxItem>
|
|
187
|
-
))
|
|
188
|
-
MenubarCheckboxItem.displayName = MenubarPrimitive.CheckboxItem.displayName
|
|
189
|
-
|
|
190
|
-
const MenubarRadioItem = React.forwardRef<
|
|
191
|
-
React.ElementRef<typeof MenubarPrimitive.RadioItem>,
|
|
192
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.RadioItem> & { key?: React.Key }
|
|
193
|
-
>(({ className, children, ...props }, ref) => (
|
|
194
|
-
<MenubarPrimitive.RadioItem
|
|
195
|
-
ref={ref}
|
|
196
|
-
className={cn(
|
|
197
|
-
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
198
|
-
className
|
|
199
|
-
)}
|
|
200
|
-
{...props}
|
|
201
|
-
>
|
|
202
|
-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
203
|
-
<MenubarPrimitive.ItemIndicator>
|
|
204
|
-
<Circle className="h-4 w-4 fill-current" />
|
|
205
|
-
</MenubarPrimitive.ItemIndicator>
|
|
206
|
-
</span>
|
|
207
|
-
{children}
|
|
208
|
-
</MenubarPrimitive.RadioItem>
|
|
209
|
-
))
|
|
210
|
-
MenubarRadioItem.displayName = MenubarPrimitive.RadioItem.displayName
|
|
211
|
-
|
|
212
|
-
const MenubarLabel = React.forwardRef<
|
|
213
|
-
React.ElementRef<typeof MenubarPrimitive.Label>,
|
|
214
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Label> & {
|
|
215
|
-
inset?: boolean
|
|
216
|
-
}
|
|
217
|
-
>(({ className, inset, ...props }, ref) => (
|
|
218
|
-
<MenubarPrimitive.Label
|
|
219
|
-
ref={ref}
|
|
220
|
-
className={cn(
|
|
221
|
-
"px-2 py-1.5 text-sm font-semibold",
|
|
222
|
-
inset && "pl-8",
|
|
223
|
-
className
|
|
224
|
-
)}
|
|
225
|
-
{...props}
|
|
226
|
-
/>
|
|
227
|
-
))
|
|
228
|
-
MenubarLabel.displayName = MenubarPrimitive.Label.displayName
|
|
229
|
-
|
|
230
|
-
const MenubarSeparator = React.forwardRef<
|
|
231
|
-
React.ElementRef<typeof MenubarPrimitive.Separator>,
|
|
232
|
-
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Separator>
|
|
233
|
-
>(({ className, ...props }, ref) => (
|
|
234
|
-
<MenubarPrimitive.Separator
|
|
235
|
-
ref={ref}
|
|
236
|
-
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
|
237
|
-
{...props}
|
|
238
|
-
/>
|
|
239
|
-
))
|
|
240
|
-
MenubarSeparator.displayName = MenubarPrimitive.Separator.displayName
|
|
241
|
-
|
|
242
|
-
const MenubarShortcut = ({
|
|
243
|
-
className,
|
|
244
|
-
...props
|
|
245
|
-
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
246
|
-
return (
|
|
247
|
-
<span
|
|
248
|
-
className={cn(
|
|
249
|
-
"ml-auto text-xs tracking-widest text-muted-foreground",
|
|
250
|
-
className
|
|
251
|
-
)}
|
|
252
|
-
{...props}
|
|
253
|
-
/>
|
|
254
|
-
)
|
|
255
|
-
}
|
|
256
|
-
MenubarShortcut.displayname = "MenubarShortcut"
|
|
257
|
-
|
|
258
|
-
export {
|
|
259
|
-
Menubar,
|
|
260
|
-
MenubarMenu,
|
|
261
|
-
MenubarTrigger,
|
|
262
|
-
MenubarContent,
|
|
263
|
-
MenubarItem,
|
|
264
|
-
MenubarSeparator,
|
|
265
|
-
MenubarLabel,
|
|
266
|
-
MenubarCheckboxItem,
|
|
267
|
-
MenubarRadioGroup,
|
|
268
|
-
MenubarRadioItem,
|
|
269
|
-
MenubarPortal,
|
|
270
|
-
MenubarSubContent,
|
|
271
|
-
MenubarSubTrigger,
|
|
272
|
-
MenubarGroup,
|
|
273
|
-
MenubarSub,
|
|
274
|
-
MenubarShortcut,
|
|
275
|
-
}
|