@bergetai/ui 0.22.0 → 0.23.0
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/dist/components/markdown/Markdown.cjs +13 -29
- package/dist/components/markdown/Markdown.cjs.map +1 -1
- package/dist/components/markdown/Markdown.d.cts.map +1 -1
- package/dist/components/markdown/Markdown.d.mts.map +1 -1
- package/dist/components/markdown/Markdown.mjs +13 -29
- package/dist/components/markdown/Markdown.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -24,39 +24,27 @@ let streamdown = require("streamdown");
|
|
|
24
24
|
const bergetComponents = {
|
|
25
25
|
h1: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h1, {
|
|
26
26
|
...props,
|
|
27
|
-
className: `
|
|
28
|
-
mt-4 mb-2 text-lg font-semibold
|
|
29
|
-
`
|
|
27
|
+
className: `mt-4 mb-2 text-lg font-semibold`
|
|
30
28
|
}),
|
|
31
29
|
h2: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h2, {
|
|
32
30
|
...props,
|
|
33
|
-
className: `
|
|
34
|
-
mt-4 mb-2 text-base font-semibold
|
|
35
|
-
`
|
|
31
|
+
className: `mt-4 mb-2 text-base font-semibold`
|
|
36
32
|
}),
|
|
37
33
|
h3: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h3, {
|
|
38
34
|
...props,
|
|
39
|
-
className: `
|
|
40
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
41
|
-
`
|
|
35
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
42
36
|
}),
|
|
43
37
|
h4: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h4, {
|
|
44
38
|
...props,
|
|
45
|
-
className: `
|
|
46
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
47
|
-
`
|
|
39
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
48
40
|
}),
|
|
49
41
|
h5: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h5, {
|
|
50
42
|
...props,
|
|
51
|
-
className: `
|
|
52
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
53
|
-
`
|
|
43
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
54
44
|
}),
|
|
55
45
|
h6: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h6, {
|
|
56
46
|
...props,
|
|
57
|
-
className: `
|
|
58
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
59
|
-
`
|
|
47
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
60
48
|
}),
|
|
61
49
|
p: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.p, {
|
|
62
50
|
...props,
|
|
@@ -75,9 +63,7 @@ const bergetComponents = {
|
|
|
75
63
|
}),
|
|
76
64
|
ol: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.ol, {
|
|
77
65
|
...props,
|
|
78
|
-
className: `
|
|
79
|
-
my-2 ms-5 list-decimal space-y-1
|
|
80
|
-
`
|
|
66
|
+
className: `my-2 ms-5 list-decimal space-y-1`
|
|
81
67
|
}),
|
|
82
68
|
li: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.li, {
|
|
83
69
|
...props,
|
|
@@ -94,14 +80,13 @@ const bergetComponents = {
|
|
|
94
80
|
blockquote: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.blockquote, {
|
|
95
81
|
...props,
|
|
96
82
|
className: `
|
|
97
|
-
my-3 border-berget-border ps-3 text-berget-muted-foreground
|
|
83
|
+
my-3 border-l-4 border-berget-border ps-3 text-berget-muted-foreground
|
|
84
|
+
italic
|
|
98
85
|
`
|
|
99
86
|
}),
|
|
100
87
|
hr: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.hr, {
|
|
101
88
|
...props,
|
|
102
|
-
className: `
|
|
103
|
-
my-4 border-berget-border
|
|
104
|
-
`
|
|
89
|
+
className: `my-4 border-berget-border`
|
|
105
90
|
}),
|
|
106
91
|
img: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.img, {
|
|
107
92
|
...props,
|
|
@@ -132,7 +117,8 @@ const bergetComponents = {
|
|
|
132
117
|
},
|
|
133
118
|
table: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
134
119
|
className: `
|
|
135
|
-
my-3 max-w-full overflow-x-auto rounded-berget-xs border
|
|
120
|
+
my-3 max-w-full overflow-x-auto rounded-berget-xs border
|
|
121
|
+
border-berget-border
|
|
136
122
|
`,
|
|
137
123
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("table", {
|
|
138
124
|
...props,
|
|
@@ -149,9 +135,7 @@ const bergetComponents = {
|
|
|
149
135
|
}),
|
|
150
136
|
td: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.td, {
|
|
151
137
|
...props,
|
|
152
|
-
className: `
|
|
153
|
-
border-b-berget-border px-3 py-1.5
|
|
154
|
-
`
|
|
138
|
+
className: `border-b-berget-border px-3 py-1.5`
|
|
155
139
|
})
|
|
156
140
|
};
|
|
157
141
|
function Markdown({ className, ...props }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.cjs","names":["defaultComponents","React","MarkdownCodeBlock","Streamdown","cn"],"sources":["../../../src/components/markdown/Markdown.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Streamdown, defaultComponents, type Components, type StreamdownProps } from 'streamdown';\nimport { cn } from '../../lib/utils';\nimport { MarkdownCodeBlock } from './MarkdownCodeBlock';\n\n/**\n * Markdown renderer for chat/UI text, built on Streamdown (incomplete-markdown\n * repair during streaming, GFM tables, rehype-sanitize + rehype-harden).\n *\n * Streamdown ships its own Tailwind classes inside its dist files, which\n * consumers' Tailwind builds never scan — so every element is given a full\n * Berget class set here instead of relying on the defaults. Utility classes\n * used below live in this package's own dist, which the shipped `@source`\n * covers for all consumers.\n *\n * Code highlighting reuses the package CodeBlock family and the shared Shiki\n * highlighter (Berget CSS-variable theme). Mermaid/KaTeX are intentionally\n * not enabled.\n */\nconst bergetComponents: Components = {\n h1: (props) =>
|
|
1
|
+
{"version":3,"file":"Markdown.cjs","names":["defaultComponents","React","MarkdownCodeBlock","Streamdown","cn"],"sources":["../../../src/components/markdown/Markdown.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Streamdown, defaultComponents, type Components, type StreamdownProps } from 'streamdown';\nimport { cn } from '../../lib/utils';\nimport { MarkdownCodeBlock } from './MarkdownCodeBlock';\n\n/**\n * Markdown renderer for chat/UI text, built on Streamdown (incomplete-markdown\n * repair during streaming, GFM tables, rehype-sanitize + rehype-harden).\n *\n * Streamdown ships its own Tailwind classes inside its dist files, which\n * consumers' Tailwind builds never scan — so every element is given a full\n * Berget class set here instead of relying on the defaults. Utility classes\n * used below live in this package's own dist, which the shipped `@source`\n * covers for all consumers.\n *\n * Code highlighting reuses the package CodeBlock family and the shared Shiki\n * highlighter (Berget CSS-variable theme). Mermaid/KaTeX are intentionally\n * not enabled.\n */\nconst bergetComponents: Components = {\n h1: (props) => <defaultComponents.h1 {...props} className={`mt-4 mb-2 text-lg font-semibold`} />,\n h2: (props) => (\n <defaultComponents.h2 {...props} className={`mt-4 mb-2 text-base font-semibold`} />\n ),\n h3: (props) => (\n <defaultComponents.h3 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\n ),\n h4: (props) => (\n <defaultComponents.h4 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\n ),\n h5: (props) => (\n <defaultComponents.h5 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\n ),\n h6: (props) => (\n <defaultComponents.h6 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\n ),\n p: (props) => (\n <defaultComponents.p\n {...props}\n className={`\n my-2\n first:mt-0\n last:mb-0\n `}\n />\n ),\n ul: (props) => (\n <defaultComponents.ul\n {...props}\n className={`\n my-2 ms-5 list-disc space-y-1\n marker:text-berget-muted-foreground\n `}\n />\n ),\n ol: (props) => <defaultComponents.ol {...props} className={`my-2 ms-5 list-decimal space-y-1`} />,\n li: (props) => <defaultComponents.li {...props} className={`leading-relaxed`} />,\n del: (props) => <del {...props} className={`line-through`} />,\n em: (props) => <em {...props} className={`italic`} />,\n blockquote: (props) => (\n <defaultComponents.blockquote\n {...props}\n className={`\n my-3 border-l-4 border-berget-border ps-3 text-berget-muted-foreground\n italic\n `}\n />\n ),\n hr: (props) => <defaultComponents.hr {...props} className={`my-4 border-berget-border`} />,\n img: (props) => (\n <defaultComponents.img\n {...props}\n className={`my-3 max-w-full rounded-berget-xs border-berget-border`}\n />\n ),\n // Real anchor, not Streamdown's default <button>: links must keep href\n // semantics (middle-click, new tab). Hardening attrs are added explicitly\n // since rehype-harden can only act on real anchors.\n a: ({ node: _node, ...props }) => (\n <a\n {...props}\n target=\"_blank\"\n rel=\"noopener noreferrer nofollow\"\n className={`text-berget-primary underline underline-offset-2`}\n />\n ),\n // Inline code only — fenced blocks are consumed by the `pre` override below.\n code: (props) => (\n <defaultComponents.code\n {...props}\n className={`\n rounded-berget-xs bg-muted px-1.5 py-0.5 font-mono text-[0.85em]\n `}\n />\n ),\n // Fenced / indented code: derive code + language from the child code\n // element and render with the package CodeBlock (highlighting included).\n pre: ({ children }) => {\n if (React.isValidElement(children)) {\n const { className, children: code } = children.props as {\n className?: string;\n children?: React.ReactNode;\n };\n const language = /language-([\\w+-]+)/.exec(className ?? '')?.[1] ?? 'text';\n return <MarkdownCodeBlock code={String(code ?? '')} language={language} />;\n }\n return <>{children}</>;\n },\n table: (props) => (\n <div\n className={`\n my-3 max-w-full overflow-x-auto rounded-berget-xs border\n border-berget-border\n `}\n >\n <table {...props} className={`w-full border-collapse text-sm`} />\n </div>\n ),\n thead: (props) => <defaultComponents.thead {...props} className={`bg-muted/50`} />,\n th: (props) => (\n <defaultComponents.th\n {...props}\n className={`border-b-berget-border px-3 py-1.5 text-start font-semibold`}\n />\n ),\n td: (props) => (\n <defaultComponents.td {...props} className={`border-b-berget-border px-3 py-1.5`} />\n ),\n};\n\ntype MarkdownProps = Omit<StreamdownProps, 'components' | 'plugins' | 'dir' | 'prefix'>;\nexport type { MarkdownProps };\n\nexport function Markdown({ className, ...props }: MarkdownProps) {\n return (\n <Streamdown\n {...props}\n dir=\"ltr\"\n components={bergetComponents}\n className={cn('text-caption/relaxed text-berget-foreground', className)}\n />\n );\n}\n\nMarkdown.displayName = 'Markdown';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,mBAA+B;CACnC,KAAK,UAAU,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAoC,CAAA;CAC/F,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,IAAI,U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rB,IAAIC,MAAM,eAAe,QAAQ,GAAG;GAClC,MAAM,EAAE,WAAW,UAAU,SAAS,SAAS;GAI/C,MAAM,WAAW,qBAAqB,KAAK,aAAa,EAAE,CAAC,GAAG,MAAM;GACpE,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,0BAAAA,mBAAD;IAAmB,MAAM,OAAO,QAAQ,EAAE;IAAa;GAAW,CAAA;EAC3E;EACA,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAA,kBAAA,UAAA,EAAG,SAAW,CAAA;CACvB;CACA,QAAQ,UACN,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,WAAW;;;;EAKX,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;GAAO,GAAI;GAAO,WAAW;EAAmC,CAAA;CAC7D,CAAA;CAEP,QAAQ,UAAU,iBAAA,GAAA,kBAAA,IAAA,CAACF,WAAAA,kBAAkB,OAAnB;EAAyB,GAAI;EAAO,WAAW;CAAgB,CAAA;CACjF,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EACE,GAAI;EACJ,WAAW;CACZ,CAAA;CAEH,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAuC,CAAA;AAEvF;AAKA,SAAgB,SAAS,EAAE,WAAW,GAAG,SAAwB;CAC/D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACG,WAAAA,YAAD;EACE,GAAI;EACJ,KAAI;EACJ,YAAY;EACZ,WAAWC,cAAAA,GAAG,+CAA+C,SAAS;CACvE,CAAA;AAEL;AAEA,SAAS,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.d.cts","names":[],"sources":["../../../src/components/markdown/Markdown.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Markdown.d.cts","names":[],"sources":["../../../src/components/markdown/Markdown.tsx"],"mappings":";;KAoIK,gBAAgB,KAAK;wBAGV,WAAW,cAAc,SAAS,4CAAa,IAAA;yBAA/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.d.mts","names":[],"sources":["../../../src/components/markdown/Markdown.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Markdown.d.mts","names":[],"sources":["../../../src/components/markdown/Markdown.tsx"],"mappings":";;KAoIK,gBAAgB,KAAK;wBAGV,WAAW,cAAc,SAAS,4CAAa,IAAA;yBAA/C"}
|
|
@@ -22,39 +22,27 @@ import { Streamdown, defaultComponents } from "streamdown";
|
|
|
22
22
|
const bergetComponents = {
|
|
23
23
|
h1: (props) => /* @__PURE__ */ jsx(defaultComponents.h1, {
|
|
24
24
|
...props,
|
|
25
|
-
className: `
|
|
26
|
-
mt-4 mb-2 text-lg font-semibold
|
|
27
|
-
`
|
|
25
|
+
className: `mt-4 mb-2 text-lg font-semibold`
|
|
28
26
|
}),
|
|
29
27
|
h2: (props) => /* @__PURE__ */ jsx(defaultComponents.h2, {
|
|
30
28
|
...props,
|
|
31
|
-
className: `
|
|
32
|
-
mt-4 mb-2 text-base font-semibold
|
|
33
|
-
`
|
|
29
|
+
className: `mt-4 mb-2 text-base font-semibold`
|
|
34
30
|
}),
|
|
35
31
|
h3: (props) => /* @__PURE__ */ jsx(defaultComponents.h3, {
|
|
36
32
|
...props,
|
|
37
|
-
className: `
|
|
38
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
39
|
-
`
|
|
33
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
40
34
|
}),
|
|
41
35
|
h4: (props) => /* @__PURE__ */ jsx(defaultComponents.h4, {
|
|
42
36
|
...props,
|
|
43
|
-
className: `
|
|
44
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
45
|
-
`
|
|
37
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
46
38
|
}),
|
|
47
39
|
h5: (props) => /* @__PURE__ */ jsx(defaultComponents.h5, {
|
|
48
40
|
...props,
|
|
49
|
-
className: `
|
|
50
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
51
|
-
`
|
|
41
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
52
42
|
}),
|
|
53
43
|
h6: (props) => /* @__PURE__ */ jsx(defaultComponents.h6, {
|
|
54
44
|
...props,
|
|
55
|
-
className: `
|
|
56
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
57
|
-
`
|
|
45
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
58
46
|
}),
|
|
59
47
|
p: (props) => /* @__PURE__ */ jsx(defaultComponents.p, {
|
|
60
48
|
...props,
|
|
@@ -73,9 +61,7 @@ const bergetComponents = {
|
|
|
73
61
|
}),
|
|
74
62
|
ol: (props) => /* @__PURE__ */ jsx(defaultComponents.ol, {
|
|
75
63
|
...props,
|
|
76
|
-
className: `
|
|
77
|
-
my-2 ms-5 list-decimal space-y-1
|
|
78
|
-
`
|
|
64
|
+
className: `my-2 ms-5 list-decimal space-y-1`
|
|
79
65
|
}),
|
|
80
66
|
li: (props) => /* @__PURE__ */ jsx(defaultComponents.li, {
|
|
81
67
|
...props,
|
|
@@ -92,14 +78,13 @@ const bergetComponents = {
|
|
|
92
78
|
blockquote: (props) => /* @__PURE__ */ jsx(defaultComponents.blockquote, {
|
|
93
79
|
...props,
|
|
94
80
|
className: `
|
|
95
|
-
my-3 border-berget-border ps-3 text-berget-muted-foreground
|
|
81
|
+
my-3 border-l-4 border-berget-border ps-3 text-berget-muted-foreground
|
|
82
|
+
italic
|
|
96
83
|
`
|
|
97
84
|
}),
|
|
98
85
|
hr: (props) => /* @__PURE__ */ jsx(defaultComponents.hr, {
|
|
99
86
|
...props,
|
|
100
|
-
className: `
|
|
101
|
-
my-4 border-berget-border
|
|
102
|
-
`
|
|
87
|
+
className: `my-4 border-berget-border`
|
|
103
88
|
}),
|
|
104
89
|
img: (props) => /* @__PURE__ */ jsx(defaultComponents.img, {
|
|
105
90
|
...props,
|
|
@@ -130,7 +115,8 @@ const bergetComponents = {
|
|
|
130
115
|
},
|
|
131
116
|
table: (props) => /* @__PURE__ */ jsx("div", {
|
|
132
117
|
className: `
|
|
133
|
-
my-3 max-w-full overflow-x-auto rounded-berget-xs border
|
|
118
|
+
my-3 max-w-full overflow-x-auto rounded-berget-xs border
|
|
119
|
+
border-berget-border
|
|
134
120
|
`,
|
|
135
121
|
children: /* @__PURE__ */ jsx("table", {
|
|
136
122
|
...props,
|
|
@@ -147,9 +133,7 @@ const bergetComponents = {
|
|
|
147
133
|
}),
|
|
148
134
|
td: (props) => /* @__PURE__ */ jsx(defaultComponents.td, {
|
|
149
135
|
...props,
|
|
150
|
-
className: `
|
|
151
|
-
border-b-berget-border px-3 py-1.5
|
|
152
|
-
`
|
|
136
|
+
className: `border-b-berget-border px-3 py-1.5`
|
|
153
137
|
})
|
|
154
138
|
};
|
|
155
139
|
function Markdown({ className, ...props }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.mjs","names":[],"sources":["../../../src/components/markdown/Markdown.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Streamdown, defaultComponents, type Components, type StreamdownProps } from 'streamdown';\nimport { cn } from '../../lib/utils';\nimport { MarkdownCodeBlock } from './MarkdownCodeBlock';\n\n/**\n * Markdown renderer for chat/UI text, built on Streamdown (incomplete-markdown\n * repair during streaming, GFM tables, rehype-sanitize + rehype-harden).\n *\n * Streamdown ships its own Tailwind classes inside its dist files, which\n * consumers' Tailwind builds never scan — so every element is given a full\n * Berget class set here instead of relying on the defaults. Utility classes\n * used below live in this package's own dist, which the shipped `@source`\n * covers for all consumers.\n *\n * Code highlighting reuses the package CodeBlock family and the shared Shiki\n * highlighter (Berget CSS-variable theme). Mermaid/KaTeX are intentionally\n * not enabled.\n */\nconst bergetComponents: Components = {\n h1: (props) =>
|
|
1
|
+
{"version":3,"file":"Markdown.mjs","names":[],"sources":["../../../src/components/markdown/Markdown.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Streamdown, defaultComponents, type Components, type StreamdownProps } from 'streamdown';\nimport { cn } from '../../lib/utils';\nimport { MarkdownCodeBlock } from './MarkdownCodeBlock';\n\n/**\n * Markdown renderer for chat/UI text, built on Streamdown (incomplete-markdown\n * repair during streaming, GFM tables, rehype-sanitize + rehype-harden).\n *\n * Streamdown ships its own Tailwind classes inside its dist files, which\n * consumers' Tailwind builds never scan — so every element is given a full\n * Berget class set here instead of relying on the defaults. Utility classes\n * used below live in this package's own dist, which the shipped `@source`\n * covers for all consumers.\n *\n * Code highlighting reuses the package CodeBlock family and the shared Shiki\n * highlighter (Berget CSS-variable theme). Mermaid/KaTeX are intentionally\n * not enabled.\n */\nconst bergetComponents: Components = {\n h1: (props) => <defaultComponents.h1 {...props} className={`mt-4 mb-2 text-lg font-semibold`} />,\n h2: (props) => (\n <defaultComponents.h2 {...props} className={`mt-4 mb-2 text-base font-semibold`} />\n ),\n h3: (props) => (\n <defaultComponents.h3 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\n ),\n h4: (props) => (\n <defaultComponents.h4 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\n ),\n h5: (props) => (\n <defaultComponents.h5 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\n ),\n h6: (props) => (\n <defaultComponents.h6 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\n ),\n p: (props) => (\n <defaultComponents.p\n {...props}\n className={`\n my-2\n first:mt-0\n last:mb-0\n `}\n />\n ),\n ul: (props) => (\n <defaultComponents.ul\n {...props}\n className={`\n my-2 ms-5 list-disc space-y-1\n marker:text-berget-muted-foreground\n `}\n />\n ),\n ol: (props) => <defaultComponents.ol {...props} className={`my-2 ms-5 list-decimal space-y-1`} />,\n li: (props) => <defaultComponents.li {...props} className={`leading-relaxed`} />,\n del: (props) => <del {...props} className={`line-through`} />,\n em: (props) => <em {...props} className={`italic`} />,\n blockquote: (props) => (\n <defaultComponents.blockquote\n {...props}\n className={`\n my-3 border-l-4 border-berget-border ps-3 text-berget-muted-foreground\n italic\n `}\n />\n ),\n hr: (props) => <defaultComponents.hr {...props} className={`my-4 border-berget-border`} />,\n img: (props) => (\n <defaultComponents.img\n {...props}\n className={`my-3 max-w-full rounded-berget-xs border-berget-border`}\n />\n ),\n // Real anchor, not Streamdown's default <button>: links must keep href\n // semantics (middle-click, new tab). Hardening attrs are added explicitly\n // since rehype-harden can only act on real anchors.\n a: ({ node: _node, ...props }) => (\n <a\n {...props}\n target=\"_blank\"\n rel=\"noopener noreferrer nofollow\"\n className={`text-berget-primary underline underline-offset-2`}\n />\n ),\n // Inline code only — fenced blocks are consumed by the `pre` override below.\n code: (props) => (\n <defaultComponents.code\n {...props}\n className={`\n rounded-berget-xs bg-muted px-1.5 py-0.5 font-mono text-[0.85em]\n `}\n />\n ),\n // Fenced / indented code: derive code + language from the child code\n // element and render with the package CodeBlock (highlighting included).\n pre: ({ children }) => {\n if (React.isValidElement(children)) {\n const { className, children: code } = children.props as {\n className?: string;\n children?: React.ReactNode;\n };\n const language = /language-([\\w+-]+)/.exec(className ?? '')?.[1] ?? 'text';\n return <MarkdownCodeBlock code={String(code ?? '')} language={language} />;\n }\n return <>{children}</>;\n },\n table: (props) => (\n <div\n className={`\n my-3 max-w-full overflow-x-auto rounded-berget-xs border\n border-berget-border\n `}\n >\n <table {...props} className={`w-full border-collapse text-sm`} />\n </div>\n ),\n thead: (props) => <defaultComponents.thead {...props} className={`bg-muted/50`} />,\n th: (props) => (\n <defaultComponents.th\n {...props}\n className={`border-b-berget-border px-3 py-1.5 text-start font-semibold`}\n />\n ),\n td: (props) => (\n <defaultComponents.td {...props} className={`border-b-berget-border px-3 py-1.5`} />\n ),\n};\n\ntype MarkdownProps = Omit<StreamdownProps, 'components' | 'plugins' | 'dir' | 'prefix'>;\nexport type { MarkdownProps };\n\nexport function Markdown({ className, ...props }: MarkdownProps) {\n return (\n <Streamdown\n {...props}\n dir=\"ltr\"\n components={bergetComponents}\n className={cn('text-caption/relaxed text-berget-foreground', className)}\n />\n );\n}\n\nMarkdown.displayName = 'Markdown';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,mBAA+B;CACnC,KAAK,UAAU,oBAAC,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAoC,CAAA;CAC/F,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,IAAI,UACF,oBAAC,kBAAkB,GAAnB;EACE,GAAI;EACJ,WAAW;;;;;CAKZ,CAAA;CAEH,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EACE,GAAI;EACJ,WAAW;;;;CAIZ,CAAA;CAEH,KAAK,UAAU,oBAAC,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAqC,CAAA;CAChG,KAAK,UAAU,oBAAC,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAoB,CAAA;CAC/E,MAAM,UAAU,oBAAC,OAAD;EAAK,GAAI;EAAO,WAAW;CAAiB,CAAA;CAC5D,KAAK,UAAU,oBAAC,MAAD;EAAI,GAAI;EAAO,WAAW;CAAW,CAAA;CACpD,aAAa,UACX,oBAAC,kBAAkB,YAAnB;EACE,GAAI;EACJ,WAAW;;;;CAIZ,CAAA;CAEH,KAAK,UAAU,oBAAC,kBAAkB,IAAnB;EAA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