@djangocfg/ui-tools 2.1.301 → 2.1.303

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 (30) hide show
  1. package/dist/{DocsLayout-MWRKNFXR.mjs → DocsLayout-6ECALRLD.mjs} +3 -3
  2. package/dist/{DocsLayout-MWRKNFXR.mjs.map → DocsLayout-6ECALRLD.mjs.map} +1 -1
  3. package/dist/{DocsLayout-NWJUF42A.cjs → DocsLayout-ASPSECYR.cjs} +48 -48
  4. package/dist/{DocsLayout-NWJUF42A.cjs.map → DocsLayout-ASPSECYR.cjs.map} +1 -1
  5. package/dist/{Mermaid.client-XFQ74OYN.mjs → Mermaid.client-SXRRI2YW.mjs} +43 -6
  6. package/dist/Mermaid.client-SXRRI2YW.mjs.map +1 -0
  7. package/dist/{Mermaid.client-RSWUUHIL.cjs → Mermaid.client-W76R5AKJ.cjs} +43 -6
  8. package/dist/Mermaid.client-W76R5AKJ.cjs.map +1 -0
  9. package/dist/{chunk-CKD7GNE5.mjs → chunk-K35OF7OB.mjs} +88 -52
  10. package/dist/chunk-K35OF7OB.mjs.map +1 -0
  11. package/dist/{chunk-SEXWBCLX.cjs → chunk-PFKR6ZPZ.cjs} +88 -52
  12. package/dist/chunk-PFKR6ZPZ.cjs.map +1 -0
  13. package/dist/index.cjs +11 -11
  14. package/dist/index.d.cts +20 -0
  15. package/dist/index.d.ts +20 -0
  16. package/dist/index.mjs +5 -5
  17. package/package.json +6 -6
  18. package/src/components/markdown/MarkdownMessage/CodeBlock.tsx +53 -42
  19. package/src/components/markdown/MarkdownMessage/MarkdownMessage.story.tsx +422 -0
  20. package/src/components/markdown/MarkdownMessage/MarkdownMessage.tsx +38 -11
  21. package/src/components/markdown/MarkdownMessage/components.tsx +69 -14
  22. package/src/components/markdown/MarkdownMessage/plainText.ts +33 -0
  23. package/src/components/markdown/MarkdownMessage/types.ts +13 -0
  24. package/src/tools/Mermaid/Mermaid.client.tsx +10 -1
  25. package/src/tools/Mermaid/components/MermaidFullscreenModal.tsx +76 -3
  26. package/src/tools/Mermaid/index.tsx +7 -0
  27. package/dist/Mermaid.client-RSWUUHIL.cjs.map +0 -1
  28. package/dist/Mermaid.client-XFQ74OYN.mjs.map +0 -1
  29. package/dist/chunk-CKD7GNE5.mjs.map +0 -1
  30. package/dist/chunk-SEXWBCLX.cjs.map +0 -1
@@ -139,6 +139,17 @@ function extractTextFromChildren(children) {
139
139
  return "";
140
140
  }
141
141
  __name(extractTextFromChildren, "extractTextFromChildren");
142
+ function looksLikePlainProse(text) {
143
+ const trimmed = text.trim();
144
+ if (trimmed.length === 0) return true;
145
+ if (trimmed.length > 500) return false;
146
+ if (/\n\s*\n/.test(trimmed)) return false;
147
+ const newlineCount = (trimmed.match(/\n/g) || []).length;
148
+ if (newlineCount > 4) return false;
149
+ if (hasMarkdownSyntax(trimmed)) return false;
150
+ return true;
151
+ }
152
+ __name(looksLikePlainProse, "looksLikePlainProse");
142
153
  function hasMarkdownSyntax(text) {
143
154
  if (text.trim().includes("\n")) return true;
144
155
  if (/<\/?[a-zA-Z][a-zA-Z0-9-]*(\s[^>]*)?\/?>/.test(text)) return true;
@@ -177,7 +188,7 @@ function hasMarkdownSyntax(text) {
177
188
  return patterns.some((p) => p.test(text));
178
189
  }
179
190
  __name(hasMarkdownSyntax, "hasMarkdownSyntax");
180
- var MermaidClient = lazy(() => import('./Mermaid.client-XFQ74OYN.mjs'));
191
+ var MermaidClient = lazy(() => import('./Mermaid.client-SXRRI2YW.mjs'));
181
192
  var LoadingFallback = /* @__PURE__ */ __name(() => /* @__PURE__ */ jsx("div", { className: "flex justify-center items-center min-h-[100px]", children: /* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-primary" }) }), "LoadingFallback");
182
193
  var Mermaid = /* @__PURE__ */ __name((props) => {
183
194
  return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingFallback, {}), children: /* @__PURE__ */ jsx(MermaidClient, { ...props }) });
@@ -240,54 +251,38 @@ function buildUrlTransform(extraProtocols) {
240
251
  };
241
252
  }
242
253
  __name(buildUrlTransform, "buildUrlTransform");
243
- var CodeBlock = /* @__PURE__ */ __name(({ code, language, isUser, isCompact = false }) => {
254
+ var CodeBlock = /* @__PURE__ */ __name(({ code, language, isCompact = false }) => {
244
255
  const theme = useResolvedTheme();
256
+ const textSizeClass = isCompact ? "text-xs" : "text-sm";
257
+ return /* @__PURE__ */ jsx("div", { className: "my-3", children: /* @__PURE__ */ jsx(
258
+ PrettyCode_default,
259
+ {
260
+ data: code,
261
+ language,
262
+ className: textSizeClass,
263
+ customBg: "bg-code",
264
+ mode: theme,
265
+ isCompact,
266
+ scrollIsolation: false
267
+ }
268
+ ) });
269
+ }, "CodeBlock");
270
+ var CodeBlockFallback = /* @__PURE__ */ __name(({ code, isUser }) => {
271
+ const copyHoverClass = isUser ? "hover:bg-white/20 text-white" : "hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground";
272
+ const copyButtonClass = `absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity h-8 w-8 ${copyHoverClass}`;
245
273
  return /* @__PURE__ */ jsxs("div", { className: "relative group my-3", children: [
246
274
  /* @__PURE__ */ jsx(
247
275
  CopyButton,
248
276
  {
249
277
  value: code,
250
278
  variant: "ghost",
251
- className: `
252
- absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity
253
- h-8 w-8
254
- ${isUser ? "hover:bg-white/20 text-white" : "hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground"}
255
- `,
279
+ className: copyButtonClass,
256
280
  title: "Copy code"
257
281
  }
258
282
  ),
259
- /* @__PURE__ */ jsx(
260
- PrettyCode_default,
261
- {
262
- data: code,
263
- language,
264
- className: isCompact ? "text-xs" : "text-sm",
265
- customBg: isUser ? "bg-white/10" : "bg-muted dark:bg-muted",
266
- mode: theme,
267
- isCompact
268
- }
269
- )
283
+ /* @__PURE__ */ jsx("pre", { className: "p-3 rounded text-xs font-mono overflow-x-auto bg-code text-code-foreground border border-code-border", children: /* @__PURE__ */ jsx("code", { children: code }) })
270
284
  ] });
271
- }, "CodeBlock");
272
- var CodeBlockFallback = /* @__PURE__ */ __name(({ code, isUser }) => /* @__PURE__ */ jsxs("div", { className: "relative group my-3", children: [
273
- /* @__PURE__ */ jsx(
274
- CopyButton,
275
- {
276
- value: code,
277
- variant: "ghost",
278
- className: `
279
- absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity
280
- h-8 w-8
281
- ${isUser ? "hover:bg-white/20 text-white" : "hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground"}
282
- `,
283
- title: "Copy code"
284
- }
285
- ),
286
- /* @__PURE__ */ jsx("pre", { className: `
287
- p-3 rounded text-xs font-mono overflow-x-auto
288
- ${isUser ? "bg-white/10 text-white" : "bg-muted text-foreground"}
289
- `, children: /* @__PURE__ */ jsx("code", { children: code }) })
290
- ] }), "CodeBlockFallback");
285
+ }, "CodeBlockFallback");
291
286
  function createMarkdownComponents(isUser = false, isCompact = false) {
292
287
  const textSize = isCompact ? "text-xs" : "text-sm";
293
288
  const headingBase = isCompact ? "text-sm" : "text-base";
@@ -333,7 +328,7 @@ function createMarkdownComponents(isUser = false, isCompact = false) {
333
328
  return /* @__PURE__ */ jsx("div", { className: "my-3 p-3 bg-muted rounded text-sm text-muted-foreground", children: "No content available" });
334
329
  }
335
330
  if (language === "mermaid") {
336
- return /* @__PURE__ */ jsx("div", { className: "my-3 max-w-full overflow-x-auto", children: /* @__PURE__ */ jsx(Mermaid_default, { chart: codeContent, className: "max-w-[600px] mx-auto", isCompact }) });
331
+ return /* @__PURE__ */ jsx("div", { className: "my-3 w-full", children: /* @__PURE__ */ jsx(Mermaid_default, { chart: codeContent, isCompact }) });
337
332
  }
338
333
  try {
339
334
  return /* @__PURE__ */ jsx(CodeBlock, { code: codeContent, language, isUser, isCompact });
@@ -346,16 +341,43 @@ function createMarkdownComponents(isUser = false, isCompact = false) {
346
341
  if (className?.includes("language-")) {
347
342
  return /* @__PURE__ */ jsx("code", { className, children });
348
343
  }
349
- return /* @__PURE__ */ jsx("code", { className: "px-1.5 py-0.5 rounded text-xs font-mono bg-muted text-foreground break-all", children: extractTextFromChildren(children) });
344
+ const inlineCodeClass = isUser ? "bg-primary-foreground/15 text-primary-foreground" : "bg-code-inline text-code-inline-foreground";
345
+ return /* @__PURE__ */ jsx("code", { className: `px-1 py-0.5 rounded font-mono text-[0.875em] ${inlineCodeClass} break-all`, children: extractTextFromChildren(children) });
350
346
  }, "code"),
351
- blockquote: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("blockquote", { className: `${textSize} border-l-2 border-border pl-3 my-2 italic text-muted-foreground break-words`, children }), "blockquote"),
347
+ // Modern chat convention drops italic on blockquotes italic +
348
+ // tight bubble = hard to read. Border-left at 2px (4px reads
349
+ // heavy in a 320–480px bubble). On the saturated user bubble we
350
+ // use a primary-foreground tint; on the assistant bubble we use
351
+ // the muted-foreground role for de-emphasis.
352
+ blockquote: /* @__PURE__ */ __name(({ children }) => {
353
+ const cls = isUser ? "border-primary-foreground/40 text-primary-foreground/80" : "border-border text-muted-foreground";
354
+ return /* @__PURE__ */ jsx("blockquote", { className: `${textSize} border-l-2 pl-3 my-3 break-words ${cls}`, children });
355
+ }, "blockquote"),
356
+ // Tables: outer wrapper handles overflow, inner `<table>`
357
+ // inherits the chat-density text size. Borders / header use
358
+ // semantic tokens — `border-code-border` for the assistant
359
+ // (matches the code-fence panel for visual cohesion when both
360
+ // appear in the same reply); primary-foreground/N for the user
361
+ // bubble so lines read against the saturated `bg-primary`.
352
362
  table: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("div", { className: "overflow-x-auto my-3", children: /* @__PURE__ */ jsx("table", { className: `min-w-full ${textSize} border-collapse`, children }) }), "table"),
353
- thead: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("thead", { className: "bg-muted/50", children }), "thead"),
363
+ thead: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("thead", { className: isUser ? "bg-primary-foreground/10" : "bg-muted/40", children }), "thead"),
354
364
  tbody: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("tbody", { children }), "tbody"),
355
- tr: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("tr", { className: "border-b border-border/50", children }), "tr"),
356
- th: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("th", { className: "px-2 py-1 text-left font-medium break-words", children }), "th"),
357
- td: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("td", { className: "px-2 py-1 break-words", children }), "td"),
358
- hr: /* @__PURE__ */ __name(() => /* @__PURE__ */ jsx("hr", { className: "my-3 border-0 h-px bg-border" }), "hr"),
365
+ tr: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("tr", { className: isUser ? "border-b border-primary-foreground/15" : "border-b border-border", children }), "tr"),
366
+ th: /* @__PURE__ */ __name(({ children }) => {
367
+ const borderCls = isUser ? "border-primary-foreground/25" : "border-border";
368
+ return /* @__PURE__ */ jsx("th", { className: `px-2 py-1.5 text-left font-semibold border-b ${borderCls} break-words`, children });
369
+ }, "th"),
370
+ td: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("td", { className: "px-2 py-1.5 break-words", children }), "td"),
371
+ // Soft separator. ChatGPT / Slack / Linear strip the visible
372
+ // line, Claude.ai keeps a hairline. We follow Claude — present
373
+ // but quiet. Palette switches by role so the hairline reads on
374
+ // both surfaces.
375
+ hr: /* @__PURE__ */ __name(() => /* @__PURE__ */ jsx(
376
+ "hr",
377
+ {
378
+ className: `my-4 border-0 h-px ${isUser ? "bg-primary-foreground/20" : "bg-border"}`
379
+ }
380
+ ), "hr"),
359
381
  strong: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("strong", { className: "font-semibold", children }), "strong"),
360
382
  em: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("em", { className: "italic", children }), "em")
361
383
  };
@@ -460,6 +482,7 @@ var MarkdownMessage = /* @__PURE__ */ __name(({
460
482
  className = "",
461
483
  isUser = false,
462
484
  isCompact = false,
485
+ plainText,
463
486
  customComponents,
464
487
  extraHrefProtocols,
465
488
  linkRules,
@@ -511,12 +534,16 @@ var MarkdownMessage = /* @__PURE__ */ __name(({
511
534
  );
512
535
  const textSizeClass = isCompact ? "text-xs" : "text-sm";
513
536
  const proseClass = isCompact ? "prose-xs" : "prose-sm";
514
- const isPlainText = !effectiveCustomComponents && !hasMarkdownSyntax(displayContent);
537
+ const customComponentsBeyondLinks = React6.useMemo(() => {
538
+ if (!customComponents) return false;
539
+ return Object.keys(customComponents).some((k) => k !== "a");
540
+ }, [customComponents]);
541
+ const isPlainText = plainText !== void 0 ? plainText : !customComponentsBeyondLinks && looksLikePlainProse(displayContent);
515
542
  if (isPlainText) {
516
543
  return /* @__PURE__ */ jsxs(
517
- "span",
544
+ "div",
518
545
  {
519
- className: `${textSizeClass} leading-7 break-words whitespace-pre-line font-light ${className}`,
546
+ className: `${textSizeClass} leading-snug break-words whitespace-pre-wrap ${className}`,
520
547
  children: [
521
548
  displayContent,
522
549
  collapsible && shouldCollapse && /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -544,7 +571,16 @@ var MarkdownMessage = /* @__PURE__ */ __name(({
544
571
  className: `
545
572
  prose ${proseClass} max-w-none break-words overflow-hidden ${textSizeClass}
546
573
  ${isUser ? "prose-invert" : "dark:prose-invert"}
547
- [&>*]:leading-7
574
+ [&>*]:leading-relaxed
575
+ [&>*:first-child]:mt-0 [&>*:last-child]:mb-0
576
+ [&_p]:my-2
577
+ [&_ul]:my-2 [&_ol]:my-2 [&_ul]:pl-5 [&_ol]:pl-5
578
+ [&_li]:my-1 [&_li>p]:my-0
579
+ [&_pre]:my-3
580
+ [&_h1]:mt-4 [&_h1]:mb-2 [&_h1]:text-base [&_h1]:font-semibold
581
+ [&_h2]:mt-3.5 [&_h2]:mb-1.5 [&_h2]:text-[15px] [&_h2]:font-semibold
582
+ [&_h3]:mt-3 [&_h3]:mb-1 [&_h3]:text-sm [&_h3]:font-medium
583
+ [&_h4]:mt-3 [&_h4]:mb-1 [&_h4]:text-sm [&_h4]:font-medium
548
584
  `,
549
585
  style: {
550
586
  // Inherit colors from parent — fixes issues with external
@@ -1505,5 +1541,5 @@ var PlaygroundProvider = /* @__PURE__ */ __name(({ children, config }) => {
1505
1541
  }, "PlaygroundProvider");
1506
1542
 
1507
1543
  export { CODE_SAMPLE_TARGETS, MarkdownMessage, Mermaid_default, PlaygroundProvider, PrettyCode_default, UrlBuilder, buildHarRequest, deduplicateEndpoints, dereferenceSchema, endpointToMarkdown, extractTextFromChildren, findApiKeyById, formatBytes, isValidJson, joinUrl, parseRequestHeaders, relativePath, renderSnippet, resolveAbsolute, resolveBaseUrl, sampleSchemaJson, toCompactJson, toMarkdown, toRawJson, useCollapsibleContent, usePlaygroundContext };
1508
- //# sourceMappingURL=chunk-CKD7GNE5.mjs.map
1509
- //# sourceMappingURL=chunk-CKD7GNE5.mjs.map
1544
+ //# sourceMappingURL=chunk-K35OF7OB.mjs.map
1545
+ //# sourceMappingURL=chunk-K35OF7OB.mjs.map