@djangocfg/ui-nextjs 2.1.20 → 2.1.22
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/ui-nextjs",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.22",
|
|
4
4
|
"description": "Next.js UI component library with Radix UI primitives, Tailwind CSS styling, charts, and form components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui-components",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"check": "tsc --noEmit"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@djangocfg/api": "^2.1.
|
|
62
|
-
"@djangocfg/ui-core": "^2.1.
|
|
61
|
+
"@djangocfg/api": "^2.1.22",
|
|
62
|
+
"@djangocfg/ui-core": "^2.1.22",
|
|
63
63
|
"@types/react": "^19.1.0",
|
|
64
64
|
"@types/react-dom": "^19.1.0",
|
|
65
65
|
"consola": "^3.4.2",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"vidstack": "next"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
107
|
+
"@djangocfg/typescript-config": "^2.1.22",
|
|
108
108
|
"@types/node": "^24.7.2",
|
|
109
109
|
"eslint": "^9.37.0",
|
|
110
110
|
"tailwindcss-animate": "1.0.7",
|
|
@@ -47,9 +47,10 @@ interface CodeBlockProps {
|
|
|
47
47
|
code: string;
|
|
48
48
|
language: string;
|
|
49
49
|
isUser: boolean;
|
|
50
|
+
isCompact?: boolean;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
const CodeBlock: React.FC<CodeBlockProps> = ({ code, language, isUser }) => {
|
|
53
|
+
const CodeBlock: React.FC<CodeBlockProps> = ({ code, language, isUser, isCompact = false }) => {
|
|
53
54
|
const theme = useResolvedTheme();
|
|
54
55
|
|
|
55
56
|
return (
|
|
@@ -73,9 +74,10 @@ const CodeBlock: React.FC<CodeBlockProps> = ({ code, language, isUser }) => {
|
|
|
73
74
|
<PrettyCode
|
|
74
75
|
data={code}
|
|
75
76
|
language={language}
|
|
76
|
-
className=
|
|
77
|
+
className={isCompact ? 'text-xs' : 'text-sm'}
|
|
77
78
|
customBg={isUser ? "bg-white/10" : "bg-muted dark:bg-muted"}
|
|
78
79
|
mode={theme}
|
|
80
|
+
isCompact={isCompact}
|
|
79
81
|
/>
|
|
80
82
|
</div>
|
|
81
83
|
);
|
|
@@ -172,14 +174,14 @@ const createMarkdownComponents = (isUser: boolean = false, isCompact: boolean =
|
|
|
172
174
|
if (language === 'mermaid') {
|
|
173
175
|
return (
|
|
174
176
|
<div className="my-3 max-w-full overflow-x-auto">
|
|
175
|
-
<Mermaid chart={codeContent} className="max-w-[600px] mx-auto" />
|
|
177
|
+
<Mermaid chart={codeContent} className="max-w-[600px] mx-auto" isCompact={isCompact} />
|
|
176
178
|
</div>
|
|
177
179
|
);
|
|
178
180
|
}
|
|
179
181
|
|
|
180
182
|
// Try to use CodeBlock component, fallback to simple pre if it fails
|
|
181
183
|
try {
|
|
182
|
-
return <CodeBlock code={codeContent} language={language} isUser={isUser} />;
|
|
184
|
+
return <CodeBlock code={codeContent} language={language} isUser={isUser} isCompact={isCompact} />;
|
|
183
185
|
} catch (error) {
|
|
184
186
|
// Fallback to simple pre element with copy button
|
|
185
187
|
console.warn('CodeBlock failed, using fallback:', error);
|
|
@@ -8,6 +8,7 @@ import { useResolvedTheme } from '../../hooks/useResolvedTheme';
|
|
|
8
8
|
interface MermaidProps {
|
|
9
9
|
chart: string;
|
|
10
10
|
className?: string;
|
|
11
|
+
isCompact?: boolean; // Compact mode for smaller font sizes
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
// Utility function to apply text colors to Mermaid SVG
|
|
@@ -42,7 +43,7 @@ const isVerticalDiagram = (svgElement: SVGSVGElement): boolean => {
|
|
|
42
43
|
return false;
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
const Mermaid: React.FC<MermaidProps> = ({ chart, className = '' }) => {
|
|
46
|
+
const Mermaid: React.FC<MermaidProps> = ({ chart, className = '', isCompact = false }) => {
|
|
46
47
|
const mermaidRef = useRef<HTMLDivElement>(null);
|
|
47
48
|
const fullscreenRef = useRef<HTMLDivElement>(null);
|
|
48
49
|
const [isFullscreen, setIsFullscreen] = useState(false);
|
|
@@ -58,6 +59,9 @@ const Mermaid: React.FC<MermaidProps> = ({ chart, className = '' }) => {
|
|
|
58
59
|
return value ? `hsl(${value})` : '';
|
|
59
60
|
};
|
|
60
61
|
|
|
62
|
+
// Font size based on compact mode
|
|
63
|
+
const diagramFontSize = isCompact ? '12px' : '14px';
|
|
64
|
+
|
|
61
65
|
// Note: In Mermaid v11+, mermaidAPI.reset() no longer exists
|
|
62
66
|
// Re-initialization happens automatically via mermaid.initialize()
|
|
63
67
|
|
|
@@ -103,7 +107,7 @@ const Mermaid: React.FC<MermaidProps> = ({ chart, className = '' }) => {
|
|
|
103
107
|
errorBkgColor: getCSSVariable('--destructive') || 'hsl(0 62.8% 30.6%)',
|
|
104
108
|
errorTextColor: 'hsl(210 40% 98%)',
|
|
105
109
|
|
|
106
|
-
fontSize:
|
|
110
|
+
fontSize: diagramFontSize,
|
|
107
111
|
fontFamily: 'Inter, system-ui, sans-serif',
|
|
108
112
|
} : {
|
|
109
113
|
// Light theme - clean and professional
|
|
@@ -147,7 +151,7 @@ const Mermaid: React.FC<MermaidProps> = ({ chart, className = '' }) => {
|
|
|
147
151
|
errorBkgColor: getCSSVariable('--destructive') || 'hsl(0 84.2% 60.2%)',
|
|
148
152
|
errorTextColor: 'hsl(210 40% 98%)',
|
|
149
153
|
|
|
150
|
-
fontSize:
|
|
154
|
+
fontSize: diagramFontSize,
|
|
151
155
|
fontFamily: 'Inter, system-ui, sans-serif',
|
|
152
156
|
};
|
|
153
157
|
|
|
@@ -217,7 +221,7 @@ const Mermaid: React.FC<MermaidProps> = ({ chart, className = '' }) => {
|
|
|
217
221
|
};
|
|
218
222
|
|
|
219
223
|
renderChart();
|
|
220
|
-
}, [chart, theme]);
|
|
224
|
+
}, [chart, theme, isCompact]);
|
|
221
225
|
|
|
222
226
|
const handleClick = () => {
|
|
223
227
|
if (svgContent) {
|
|
@@ -12,11 +12,15 @@ interface PrettyCodeProps {
|
|
|
12
12
|
mode?: 'dark' | 'light';
|
|
13
13
|
inline?: boolean;
|
|
14
14
|
customBg?: string; // Custom background class
|
|
15
|
+
isCompact?: boolean; // Compact mode for smaller font sizes
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
const PrettyCode = ({ data, language, className, mode, inline = false, customBg }: PrettyCodeProps) => {
|
|
18
|
+
const PrettyCode = ({ data, language, className, mode, inline = false, customBg, isCompact = false }: PrettyCodeProps) => {
|
|
18
19
|
const detectedTheme = useResolvedTheme();
|
|
19
20
|
|
|
21
|
+
// Font size based on compact mode
|
|
22
|
+
const fontSize = isCompact ? '0.75rem' : '0.875rem'; // 12px vs 14px
|
|
23
|
+
|
|
20
24
|
// Use provided mode or fall back to detected theme
|
|
21
25
|
const currentTheme = mode || detectedTheme;
|
|
22
26
|
const isDarkMode = currentTheme === 'dark';
|
|
@@ -131,10 +135,10 @@ const PrettyCode = ({ data, language, className, mode, inline = false, customBg
|
|
|
131
135
|
<Highlight theme={prismTheme} code={contentJson} language={normalizedLanguage as Language}>
|
|
132
136
|
{({ className, style, tokens, getTokenProps }) => (
|
|
133
137
|
<code
|
|
134
|
-
className={`${className} ${inlineBgClass} px-2 py-1 rounded text-sm font-mono inline-block`}
|
|
138
|
+
className={`${className} ${inlineBgClass} px-2 py-1 rounded ${isCompact ? 'text-xs' : 'text-sm'} font-mono inline-block`}
|
|
135
139
|
style={{
|
|
136
140
|
...style,
|
|
137
|
-
fontSize
|
|
141
|
+
fontSize,
|
|
138
142
|
fontFamily: 'monospace',
|
|
139
143
|
}}
|
|
140
144
|
>
|
|
@@ -176,8 +180,8 @@ const PrettyCode = ({ data, language, className, mode, inline = false, customBg
|
|
|
176
180
|
...style,
|
|
177
181
|
margin: 0,
|
|
178
182
|
padding: '2.5rem 1rem 1rem 1rem', // Extra top padding for language badge
|
|
179
|
-
fontSize
|
|
180
|
-
lineHeight: 1.5,
|
|
183
|
+
fontSize,
|
|
184
|
+
lineHeight: isCompact ? 1.4 : 1.5,
|
|
181
185
|
fontFamily: 'monospace',
|
|
182
186
|
whiteSpace: 'pre-wrap',
|
|
183
187
|
wordBreak: 'break-word',
|