@mintlify/msft-sdk 1.1.52 → 1.1.54
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/content-components/callouts.js +2 -2
- package/dist/components/content-components/callouts.js.map +1 -1
- package/dist/components/content-components/code-block.js +110 -87
- package/dist/components/content-components/code-block.js.map +1 -1
- package/dist/components/content-components/code-group.js +25 -25
- package/dist/components/content-components/code-group.js.map +1 -1
- package/dist/components/content-components/table/index.js +2 -2
- package/dist/components/content-components/table/index.js.map +1 -1
- package/dist/components/content-components/tabs/tabs.js +16 -16
- package/dist/components/content-components/tabs/tabs.js.map +1 -1
- package/dist/components/nav-tree/index.js +125 -115
- package/dist/components/nav-tree/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/styles.css +1 -1
- package/dist/utils/getScrollbarClassname.js +9 -0
- package/dist/utils/getScrollbarClassname.js.map +1 -0
- package/package.json +2 -1
|
@@ -49,12 +49,12 @@ function h({ type: i, children: e }) {
|
|
|
49
49
|
n.icon && /* @__PURE__ */ t(
|
|
50
50
|
"div",
|
|
51
51
|
{
|
|
52
|
-
className: "mint:flex mint:items-start mint:
|
|
52
|
+
className: "mint:flex mint:items-start mint:pt-0.5",
|
|
53
53
|
"aria-hidden": "true",
|
|
54
54
|
children: n.icon
|
|
55
55
|
}
|
|
56
56
|
),
|
|
57
|
-
/* @__PURE__ */ t("div", { className: "mint:text-sm mint:min-w-0 mint:w-full mint:max-w-none mint:prose mint:dark:prose-invert", children: e })
|
|
57
|
+
/* @__PURE__ */ t("div", { className: "mint:text-sm mint:min-w-0 mint:w-full mint:max-w-none mint:prose mint:dark:prose-invert [&>ul]:!mt-0 [&>ol]:!mt-0", children: e })
|
|
58
58
|
]
|
|
59
59
|
}
|
|
60
60
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callouts.js","sources":["../../../src/components/content-components/callouts.tsx"],"sourcesContent":["import {\n Lightbulb20Regular,\n InfoFilled,\n Warning20Regular,\n DismissCircle20Regular,\n Info20Regular,\n} from '@fluentui/react-icons';\n\nimport { cn } from '../../utils/cn';\n\nexport type CalloutType = 'note' | 'tip' | 'important' | 'caution' | 'warning' | 'nextstepaction';\n\ninterface CalloutProps {\n type: CalloutType;\n children: React.ReactNode;\n}\n\nconst calloutConfig: Record<\n CalloutType,\n {\n icon?: React.ReactNode;\n className: string;\n }\n> = {\n tip: {\n icon: <Lightbulb20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n 'mint:bg-[#f1faf1] mint:border-[#9fd89f] mint:text-[#0c5e0c] mint:dark:bg-[#052505] mint:dark:border-[#54b054] mint:dark:text-[#54b054]',\n },\n note: {\n icon: <Info20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n 'mint:bg-[#f5f5f5] mint:border-[#d1d1d1] mint:text-[#242424] mint:dark:bg-[#141414] mint:dark:border-[#666666] mint:dark:text-white',\n },\n warning: {\n icon: <Warning20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n 'mint:bg-[#fff9f5] mint:border-[#fdcfb4] mint:text-[#8a3707] mint:dark:bg-[#4a1e04] mint:dark:border-[#de590b] mint:dark:text-[#faa06b]',\n },\n caution: {\n icon: <DismissCircle20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n 'mint:bg-[#fdf3f4] mint:border-[#eeacb2] mint:text-[#960b18] mint:dark:bg-[#3b0509] mint:dark:border-[#c50f1f] mint:dark:text-[#dc626d]',\n },\n important: {\n icon: <Warning20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n 'mint:bg-[#e1cefc] mint:border-[#8251ee] mint:text-[#643fb2] mint:dark:bg-[#1a1326] mint:dark:border-[#9263f1] mint:dark:text-[#9263f1]',\n },\n nextstepaction: {\n icon: (\n <InfoFilled className=\"mint:w-5 mint:h-5 mint:shrink-0 mint:text-[#616161] mint:dark:text-white\" />\n ),\n className:\n 'mint:bg-[#f9fafb] mint:border-[#d1d1d1] mint:text-[#141414] mint:dark:bg-[#141414] mint:dark:border-[#666666] mint:dark:text-white',\n },\n};\n\nconst calloutLabels: Record<CalloutType, string> = {\n note: 'Note',\n tip: 'Tip',\n important: 'Important',\n caution: 'Caution',\n warning: 'Warning',\n nextstepaction: 'Next step action',\n};\n\nexport function Callout({ type, children }: CalloutProps) {\n const config = calloutConfig[type];\n const label = calloutLabels[type];\n\n return (\n <aside\n role=\"note\"\n aria-label={label}\n className={cn(\n 'mint:my-4 mint:flex mint:gap-2 mint:px-3 mint:py-2.5 mint:rounded-lg mint:border mint:overflow-hidden',\n config.className\n )}\n >\n {config.icon && (\n <div\n className=\"mint:flex mint:items-start mint:
|
|
1
|
+
{"version":3,"file":"callouts.js","sources":["../../../src/components/content-components/callouts.tsx"],"sourcesContent":["import {\n Lightbulb20Regular,\n InfoFilled,\n Warning20Regular,\n DismissCircle20Regular,\n Info20Regular,\n} from '@fluentui/react-icons';\n\nimport { cn } from '../../utils/cn';\n\nexport type CalloutType = 'note' | 'tip' | 'important' | 'caution' | 'warning' | 'nextstepaction';\n\ninterface CalloutProps {\n type: CalloutType;\n children: React.ReactNode;\n}\n\nconst calloutConfig: Record<\n CalloutType,\n {\n icon?: React.ReactNode;\n className: string;\n }\n> = {\n tip: {\n icon: <Lightbulb20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n 'mint:bg-[#f1faf1] mint:border-[#9fd89f] mint:text-[#0c5e0c] mint:dark:bg-[#052505] mint:dark:border-[#54b054] mint:dark:text-[#54b054]',\n },\n note: {\n icon: <Info20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n 'mint:bg-[#f5f5f5] mint:border-[#d1d1d1] mint:text-[#242424] mint:dark:bg-[#141414] mint:dark:border-[#666666] mint:dark:text-white',\n },\n warning: {\n icon: <Warning20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n 'mint:bg-[#fff9f5] mint:border-[#fdcfb4] mint:text-[#8a3707] mint:dark:bg-[#4a1e04] mint:dark:border-[#de590b] mint:dark:text-[#faa06b]',\n },\n caution: {\n icon: <DismissCircle20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n 'mint:bg-[#fdf3f4] mint:border-[#eeacb2] mint:text-[#960b18] mint:dark:bg-[#3b0509] mint:dark:border-[#c50f1f] mint:dark:text-[#dc626d]',\n },\n important: {\n icon: <Warning20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n 'mint:bg-[#e1cefc] mint:border-[#8251ee] mint:text-[#643fb2] mint:dark:bg-[#1a1326] mint:dark:border-[#9263f1] mint:dark:text-[#9263f1]',\n },\n nextstepaction: {\n icon: (\n <InfoFilled className=\"mint:w-5 mint:h-5 mint:shrink-0 mint:text-[#616161] mint:dark:text-white\" />\n ),\n className:\n 'mint:bg-[#f9fafb] mint:border-[#d1d1d1] mint:text-[#141414] mint:dark:bg-[#141414] mint:dark:border-[#666666] mint:dark:text-white',\n },\n};\n\nconst calloutLabels: Record<CalloutType, string> = {\n note: 'Note',\n tip: 'Tip',\n important: 'Important',\n caution: 'Caution',\n warning: 'Warning',\n nextstepaction: 'Next step action',\n};\n\nexport function Callout({ type, children }: CalloutProps) {\n const config = calloutConfig[type];\n const label = calloutLabels[type];\n\n return (\n <aside\n role=\"note\"\n aria-label={label}\n className={cn(\n 'mint:my-4 mint:flex mint:gap-2 mint:px-3 mint:py-2.5 mint:rounded-lg mint:border mint:overflow-hidden',\n config.className\n )}\n >\n {config.icon && (\n <div\n className=\"mint:flex mint:items-start mint:pt-0.5\"\n aria-hidden=\"true\"\n >\n {config.icon}\n </div>\n )}\n <div className=\"mint:text-sm mint:min-w-0 mint:w-full mint:max-w-none mint:prose mint:dark:prose-invert [&>ul]:!mt-0 [&>ol]:!mt-0\">\n {children}\n </div>\n </aside>\n );\n}\n"],"names":["calloutConfig","jsx","Lightbulb20Regular","Info20Regular","Warning20Regular","DismissCircle20Regular","InfoFilled","calloutLabels","Callout","type","children","config","label","jsxs","cn"],"mappings":";;;AAiBA,MAAMA,IAMF;AAAA,EACF,KAAK;AAAA,IACH,MAAM,gBAAAC,EAACC,GAAA,EAAmB,WAAU,kCAAA,CAAkC;AAAA,IACtE,WACE;AAAA,EAAA;AAAA,EAEJ,MAAM;AAAA,IACJ,MAAM,gBAAAD,EAACE,GAAA,EAAc,WAAU,kCAAA,CAAkC;AAAA,IACjE,WACE;AAAA,EAAA;AAAA,EAEJ,SAAS;AAAA,IACP,MAAM,gBAAAF,EAACG,GAAA,EAAiB,WAAU,kCAAA,CAAkC;AAAA,IACpE,WACE;AAAA,EAAA;AAAA,EAEJ,SAAS;AAAA,IACP,MAAM,gBAAAH,EAACI,GAAA,EAAuB,WAAU,kCAAA,CAAkC;AAAA,IAC1E,WACE;AAAA,EAAA;AAAA,EAEJ,WAAW;AAAA,IACT,MAAM,gBAAAJ,EAACG,GAAA,EAAiB,WAAU,kCAAA,CAAkC;AAAA,IACpE,WACE;AAAA,EAAA;AAAA,EAEJ,gBAAgB;AAAA,IACd,MACE,gBAAAH,EAACK,GAAA,EAAW,WAAU,2EAAA,CAA2E;AAAA,IAEnG,WACE;AAAA,EAAA;AAEN,GAEMC,IAA6C;AAAA,EACjD,MAAM;AAAA,EACN,KAAK;AAAA,EACL,WAAW;AAAA,EACX,SAAS;AAAA,EACT,SAAS;AAAA,EACT,gBAAgB;AAClB;AAEO,SAASC,EAAQ,EAAE,MAAAC,GAAM,UAAAC,KAA0B;AACxD,QAAMC,IAASX,EAAcS,CAAI,GAC3BG,IAAQL,EAAcE,CAAI;AAEhC,SACE,gBAAAI;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,cAAYD;AAAA,MACZ,WAAWE;AAAA,QACT;AAAA,QACAH,EAAO;AAAA,MAAA;AAAA,MAGR,UAAA;AAAA,QAAAA,EAAO,QACN,gBAAAV;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,eAAY;AAAA,YAEX,UAAAU,EAAO;AAAA,UAAA;AAAA,QAAA;AAAA,QAGZ,gBAAAV,EAAC,OAAA,EAAI,WAAU,qHACZ,UAAAS,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { ClipboardCheckmarkRegular as
|
|
3
|
-
import
|
|
1
|
+
import { jsx as r, jsxs as N } from "react/jsx-runtime";
|
|
2
|
+
import { ClipboardCheckmarkRegular as I, Copy20Regular as S } from "@fluentui/react-icons";
|
|
3
|
+
import h from "prismjs";
|
|
4
4
|
import "prismjs/components/prism-bash.js";
|
|
5
5
|
import "prismjs/components/prism-csharp.js";
|
|
6
6
|
import "prismjs/components/prism-javascript.js";
|
|
@@ -9,144 +9,167 @@ import "prismjs/components/prism-markdown.js";
|
|
|
9
9
|
import "prismjs/components/prism-powershell.js";
|
|
10
10
|
import "prismjs/components/prism-python.js";
|
|
11
11
|
import "prismjs/components/prism-typescript.js";
|
|
12
|
-
import
|
|
13
|
-
import { cn as
|
|
14
|
-
import { getNodeText as
|
|
12
|
+
import A, { useState as k, useEffect as R } from "react";
|
|
13
|
+
import { cn as d } from "../../utils/cn.js";
|
|
14
|
+
import { getNodeText as j } from "../../utils/get-node-text.js";
|
|
15
|
+
import { getCodeBlockScrollbarClassname as E } from "../../utils/getScrollbarClassname.js";
|
|
15
16
|
const w = ["image/png", "text/plain"];
|
|
16
|
-
function
|
|
17
|
-
const [t, e] =
|
|
17
|
+
function y() {
|
|
18
|
+
const [t, e] = k(!1), o = async (n) => {
|
|
18
19
|
try {
|
|
19
|
-
await navigator.clipboard.writeText(
|
|
20
|
-
} catch (
|
|
21
|
-
console.error("Failed to copy to clipboard:",
|
|
20
|
+
await navigator.clipboard.writeText(n), e(!0), setTimeout(() => e(!1), 2e3);
|
|
21
|
+
} catch (m) {
|
|
22
|
+
console.error("Failed to copy to clipboard:", m);
|
|
22
23
|
}
|
|
23
24
|
};
|
|
24
|
-
return { isCopied: t, copy:
|
|
25
|
+
return { isCopied: t, copy: o, copyBlob: async (n, m) => {
|
|
25
26
|
try {
|
|
26
|
-
if (w.includes(
|
|
27
|
-
const i = await
|
|
28
|
-
[
|
|
27
|
+
if (w.includes(m)) {
|
|
28
|
+
const i = await n.arrayBuffer(), a = new Blob([i], { type: m }), f = new ClipboardItem({
|
|
29
|
+
[m]: a
|
|
29
30
|
});
|
|
30
|
-
await navigator.clipboard.write([
|
|
31
|
+
await navigator.clipboard.write([f]), e(!0), setTimeout(() => e(!1), 2e3);
|
|
31
32
|
} else {
|
|
32
|
-
const i = await
|
|
33
|
-
await
|
|
33
|
+
const i = await n.text();
|
|
34
|
+
await o(i);
|
|
34
35
|
}
|
|
35
36
|
} catch (i) {
|
|
36
37
|
console.error("Failed to copy blob to clipboard:", i);
|
|
37
38
|
try {
|
|
38
|
-
const a = await
|
|
39
|
-
await
|
|
39
|
+
const a = await n.text();
|
|
40
|
+
await o(a);
|
|
40
41
|
} catch (a) {
|
|
41
42
|
console.error("Failed to copy as text fallback:", a);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
} };
|
|
45
46
|
}
|
|
46
|
-
function _({ onClick: t, isCopied: e, showTooltip:
|
|
47
|
-
return /* @__PURE__ */
|
|
48
|
-
|
|
49
|
-
/* @__PURE__ */
|
|
47
|
+
function _({ onClick: t, isCopied: e, showTooltip: o = !0 }) {
|
|
48
|
+
return /* @__PURE__ */ N("div", { className: "mint:relative", children: [
|
|
49
|
+
o && e && /* @__PURE__ */ r("div", { className: "mint:absolute mint:bottom-[calc(100%+0.5rem)] mint:left-1/2 mint:-translate-x-1/2 mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#171717] mint:dark:text-[#fafafa] mint:px-2.5 mint:py-1.5 mint:rounded-md mint:text-xs mint:font-medium mint:whitespace-nowrap mint:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.1),0_2px_4px_-1px_rgba(0,0,0,0.06)] mint:dark:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.3),0_2px_4px_-1px_rgba(0,0,0,0.2)] mint:z-10 mint:animate-[fadeIn_0.15s_ease-out] mint:after:content-[''] mint:after:absolute mint:after:top-full mint:after:left-1/2 mint:after:-translate-x-1/2 mint:after:w-0 mint:after:h-0 mint:after:border-l-[6px] mint:after:border-l-transparent mint:after:border-r-[6px] mint:after:border-r-transparent mint:after:border-t-[6px] mint:after:border-t-white mint:dark:after:border-t-[#1a1a1a]", children: "Copied!" }),
|
|
50
|
+
/* @__PURE__ */ r(
|
|
50
51
|
"button",
|
|
51
52
|
{
|
|
52
53
|
onClick: t,
|
|
53
54
|
className: "mint:flex mint:items-center mint:gap-1.5 mint:px-2 mint:py-1 mint:text-xs mint:text-[#737373] mint:dark:text-[#a3a3a3] mint:rounded mint:transition-colors mint:duration-150 mint:border-none mint:bg-transparent mint:cursor-pointer mint:hover:text-[#9263f1] mint:dark:hover:text-[#c9aaf9]",
|
|
54
55
|
"aria-label": e ? "Copied" : "Copy code",
|
|
55
|
-
children: e ? /* @__PURE__ */
|
|
56
|
+
children: e ? /* @__PURE__ */ r(I, { className: "mint:w-5 mint:h-5 mint:text-[#737373] mint:dark:text-[#a3a3a3]" }) : /* @__PURE__ */ r(S, { className: "mint:w-5 mint:h-5" })
|
|
56
57
|
}
|
|
57
58
|
)
|
|
58
59
|
] });
|
|
59
60
|
}
|
|
60
|
-
function
|
|
61
|
+
function V({
|
|
61
62
|
textToCopy: t,
|
|
62
63
|
showTooltip: e = !0
|
|
63
64
|
}) {
|
|
64
|
-
const { isCopied:
|
|
65
|
-
return /* @__PURE__ */
|
|
66
|
-
|
|
67
|
-
}, isCopied:
|
|
65
|
+
const { isCopied: o, copy: c } = y();
|
|
66
|
+
return /* @__PURE__ */ r(_, { onClick: () => {
|
|
67
|
+
c(t);
|
|
68
|
+
}, isCopied: o, showTooltip: e });
|
|
68
69
|
}
|
|
69
|
-
function
|
|
70
|
+
function W({
|
|
70
71
|
data: t,
|
|
71
72
|
showTooltip: e = !0
|
|
72
73
|
}) {
|
|
73
|
-
const { isCopied:
|
|
74
|
-
return /* @__PURE__ */
|
|
75
|
-
t.contentType && w.includes(t.contentType) ?
|
|
76
|
-
}, isCopied:
|
|
74
|
+
const { isCopied: o, copy: c, copyBlob: n } = y();
|
|
75
|
+
return /* @__PURE__ */ r(_, { onClick: () => {
|
|
76
|
+
t.contentType && w.includes(t.contentType) ? n(t.blob, t.contentType) : t.type === "other" && t.content ? c(t.content) : console.error("Unsupported content type for clipboard");
|
|
77
|
+
}, isCopied: o, showTooltip: e });
|
|
77
78
|
}
|
|
78
|
-
function
|
|
79
|
+
function X({
|
|
79
80
|
children: t,
|
|
80
81
|
className: e,
|
|
81
|
-
fileName:
|
|
82
|
-
language:
|
|
83
|
-
blob:
|
|
84
|
-
contentType:
|
|
82
|
+
fileName: o,
|
|
83
|
+
language: c,
|
|
84
|
+
blob: n,
|
|
85
|
+
contentType: m,
|
|
86
|
+
dataGroup: i = !1
|
|
85
87
|
}) {
|
|
86
|
-
const [
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
var
|
|
88
|
+
const [a, f] = k("");
|
|
89
|
+
y();
|
|
90
|
+
const s = c || (e == null ? void 0 : e.replace(/^language-/, "")) || "text", u = j(t), T = !!o, g = A.useMemo(() => {
|
|
91
|
+
var x, C;
|
|
90
92
|
if (typeof t != "object" || t == null)
|
|
91
93
|
return !1;
|
|
92
|
-
const
|
|
93
|
-
for (const
|
|
94
|
-
if (typeof
|
|
95
|
-
const
|
|
96
|
-
for (const
|
|
97
|
-
if (typeof
|
|
94
|
+
const p = Array.isArray(t) ? t : [t];
|
|
95
|
+
for (const l of p)
|
|
96
|
+
if (typeof l == "object" && l != null && "props" in l && ((x = l.props) != null && x.children)) {
|
|
97
|
+
const B = Array.isArray(l.props.children) ? l.props.children : [l.props.children];
|
|
98
|
+
for (const b of B)
|
|
99
|
+
if (typeof b == "object" && b != null && "props" in b && ((C = b.props) != null && C.className))
|
|
98
100
|
return !0;
|
|
99
101
|
}
|
|
100
102
|
return !1;
|
|
101
103
|
}, [t]);
|
|
102
|
-
|
|
103
|
-
if (!
|
|
104
|
+
R(() => {
|
|
105
|
+
if (!g)
|
|
104
106
|
try {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
} catch (
|
|
108
|
-
console.error("Failed to highlight code:",
|
|
107
|
+
const p = h.languages[s] || h.languages.plaintext, x = h.highlight(u, p, s);
|
|
108
|
+
f(x);
|
|
109
|
+
} catch (p) {
|
|
110
|
+
console.error("Failed to highlight code:", p), f(u);
|
|
109
111
|
}
|
|
110
|
-
}, [
|
|
112
|
+
}, [u, s, g]);
|
|
113
|
+
const v = E("system", i);
|
|
114
|
+
return /* @__PURE__ */ r(
|
|
111
115
|
"div",
|
|
112
116
|
{
|
|
113
|
-
className:
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
className: T ? "mint:flex mint:flex-col mint:gap-2 mint:px-0.5 mint:pb-0.5 mint:rounded-xl mint:overflow-hidden" : void 0,
|
|
118
|
+
"data-group": i,
|
|
119
|
+
children: /* @__PURE__ */ r(
|
|
120
|
+
"div",
|
|
116
121
|
{
|
|
117
|
-
className:
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
className: d(
|
|
123
|
+
"not-prose mint:relative mint:rounded-xl mint:bg-[#f5f5f5] mint:dark:bg-[#141414]",
|
|
124
|
+
i && "mint:group"
|
|
120
125
|
),
|
|
121
|
-
children:
|
|
126
|
+
children: /* @__PURE__ */ r(
|
|
127
|
+
"pre",
|
|
128
|
+
{
|
|
129
|
+
className: d(
|
|
130
|
+
"mint:px-4 mint:py-2 mint:m-0 mint:whitespace-pre mint:text-sm mint:overflow-scroll mint:scrollbar-track-zinc-200 mint:dark:scrollbar-track-zinc-800",
|
|
131
|
+
v
|
|
132
|
+
),
|
|
133
|
+
children: g ? /* @__PURE__ */ r(
|
|
134
|
+
"code",
|
|
135
|
+
{
|
|
136
|
+
className: d(
|
|
137
|
+
`language-${s}`,
|
|
138
|
+
"mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]"
|
|
139
|
+
),
|
|
140
|
+
children: t
|
|
141
|
+
}
|
|
142
|
+
) : a ? /* @__PURE__ */ r(
|
|
143
|
+
"code",
|
|
144
|
+
{
|
|
145
|
+
className: d(
|
|
146
|
+
`language-${s}`,
|
|
147
|
+
"mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]"
|
|
148
|
+
),
|
|
149
|
+
dangerouslySetInnerHTML: { __html: a }
|
|
150
|
+
}
|
|
151
|
+
) : /* @__PURE__ */ r(
|
|
152
|
+
"code",
|
|
153
|
+
{
|
|
154
|
+
className: d(
|
|
155
|
+
`language-${s}`,
|
|
156
|
+
"mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]"
|
|
157
|
+
),
|
|
158
|
+
children: u
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
)
|
|
122
163
|
}
|
|
123
|
-
)
|
|
124
|
-
"code",
|
|
125
|
-
{
|
|
126
|
-
className: h(
|
|
127
|
-
`language-${m}`,
|
|
128
|
-
"mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]"
|
|
129
|
-
),
|
|
130
|
-
dangerouslySetInnerHTML: { __html: i }
|
|
131
|
-
}
|
|
132
|
-
) : /* @__PURE__ */ o(
|
|
133
|
-
"code",
|
|
134
|
-
{
|
|
135
|
-
className: h(
|
|
136
|
-
`language-${m}`,
|
|
137
|
-
"mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]"
|
|
138
|
-
),
|
|
139
|
-
children: d
|
|
140
|
-
}
|
|
141
|
-
) }) }) })
|
|
164
|
+
)
|
|
142
165
|
}
|
|
143
166
|
);
|
|
144
167
|
}
|
|
145
168
|
export {
|
|
146
|
-
|
|
147
|
-
|
|
169
|
+
X as CodeBlock,
|
|
170
|
+
W as CopyDataToClipboardButton,
|
|
148
171
|
_ as CopyIconButton,
|
|
149
|
-
|
|
150
|
-
|
|
172
|
+
V as CopyToClipboardButton,
|
|
173
|
+
y as useCopyToClipboard
|
|
151
174
|
};
|
|
152
175
|
//# sourceMappingURL=code-block.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-block.js","sources":["../../../src/components/content-components/code-block.tsx"],"sourcesContent":["import { Copy20Regular, ClipboardCheckmarkRegular } from '@fluentui/react-icons';\nimport Prism from 'prismjs';\nimport 'prismjs/components/prism-bash.js';\nimport 'prismjs/components/prism-csharp.js';\nimport 'prismjs/components/prism-javascript.js';\nimport 'prismjs/components/prism-json.js';\nimport 'prismjs/components/prism-markdown.js';\nimport 'prismjs/components/prism-powershell.js';\nimport 'prismjs/components/prism-python.js';\nimport 'prismjs/components/prism-typescript.js';\nimport React, { useEffect, useState } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { getNodeText } from '../../utils/get-node-text';\nimport { capitalize } from '../../utils/string';\n\nconst SUPPORTED_CLIPBOARD_CONTENT_TYPES = ['image/png', 'text/plain'];\n\n// Hook for clipboard operations\nexport function useCopyToClipboard() {\n const [isCopied, setIsCopied] = useState(false);\n\n const copy = async (text: string) => {\n try {\n await navigator.clipboard.writeText(text);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n } catch (error) {\n console.error('Failed to copy to clipboard:', error);\n }\n };\n\n const copyBlob = async (blob: Blob, contentType: string) => {\n try {\n // image/png, text/plain, and text/html are the only filetypes supported in the chromium\n // clipboard - however, text/html crashes chrome for some reason\n if (SUPPORTED_CLIPBOARD_CONTENT_TYPES.includes(contentType)) {\n const buffer = await blob.arrayBuffer();\n const newBlob = new Blob([buffer], { type: contentType });\n const clipboardItem = new ClipboardItem({\n [contentType]: newBlob,\n });\n await navigator.clipboard.write([clipboardItem]);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n } else {\n // Fallback to text copy for unsupported types\n const text = await blob.text();\n await copy(text);\n }\n } catch (error) {\n console.error('Failed to copy blob to clipboard:', error);\n // Fallback to text copy if blob copy fails\n try {\n const text = await blob.text();\n await copy(text);\n } catch (fallbackError) {\n console.error('Failed to copy as text fallback:', fallbackError);\n }\n }\n };\n\n return { isCopied, copy, copyBlob };\n}\n\n// Base copy icon button component\ninterface CopyIconButtonProps {\n onClick: () => void;\n isCopied: boolean;\n showTooltip?: boolean;\n}\n\nexport function CopyIconButton({ onClick, isCopied, showTooltip = true }: CopyIconButtonProps) {\n return (\n <div className=\"mint:relative\">\n {showTooltip && isCopied && (\n <div className=\"mint:absolute mint:bottom-[calc(100%+0.5rem)] mint:left-1/2 mint:-translate-x-1/2 mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#171717] mint:dark:text-[#fafafa] mint:px-2.5 mint:py-1.5 mint:rounded-md mint:text-xs mint:font-medium mint:whitespace-nowrap mint:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.1),0_2px_4px_-1px_rgba(0,0,0,0.06)] mint:dark:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.3),0_2px_4px_-1px_rgba(0,0,0,0.2)] mint:z-10 mint:animate-[fadeIn_0.15s_ease-out] mint:after:content-[''] mint:after:absolute mint:after:top-full mint:after:left-1/2 mint:after:-translate-x-1/2 mint:after:w-0 mint:after:h-0 mint:after:border-l-[6px] mint:after:border-l-transparent mint:after:border-r-[6px] mint:after:border-r-transparent mint:after:border-t-[6px] mint:after:border-t-white mint:dark:after:border-t-[#1a1a1a]\">\n Copied!\n </div>\n )}\n <button\n onClick={onClick}\n className=\"mint:flex mint:items-center mint:gap-1.5 mint:px-2 mint:py-1 mint:text-xs mint:text-[#737373] mint:dark:text-[#a3a3a3] mint:rounded mint:transition-colors mint:duration-150 mint:border-none mint:bg-transparent mint:cursor-pointer mint:hover:text-[#9263f1] mint:dark:hover:text-[#c9aaf9]\"\n aria-label={isCopied ? 'Copied' : 'Copy code'}\n >\n {isCopied ? (\n <ClipboardCheckmarkRegular className=\"mint:w-5 mint:h-5 mint:text-[#737373] mint:dark:text-[#a3a3a3]\" />\n ) : (\n <Copy20Regular className=\"mint:w-5 mint:h-5\" />\n )}\n </button>\n </div>\n );\n}\n\n// Convenience component that handles text copying\ninterface CopyToClipboardButtonProps {\n textToCopy: string;\n showTooltip?: boolean;\n}\n\nexport function CopyToClipboardButton({\n textToCopy,\n showTooltip = true,\n}: CopyToClipboardButtonProps) {\n const { isCopied, copy } = useCopyToClipboard();\n\n const handleCopy = () => {\n copy(textToCopy);\n };\n\n return <CopyIconButton onClick={handleCopy} isCopied={isCopied} showTooltip={showTooltip} />;\n}\n\n// Convenience component that handles blob/data copying\ninterface CopyDataToClipboardButtonProps {\n data: {\n type: 'image' | 'audio' | 'video' | 'other';\n blob: Blob;\n contentType?: string;\n content?: string;\n };\n showTooltip?: boolean;\n}\n\nexport function CopyDataToClipboardButton({\n data,\n showTooltip = true,\n}: CopyDataToClipboardButtonProps) {\n const { isCopied, copy, copyBlob } = useCopyToClipboard();\n\n const handleCopy = () => {\n // Check if we can copy as blob (for images, etc.)\n if (data.contentType && SUPPORTED_CLIPBOARD_CONTENT_TYPES.includes(data.contentType)) {\n copyBlob(data.blob, data.contentType);\n } else if (data.type === 'other' && data.content) {\n // For text content, copy as text\n copy(data.content);\n } else {\n console.error('Unsupported content type for clipboard');\n }\n };\n\n return <CopyIconButton onClick={handleCopy} isCopied={isCopied} showTooltip={showTooltip} />;\n}\n\ninterface CodeBlockProps {\n children: React.ReactNode;\n className?: string;\n language?: string;\n fileName?: string;\n // Support for copying blobs (images, etc.)\n blob?: Blob;\n contentType?: string;\n}\n\nexport function CodeBlock({\n children,\n className,\n fileName,\n language,\n blob,\n contentType,\n}: CodeBlockProps) {\n const [highlightedCode, setHighlightedCode] = useState<string>('');\n const { isCopied, copy, copyBlob } = useCopyToClipboard();\n const lang = language || className?.replace(/^language-/, '') || 'text';\n const codeText = getNodeText(children);\n const showContainer = !!fileName;\n\n const isSSRHighlighted = React.useMemo(() => {\n if (typeof children !== 'object' || children == null) {\n return false;\n }\n\n const childrenArray = Array.isArray(children) ? children : [children];\n for (const child of childrenArray) {\n if (typeof child === 'object' && child != null && 'props' in child && child.props?.children) {\n const codeChildren = Array.isArray(child.props.children)\n ? child.props.children\n : [child.props.children];\n\n for (const codeChild of codeChildren) {\n if (\n typeof codeChild === 'object' &&\n codeChild != null &&\n 'props' in codeChild &&\n codeChild.props?.className\n ) {\n return true;\n }\n }\n }\n }\n return false;\n }, [children]);\n\n useEffect(() => {\n if (isSSRHighlighted) {\n return;\n }\n\n try {\n const grammar = Prism.languages[lang] || Prism.languages.plaintext;\n const html = Prism.highlight(codeText, grammar, lang);\n setHighlightedCode(html);\n } catch (error) {\n console.error('Failed to highlight code:', error);\n setHighlightedCode(codeText);\n }\n }, [codeText, lang, isSSRHighlighted]);\n\n const handleCopy = () => {\n // If blob and contentType are provided, use blob copying\n if (blob && contentType) {\n copyBlob(blob, contentType);\n } else {\n // Otherwise, use text copying\n copy(codeText);\n }\n };\n\n return (\n <div\n className={\n showContainer\n ? 'mint:flex mint:flex-col mint:gap-2 mint:px-0.5 mint:pb-0.5 mint:rounded-xl mint:overflow-hidden'\n : undefined\n }\n >\n <div className=\"not-prose mint:relative mint:rounded-xl mint:bg-[#f5f5f5] mint:dark:bg-[#141414]\">\n <div className=\"mint:code-scrollbar mint:overflow-x-scroll\">\n <pre className=\"mint:px-4 mint:py-2 mint:m-0 mint:whitespace-pre mint:text-sm\">\n {isSSRHighlighted ? (\n <code\n className={cn(\n `language-${lang}`,\n 'mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]'\n )}\n >\n {children}\n </code>\n ) : highlightedCode ? (\n <code\n className={cn(\n `language-${lang}`,\n 'mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]'\n )}\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n />\n ) : (\n <code\n className={cn(\n `language-${lang}`,\n 'mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]'\n )}\n >\n {codeText}\n </code>\n )}\n </pre>\n </div>\n </div>\n </div>\n );\n}\n"],"names":["SUPPORTED_CLIPBOARD_CONTENT_TYPES","useCopyToClipboard","isCopied","setIsCopied","useState","copy","text","error","blob","contentType","buffer","newBlob","clipboardItem","fallbackError","CopyIconButton","onClick","showTooltip","jsxs","jsx","ClipboardCheckmarkRegular","Copy20Regular","CopyToClipboardButton","textToCopy","CopyDataToClipboardButton","data","copyBlob","CodeBlock","children","className","fileName","language","highlightedCode","setHighlightedCode","lang","codeText","getNodeText","showContainer","isSSRHighlighted","React","childrenArray","child","_a","codeChildren","codeChild","_b","useEffect","grammar","Prism","html","cn"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAMA,IAAoC,CAAC,aAAa,YAAY;AAG7D,SAASC,IAAqB;AACnC,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAK,GAExCC,IAAO,OAAOC,MAAiB;AACnC,QAAI;AACF,YAAM,UAAU,UAAU,UAAUA,CAAI,GACxCH,EAAY,EAAI,GAChB,WAAW,MAAMA,EAAY,EAAK,GAAG,GAAI;AAAA,IAC3C,SAASI,GAAO;AACd,cAAQ,MAAM,gCAAgCA,CAAK;AAAA,IACrD;AAAA,EACF;AAgCA,SAAO,EAAE,UAAAL,GAAU,MAAAG,GAAM,UA9BR,OAAOG,GAAYC,MAAwB;AAC1D,QAAI;AAGF,UAAIT,EAAkC,SAASS,CAAW,GAAG;AAC3D,cAAMC,IAAS,MAAMF,EAAK,YAAA,GACpBG,IAAU,IAAI,KAAK,CAACD,CAAM,GAAG,EAAE,MAAMD,GAAa,GAClDG,IAAgB,IAAI,cAAc;AAAA,UACtC,CAACH,CAAW,GAAGE;AAAA,QAAA,CAChB;AACD,cAAM,UAAU,UAAU,MAAM,CAACC,CAAa,CAAC,GAC/CT,EAAY,EAAI,GAChB,WAAW,MAAMA,EAAY,EAAK,GAAG,GAAI;AAAA,MAC3C,OAAO;AAEL,cAAMG,IAAO,MAAME,EAAK,KAAA;AACxB,cAAMH,EAAKC,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KAAKc,EAAM,UAAU,WACnDC,IAAOD,EAAM,UAAUb,GAAUY,GAASb,CAAI;AACpD,QAAAD,EAAmBgB,CAAI;AAAA,MACzB,SAASzC,GAAO;AACd,gBAAQ,MAAM,6BAA6BA,CAAK,GAChDyB,EAAmBE,CAAQ;AAAA,MAC7B;AAAA,EACF,GAAG,CAACA,GAAUD,GAAMI,CAAgB,CAAC,GAanC,gBAAAnB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WACEkB,IACI,oGACA;AAAA,MAGN,UAAA,gBAAAlB,EAAC,OAAA,EAAI,WAAU,oFACb,UAAA,gBAAAA,EAAC,OAAA,EAAI,WAAU,8CACb,UAAA,gBAAAA,EAAC,OAAA,EAAI,WAAU,iEACZ,UAAAmB,IACC,gBAAAnB;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW+B;AAAA,YACT,YAAYhB,CAAI;AAAA,YAChB;AAAA,UAAA;AAAA,UAGD,UAAAN;AAAA,QAAA;AAAA,MAAA,IAEDI,IACF,gBAAAb;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW+B;AAAA,YACT,YAAYhB,CAAI;AAAA,YAChB;AAAA,UAAA;AAAA,UAEF,yBAAyB,EAAE,QAAQF,EAAA;AAAA,QAAgB;AAAA,MAAA,IAGrD,gBAAAb;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW+B;AAAA,YACT,YAAYhB,CAAI;AAAA,YAChB;AAAA,UAAA;AAAA,UAGD,UAAAC;AAAA,QAAA;AAAA,MAAA,EACH,CAEJ,GACF,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"code-block.js","sources":["../../../src/components/content-components/code-block.tsx"],"sourcesContent":["import { Copy20Regular, ClipboardCheckmarkRegular } from '@fluentui/react-icons';\nimport Prism from 'prismjs';\nimport 'prismjs/components/prism-bash.js';\nimport 'prismjs/components/prism-csharp.js';\nimport 'prismjs/components/prism-javascript.js';\nimport 'prismjs/components/prism-json.js';\nimport 'prismjs/components/prism-markdown.js';\nimport 'prismjs/components/prism-powershell.js';\nimport 'prismjs/components/prism-python.js';\nimport 'prismjs/components/prism-typescript.js';\nimport React, { useEffect, useState } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { getNodeText } from '../../utils/get-node-text';\nimport { capitalize } from '../../utils/string';\nimport { getCodeBlockScrollbarClassname } from '../../utils/getScrollbarClassname';\n\nconst SUPPORTED_CLIPBOARD_CONTENT_TYPES = ['image/png', 'text/plain'];\n\n// Hook for clipboard operations\nexport function useCopyToClipboard() {\n const [isCopied, setIsCopied] = useState(false);\n\n const copy = async (text: string) => {\n try {\n await navigator.clipboard.writeText(text);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n } catch (error) {\n console.error('Failed to copy to clipboard:', error);\n }\n };\n\n const copyBlob = async (blob: Blob, contentType: string) => {\n try {\n // image/png, text/plain, and text/html are the only filetypes supported in the chromium\n // clipboard - however, text/html crashes chrome for some reason\n if (SUPPORTED_CLIPBOARD_CONTENT_TYPES.includes(contentType)) {\n const buffer = await blob.arrayBuffer();\n const newBlob = new Blob([buffer], { type: contentType });\n const clipboardItem = new ClipboardItem({\n [contentType]: newBlob,\n });\n await navigator.clipboard.write([clipboardItem]);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n } else {\n // Fallback to text copy for unsupported types\n const text = await blob.text();\n await copy(text);\n }\n } catch (error) {\n console.error('Failed to copy blob to clipboard:', error);\n // Fallback to text copy if blob copy fails\n try {\n const text = await blob.text();\n await copy(text);\n } catch (fallbackError) {\n console.error('Failed to copy as text fallback:', fallbackError);\n }\n }\n };\n\n return { isCopied, copy, copyBlob };\n}\n\n// Base copy icon button component\ninterface CopyIconButtonProps {\n onClick: () => void;\n isCopied: boolean;\n showTooltip?: boolean;\n}\n\nexport function CopyIconButton({ onClick, isCopied, showTooltip = true }: CopyIconButtonProps) {\n return (\n <div className=\"mint:relative\">\n {showTooltip && isCopied && (\n <div className=\"mint:absolute mint:bottom-[calc(100%+0.5rem)] mint:left-1/2 mint:-translate-x-1/2 mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#171717] mint:dark:text-[#fafafa] mint:px-2.5 mint:py-1.5 mint:rounded-md mint:text-xs mint:font-medium mint:whitespace-nowrap mint:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.1),0_2px_4px_-1px_rgba(0,0,0,0.06)] mint:dark:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.3),0_2px_4px_-1px_rgba(0,0,0,0.2)] mint:z-10 mint:animate-[fadeIn_0.15s_ease-out] mint:after:content-[''] mint:after:absolute mint:after:top-full mint:after:left-1/2 mint:after:-translate-x-1/2 mint:after:w-0 mint:after:h-0 mint:after:border-l-[6px] mint:after:border-l-transparent mint:after:border-r-[6px] mint:after:border-r-transparent mint:after:border-t-[6px] mint:after:border-t-white mint:dark:after:border-t-[#1a1a1a]\">\n Copied!\n </div>\n )}\n <button\n onClick={onClick}\n className=\"mint:flex mint:items-center mint:gap-1.5 mint:px-2 mint:py-1 mint:text-xs mint:text-[#737373] mint:dark:text-[#a3a3a3] mint:rounded mint:transition-colors mint:duration-150 mint:border-none mint:bg-transparent mint:cursor-pointer mint:hover:text-[#9263f1] mint:dark:hover:text-[#c9aaf9]\"\n aria-label={isCopied ? 'Copied' : 'Copy code'}\n >\n {isCopied ? (\n <ClipboardCheckmarkRegular className=\"mint:w-5 mint:h-5 mint:text-[#737373] mint:dark:text-[#a3a3a3]\" />\n ) : (\n <Copy20Regular className=\"mint:w-5 mint:h-5\" />\n )}\n </button>\n </div>\n );\n}\n\n// Convenience component that handles text copying\ninterface CopyToClipboardButtonProps {\n textToCopy: string;\n showTooltip?: boolean;\n}\n\nexport function CopyToClipboardButton({\n textToCopy,\n showTooltip = true,\n}: CopyToClipboardButtonProps) {\n const { isCopied, copy } = useCopyToClipboard();\n\n const handleCopy = () => {\n copy(textToCopy);\n };\n\n return <CopyIconButton onClick={handleCopy} isCopied={isCopied} showTooltip={showTooltip} />;\n}\n\n// Convenience component that handles blob/data copying\ninterface CopyDataToClipboardButtonProps {\n data: {\n type: 'image' | 'audio' | 'video' | 'other';\n blob: Blob;\n contentType?: string;\n content?: string;\n };\n showTooltip?: boolean;\n}\n\nexport function CopyDataToClipboardButton({\n data,\n showTooltip = true,\n}: CopyDataToClipboardButtonProps) {\n const { isCopied, copy, copyBlob } = useCopyToClipboard();\n\n const handleCopy = () => {\n // Check if we can copy as blob (for images, etc.)\n if (data.contentType && SUPPORTED_CLIPBOARD_CONTENT_TYPES.includes(data.contentType)) {\n copyBlob(data.blob, data.contentType);\n } else if (data.type === 'other' && data.content) {\n // For text content, copy as text\n copy(data.content);\n } else {\n console.error('Unsupported content type for clipboard');\n }\n };\n\n return <CopyIconButton onClick={handleCopy} isCopied={isCopied} showTooltip={showTooltip} />;\n}\n\ninterface CodeBlockProps {\n children: React.ReactNode;\n className?: string;\n language?: string;\n fileName?: string;\n // Support for copying blobs (images, etc.)\n blob?: Blob;\n contentType?: string;\n // Control whether scrollbar uses group-hover behavior\n dataGroup?: boolean;\n}\n\nexport function CodeBlock({\n children,\n className,\n fileName,\n language,\n blob,\n contentType,\n dataGroup = false,\n}: CodeBlockProps) {\n const [highlightedCode, setHighlightedCode] = useState<string>('');\n const { isCopied, copy, copyBlob } = useCopyToClipboard();\n const lang = language || className?.replace(/^language-/, '') || 'text';\n const codeText = getNodeText(children);\n const showContainer = !!fileName;\n\n const isSSRHighlighted = React.useMemo(() => {\n if (typeof children !== 'object' || children == null) {\n return false;\n }\n\n const childrenArray = Array.isArray(children) ? children : [children];\n for (const child of childrenArray) {\n if (typeof child === 'object' && child != null && 'props' in child && child.props?.children) {\n const codeChildren = Array.isArray(child.props.children)\n ? child.props.children\n : [child.props.children];\n\n for (const codeChild of codeChildren) {\n if (\n typeof codeChild === 'object' &&\n codeChild != null &&\n 'props' in codeChild &&\n codeChild.props?.className\n ) {\n return true;\n }\n }\n }\n }\n return false;\n }, [children]);\n\n useEffect(() => {\n if (isSSRHighlighted) {\n return;\n }\n\n try {\n const grammar = Prism.languages[lang] || Prism.languages.plaintext;\n const html = Prism.highlight(codeText, grammar, lang);\n setHighlightedCode(html);\n } catch (error) {\n console.error('Failed to highlight code:', error);\n setHighlightedCode(codeText);\n }\n }, [codeText, lang, isSSRHighlighted]);\n\n const handleCopy = () => {\n // If blob and contentType are provided, use blob copying\n if (blob && contentType) {\n copyBlob(blob, contentType);\n } else {\n // Otherwise, use text copying\n copy(codeText);\n }\n };\n\n const scrollbarClass = getCodeBlockScrollbarClassname('system', dataGroup);\n\n return (\n <div\n className={\n showContainer\n ? 'mint:flex mint:flex-col mint:gap-2 mint:px-0.5 mint:pb-0.5 mint:rounded-xl mint:overflow-hidden'\n : undefined\n }\n data-group={dataGroup}\n >\n <div\n className={cn(\n 'not-prose mint:relative mint:rounded-xl mint:bg-[#f5f5f5] mint:dark:bg-[#141414]',\n dataGroup && 'mint:group'\n )}\n >\n <pre\n className={cn(\n 'mint:px-4 mint:py-2 mint:m-0 mint:whitespace-pre mint:text-sm mint:overflow-scroll mint:scrollbar-track-zinc-200 mint:dark:scrollbar-track-zinc-800',\n scrollbarClass\n )}\n >\n {isSSRHighlighted ? (\n <code\n className={cn(\n `language-${lang}`,\n 'mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]'\n )}\n >\n {children}\n </code>\n ) : highlightedCode ? (\n <code\n className={cn(\n `language-${lang}`,\n 'mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]'\n )}\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n />\n ) : (\n <code\n className={cn(\n `language-${lang}`,\n 'mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]'\n )}\n >\n {codeText}\n </code>\n )}\n </pre>\n </div>\n </div>\n );\n}\n"],"names":["SUPPORTED_CLIPBOARD_CONTENT_TYPES","useCopyToClipboard","isCopied","setIsCopied","useState","copy","text","error","blob","contentType","buffer","newBlob","clipboardItem","fallbackError","CopyIconButton","onClick","showTooltip","jsxs","jsx","ClipboardCheckmarkRegular","Copy20Regular","CopyToClipboardButton","textToCopy","CopyDataToClipboardButton","data","copyBlob","CodeBlock","children","className","fileName","language","dataGroup","highlightedCode","setHighlightedCode","lang","codeText","getNodeText","showContainer","isSSRHighlighted","React","childrenArray","child","_a","codeChildren","codeChild","_b","useEffect","grammar","Prism","html","scrollbarClass","getCodeBlockScrollbarClassname","cn"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAMA,IAAoC,CAAC,aAAa,YAAY;AAG7D,SAASC,IAAqB;AACnC,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAK,GAExCC,IAAO,OAAOC,MAAiB;AACnC,QAAI;AACF,YAAM,UAAU,UAAU,UAAUA,CAAI,GACxCH,EAAY,EAAI,GAChB,WAAW,MAAMA,EAAY,EAAK,GAAG,GAAI;AAAA,IAC3C,SAASI,GAAO;AACd,cAAQ,MAAM,gCAAgCA,CAAK;AAAA,IACrD;AAAA,EACF;AAgCA,SAAO,EAAE,UAAAL,GAAU,MAAAG,GAAM,UA9BR,OAAOG,GAAYC,MAAwB;AAC1D,QAAI;AAGF,UAAIT,EAAkC,SAASS,CAAW,GAAG;AAC3D,cAAMC,IAAS,MAAMF,EAAK,YAAA,GACpBG,IAAU,IAAI,KAAK,CAACD,CAAM,GAAG,EAAE,MAAMD,GAAa,GAClDG,IAAgB,IAAI,cAAc;AAAA,UACtC,CAACH,CAAW,GAAGE;AAAA,QAAA,CAChB;AACD,cAAM,UAAU,UAAU,MAAM,CAACC,CAAa,CAAC,GAC/CT,EAAY,EAAI,GAChB,WAAW,MAAMA,EAAY,EAAK,GAAG,GAAI;AAAA,MAC3C,OAAO;AAEL,cAAMG,IAAO,MAAME,EAAK,KAAA;AACxB,cAAMH,EAAKC,CAAI;AAAA,MACjB;AAAA,IACF,SAASC,GAAO;AACd,cAAQ,MAAM,qCAAqCA,CAAK;AAExD,UAAI;AACF,cAAMD,IAAO,MAAME,EAAK,KAAA;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, { forwardRef as
|
|
4
|
-
import { ChevronDownFilled as
|
|
3
|
+
import j, { forwardRef as y, useRef as z, useState as F, useCallback as L } from "react";
|
|
4
|
+
import { ChevronDownFilled as V } from "@fluentui/react-icons";
|
|
5
5
|
import { cn as g } from "../../utils/cn.js";
|
|
6
|
-
import { CopyToClipboardButton as
|
|
7
|
-
import { getNodeText as
|
|
6
|
+
import { CopyToClipboardButton as B } from "./code-block.js";
|
|
7
|
+
import { getNodeText as G } from "../../utils/get-node-text.js";
|
|
8
8
|
import { capitalize as D } from "../../utils/string.js";
|
|
9
|
-
const K =
|
|
10
|
-
var
|
|
11
|
-
const { defaultValue:
|
|
9
|
+
const K = y(function({ children: r, onChange: a, className: o, dropdown: l, noMargins: h, ...T }, C) {
|
|
10
|
+
var k, N;
|
|
11
|
+
const { defaultValue: u, ...S } = T, x = z(/* @__PURE__ */ new Map()), i = Array.isArray(r) ? r : j.Children.toArray(r), [v, A] = F(0), w = L(
|
|
12
12
|
(n) => {
|
|
13
13
|
var s;
|
|
14
14
|
const t = Number(n), m = ((s = document.activeElement) == null ? void 0 : s.getAttribute("role")) === "tab";
|
|
15
15
|
A(t), a == null || a(t), m && requestAnimationFrame(() => {
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const p = x.current.get(t);
|
|
17
|
+
p && p.focus();
|
|
18
18
|
});
|
|
19
19
|
},
|
|
20
20
|
[a]
|
|
@@ -23,17 +23,17 @@ const K = k(function({ children: r, onChange: a, className: o, dropdown: l, noMa
|
|
|
23
23
|
return null;
|
|
24
24
|
if (i.length === 0)
|
|
25
25
|
return console.warn("CodeGroup has no children, expected at least one CodeBlock child."), null;
|
|
26
|
-
const
|
|
26
|
+
const d = Number(v), I = () => {
|
|
27
27
|
var n;
|
|
28
|
-
return /* @__PURE__ */ e("div", { className: "mint:flex mint:items-center mint:gap-1.5 mint:text-xs mint:font-medium mint:min-w-0", children: /* @__PURE__ */ e("span", { className: "mint:truncate mint:text-[#171717] mint:dark:text-[#fafafa]", children: (n = i[
|
|
28
|
+
return /* @__PURE__ */ e("div", { className: "mint:flex mint:items-center mint:gap-1.5 mint:text-xs mint:font-medium mint:min-w-0", children: /* @__PURE__ */ e("span", { className: "mint:truncate mint:text-[#171717] mint:dark:text-[#fafafa]", children: (n = i[d]) == null ? void 0 : n.props.fileName }) });
|
|
29
29
|
}, $ = () => /* @__PURE__ */ e(f.List, { className: "mint:flex-1 mint:min-w-0 mint:text-xs mint:leading-6 mint:rounded-tl-xl mint:gap-1 mint:flex mint:overflow-x-auto mint:overflow-y-hidden", children: i.map((n, t) => /* @__PURE__ */ e(
|
|
30
30
|
_,
|
|
31
31
|
{
|
|
32
32
|
value: String(t),
|
|
33
|
-
isSelected:
|
|
33
|
+
isSelected: d === t,
|
|
34
34
|
tabsLength: i.length,
|
|
35
35
|
ref: (m) => {
|
|
36
|
-
m &&
|
|
36
|
+
m && x.current.set(t, m);
|
|
37
37
|
},
|
|
38
38
|
children: n.props.fileName
|
|
39
39
|
},
|
|
@@ -44,25 +44,25 @@ const K = k(function({ children: r, onChange: a, className: o, dropdown: l, noMa
|
|
|
44
44
|
/* @__PURE__ */ e(
|
|
45
45
|
"select",
|
|
46
46
|
{
|
|
47
|
-
value: ((n = i[
|
|
47
|
+
value: ((n = i[d]) == null ? void 0 : n.props.language) || "",
|
|
48
48
|
onChange: (t) => {
|
|
49
|
-
const m = t.target.value, s = i.findIndex((
|
|
50
|
-
s !== -1 &&
|
|
49
|
+
const m = t.target.value, s = i.findIndex((p) => p.props.language === m);
|
|
50
|
+
s !== -1 && w(String(s));
|
|
51
51
|
},
|
|
52
52
|
className: "mint:appearance-none mint:bg-transparent mint:border mint:border-[#e5e5e5] mint:dark:border-[#262626] mint:rounded-lg mint:px-2.5 mint:pr-7 mint:py-1 mint:text-xs mint:font-medium mint:text-[#171717] mint:dark:text-[#fafafa] mint:cursor-pointer mint:focus:outline-0",
|
|
53
53
|
children: i.map((t, m) => /* @__PURE__ */ e("option", { value: t.props.language, children: D(t.props.language || "") }, `${t.props.language}-${t.props.fileName}-${m}`))
|
|
54
54
|
}
|
|
55
55
|
),
|
|
56
|
-
/* @__PURE__ */ e(
|
|
56
|
+
/* @__PURE__ */ e(V, { className: "mint:absolute mint:right-2 mint:top-1/2 mint:-translate-y-1/2 mint:w-3.5 mint:h-3.5 mint:pointer-events-none mint:text-[#737373] mint:dark:text-[#a3a3a3]" })
|
|
57
57
|
] });
|
|
58
58
|
};
|
|
59
59
|
return /* @__PURE__ */ c(
|
|
60
60
|
f.Root,
|
|
61
61
|
{
|
|
62
|
-
defaultValue:
|
|
62
|
+
defaultValue: u == null ? void 0 : typeof u == "string" ? u : String(u),
|
|
63
63
|
ref: C,
|
|
64
64
|
value: String(v),
|
|
65
|
-
onValueChange:
|
|
65
|
+
onValueChange: w,
|
|
66
66
|
className: g(
|
|
67
67
|
!h && "mint:mt-4 mint:mb-4",
|
|
68
68
|
"mint:flex mint:flex-col not-prose mint:relative mint:overflow-hidden mint:rounded-2xl mint:border mint:border-[#e5e5e5] mint:dark:border-[#262626] mint:bg-white mint:dark:bg-[#0a0a0a]",
|
|
@@ -83,9 +83,9 @@ const K = k(function({ children: r, onChange: a, className: o, dropdown: l, noMa
|
|
|
83
83
|
/* @__PURE__ */ c("div", { className: "mint:flex mint:items-center mint:justify-end mint:shrink-0 mint:gap-1.5", children: [
|
|
84
84
|
l && /* @__PURE__ */ e(R, {}),
|
|
85
85
|
/* @__PURE__ */ e(
|
|
86
|
-
|
|
86
|
+
B,
|
|
87
87
|
{
|
|
88
|
-
textToCopy:
|
|
88
|
+
textToCopy: G((N = (k = i[d]) == null ? void 0 : k.props) == null ? void 0 : N.children),
|
|
89
89
|
showTooltip: !0
|
|
90
90
|
}
|
|
91
91
|
)
|
|
@@ -99,14 +99,14 @@ const K = k(function({ children: r, onChange: a, className: o, dropdown: l, noMa
|
|
|
99
99
|
value: String(t),
|
|
100
100
|
className: "mint:w-full mint:min-w-full mint:max-w-full mint:h-full mint:max-h-full",
|
|
101
101
|
tabIndex: -1,
|
|
102
|
-
children: /* @__PURE__ */ e("div", { className: "mint:
|
|
102
|
+
children: /* @__PURE__ */ e("div", { className: "mint:overflow-scroll mint:max-h-[calc(40vh-3rem)] mint:scrollbar-thin mint:scrollbar-thumb-rounded mint:scrollbar-track-zinc-200 mint:dark:scrollbar-track-zinc-800 mint:scrollbar-thumb-black/15 mint:dark:scrollbar-thumb-white/20 mint:hover:scrollbar-thumb-black/20 mint:dark:hover:scrollbar-thumb-white/25 mint:active:scrollbar-thumb-black/20 mint:dark:active:scrollbar-thumb-white/25", children: n })
|
|
103
103
|
},
|
|
104
104
|
`${n.props.fileName}-${n.props.language}-${t}`
|
|
105
105
|
)) })
|
|
106
106
|
]
|
|
107
107
|
}
|
|
108
108
|
);
|
|
109
|
-
}), _ =
|
|
109
|
+
}), _ = y(function({ children: r, value: a, isSelected: o, tabsLength: l }, h) {
|
|
110
110
|
return /* @__PURE__ */ c(
|
|
111
111
|
f.Trigger,
|
|
112
112
|
{
|
|
@@ -133,13 +133,13 @@ const K = k(function({ children: r, onChange: a, className: o, dropdown: l, noMa
|
|
|
133
133
|
}
|
|
134
134
|
);
|
|
135
135
|
});
|
|
136
|
-
function Q({ text:
|
|
136
|
+
function Q({ text: b }) {
|
|
137
137
|
return /* @__PURE__ */ e(
|
|
138
138
|
"div",
|
|
139
139
|
{
|
|
140
140
|
"aria-hidden": !0,
|
|
141
141
|
className: "mint:absolute mint:top-11 mint:left-1/2 mint:transform mint:whitespace-nowrap mint:-translate-x-1/2 mint:-translate-y-1/2 mint:peer-hover:opacity-100 mint:opacity-0 mint:text-white mint:rounded-lg mint:px-1.5 mint:py-0.5 mint:text-xs mint:bg-primary-dark",
|
|
142
|
-
children:
|
|
142
|
+
children: b
|
|
143
143
|
}
|
|
144
144
|
);
|
|
145
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-group.js","sources":["../../../src/components/content-components/code-group.tsx"],"sourcesContent":["\nimport * as TabsPrimitive from '@radix-ui/react-tabs';\nimport React, {\n ComponentPropsWithoutRef,\n ReactElement,\n ReactNode,\n forwardRef,\n useCallback,\n useState,\n useRef,\n} from 'react';\nimport { ChevronDownFilled } from '@fluentui/react-icons';\n\nimport { cn } from '../../utils/cn';\nimport { CodeBlock } from './code-block';\nimport { CopyToClipboardButton } from './code-block';\nimport { getNodeText } from '../../utils/get-node-text';\nimport { capitalize } from '../../utils/string';\n\ntype CodeBlockProps = ComponentPropsWithoutRef<typeof CodeBlock>;\n\nexport type CodeGroupPropsBase = {\n dropdown?: boolean;\n isSmallText?: boolean;\n noMargins?: boolean;\n children?: ReactElement<CodeBlockProps>[] | ReactElement<CodeBlockProps>;\n onChange?: (index: number) => void;\n};\n\nexport type CodeGroupProps = CodeGroupPropsBase &\n Omit<ComponentPropsWithoutRef<'div'>, keyof CodeGroupPropsBase | 'dir'>;\n\ntype CodeBlockChild = Exclude<React.ReactElement<CodeBlockProps>, boolean | null | undefined>;\n\nexport const CodeGroup = forwardRef<HTMLDivElement, CodeGroupProps>(function CodeGroup(\n { children, onChange, className, dropdown, noMargins, ...restProps },\n ref\n) {\n // Filter out props that are incompatible with TabsPrimitive.Root\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { defaultValue, ...props } = restProps as any;\n const triggerRefs = useRef<Map<number, HTMLButtonElement>>(new Map());\n const childArr = Array.isArray(children)\n ? children\n : (React.Children.toArray(children) as Array<CodeBlockChild>);\n\n const [selectedTab, setSelectedTab] = useState(0);\n\n const handleValueChange = useCallback(\n (value: string) => {\n const index = Number(value);\n const wasFocusOnTab = document.activeElement?.getAttribute('role') === 'tab';\n\n setSelectedTab(index);\n onChange?.(index);\n\n if (wasFocusOnTab) {\n requestAnimationFrame(() => {\n const trigger = triggerRefs.current.get(index);\n if (trigger) {\n trigger.focus();\n }\n });\n }\n },\n [onChange]\n );\n\n if (!children) {\n return null;\n }\n\n if (childArr.length === 0) {\n console.warn('CodeGroup has no children, expected at least one CodeBlock child.');\n return null;\n }\n\n const selectedIndex = Number(selectedTab);\n\n const SelectedFilename = () => {\n return (\n <div className=\"mint:flex mint:items-center mint:gap-1.5 mint:text-xs mint:font-medium mint:min-w-0\">\n <span className=\"mint:truncate mint:text-[#171717] mint:dark:text-[#fafafa]\">\n {childArr[selectedIndex]?.props.fileName}\n </span>\n </div>\n );\n };\n\n const TabList = () => {\n return (\n <TabsPrimitive.List className=\"mint:flex-1 mint:min-w-0 mint:text-xs mint:leading-6 mint:rounded-tl-xl mint:gap-1 mint:flex mint:overflow-x-auto mint:overflow-y-hidden\">\n {childArr.map((child, index) => (\n <TabItem\n key={child.props.fileName + 'TabItem' + index}\n value={String(index)}\n isSelected={selectedIndex === index}\n tabsLength={childArr.length}\n ref={(el) => {\n if (el) {\n triggerRefs.current.set(index, el);\n }\n }}\n >\n {child.props.fileName}\n </TabItem>\n ))}\n </TabsPrimitive.List>\n );\n };\n\n const LanguageDropdown = () => {\n return (\n <div className=\"mint:relative\">\n <select\n value={childArr[selectedIndex]?.props.language || ''}\n onChange={(e) => {\n const language = e.target.value;\n const index = childArr.findIndex((child) => child.props.language === language);\n if (index !== -1) {\n handleValueChange(String(index));\n }\n }}\n className=\"mint:appearance-none mint:bg-transparent mint:border mint:border-[#e5e5e5] mint:dark:border-[#262626] mint:rounded-lg mint:px-2.5 mint:pr-7 mint:py-1 mint:text-xs mint:font-medium mint:text-[#171717] mint:dark:text-[#fafafa] mint:cursor-pointer mint:focus:outline-0\"\n >\n {childArr.map((child, index) => (\n <option key={`${child.props.language}-${child.props.fileName}-${index}`} value={child.props.language}>\n {capitalize(child.props.language || '')}\n </option>\n ))}\n </select>\n <ChevronDownFilled className=\"mint:absolute mint:right-2 mint:top-1/2 mint:-translate-y-1/2 mint:w-3.5 mint:h-3.5 mint:pointer-events-none mint:text-[#737373] mint:dark:text-[#a3a3a3]\" />\n </div>\n );\n };\n\n return (\n <TabsPrimitive.Root\n defaultValue={defaultValue == undefined ? undefined : (typeof defaultValue === 'string' ? defaultValue : String(defaultValue))}\n ref={ref}\n value={String(selectedTab)}\n onValueChange={handleValueChange}\n className={cn(\n !noMargins && 'mint:mt-4 mint:mb-4',\n 'mint:flex mint:flex-col not-prose mint:relative mint:overflow-hidden mint:rounded-2xl mint:border mint:border-[#e5e5e5] mint:dark:border-[#262626] mint:bg-white mint:dark:bg-[#0a0a0a]',\n className\n )}\n asChild={false}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {...(props as any)}\n >\n <div\n className={cn(\n 'mint:flex mint:items-center mint:justify-between mint:gap-2 mint:relative mint:px-2.5 mint:py-2',\n dropdown ? '' : ''\n )}\n >\n {dropdown ? <SelectedFilename /> : <TabList />}\n <div className=\"mint:flex mint:items-center mint:justify-end mint:shrink-0 mint:gap-1.5\">\n {dropdown && <LanguageDropdown />}\n <CopyToClipboardButton\n textToCopy={getNodeText(childArr[selectedIndex]?.props?.children)}\n showTooltip={true}\n />\n </div>\n </div>\n <div className=\"mint:flex mint:flex-1 mint:overflow-hidden\">\n {childArr.map((child, index) => {\n return (\n <TabsPrimitive.Content\n key={`${child.props.fileName}-${child.props.language}-${index}`}\n value={String(index)}\n className=\"mint:w-full mint:min-w-full mint:max-w-full mint:h-full mint:max-h-full\"\n tabIndex={-1}\n >\n <div className=\"mint:code-scrollbar mint:overflow-scroll mint:max-h-[calc(40vh-3rem)]\">\n {child}\n </div>\n </TabsPrimitive.Content>\n );\n })}\n </div>\n </TabsPrimitive.Root>\n );\n});\n\nconst TabItem = forwardRef<\n React.ElementRef<typeof TabsPrimitive.Trigger>,\n {\n children: ReactNode;\n value: string;\n isSelected: boolean;\n tabsLength: number;\n }\n>(function TabItem({ children, value, isSelected, tabsLength }, ref) {\n return (\n <TabsPrimitive.Trigger\n ref={ref}\n value={value}\n className={cn(\n 'mint:group mint:flex mint:items-center mint:relative mint:gap-1.5 mint:my-1 mint:mb-1.5 mint:outline-0 mint:whitespace-nowrap mint:font-medium mint:ml-0! mint:first:ml-2.5! mint:focus:outline-2',\n isSelected && 'mint:text-[#9263f1] mint:dark:text-[#c9aaf9]',\n !isSelected && 'mint:text-[#737373] mint:dark:text-[#a3a3a3]'\n )}\n >\n <div\n className={cn(\n 'mint:flex mint:items-center mint:gap-1.5 mint:px-1.5 mint:rounded-lg mint:z-10',\n tabsLength > 1 &&\n 'mint:group-hover:bg-[#f5f5f5] mint:group-hover:dark:bg-[#1a1a1a] mint:group-hover:text-[#9263f1] mint:group-hover:dark:text-[#c9aaf9]'\n )}\n >\n {children}\n </div>\n\n {isSelected && (\n <div className=\"mint:absolute mint:-bottom-1.5 mint:left-0 mint:right-0 mint:h-0.5 mint:rounded-full mint:bg-[#9263f1] mint:dark:bg-[#c9aaf9]\" />\n )}\n </TabsPrimitive.Trigger>\n );\n});\n\nexport function CodeBlockTooltip({ text }: { text: string }) {\n return (\n <div\n aria-hidden\n className=\"mint:absolute mint:top-11 mint:left-1/2 mint:transform mint:whitespace-nowrap mint:-translate-x-1/2 mint:-translate-y-1/2 mint:peer-hover:opacity-100 mint:opacity-0 mint:text-white mint:rounded-lg mint:px-1.5 mint:py-0.5 mint:text-xs mint:bg-primary-dark\"\n >\n {text}\n </div>\n );\n}\n"],"names":["CodeGroup","forwardRef","children","onChange","className","dropdown","noMargins","restProps","ref","defaultValue","props","triggerRefs","useRef","childArr","React","selectedTab","setSelectedTab","useState","handleValueChange","useCallback","value","index","wasFocusOnTab","_a","trigger","selectedIndex","SelectedFilename","jsx","TabList","TabsPrimitive","child","TabItem","el","LanguageDropdown","jsxs","e","language","capitalize","ChevronDownFilled","cn","CopyToClipboardButton","getNodeText","_b","isSelected","tabsLength","CodeBlockTooltip","text"],"mappings":";;;;;;;;AAkCO,MAAMA,IAAYC,EAA2C,SAClE,EAAE,UAAAC,GAAU,UAAAC,GAAU,WAAAC,GAAW,UAAAC,GAAU,WAAAC,GAAW,GAAGC,EAAA,GACzDC,GACA;;AAGA,QAAM,EAAE,cAAAC,GAAc,GAAGC,EAAA,IAAUH,GAC7BI,IAA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WY;AAAA,cACT;AAAA,cACAK,IAAa,KACX;AAAA,YAAA;AAAA,YAGH,UAAA1C;AAAA,UAAA;AAAA,QAAA;AAAA,QAGFyC,KACC,gBAAAhB,EAAC,OAAA,EAAI,WAAU,gIAAA,CAAgI;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIvJ,CAAC;AAEM,SAASkB,EAAiB,EAAE,MAAAC,KAA0B;AAC3D,SACE,gBAAAnB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,eAAW;AAAA,MACX,WAAU;AAAA,MAET,UAAAmB;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
1
|
+
{"version":3,"file":"code-group.js","sources":["../../../src/components/content-components/code-group.tsx"],"sourcesContent":["\nimport * as TabsPrimitive from '@radix-ui/react-tabs';\nimport React, {\n ComponentPropsWithoutRef,\n ReactElement,\n ReactNode,\n forwardRef,\n useCallback,\n useState,\n useRef,\n} from 'react';\nimport { ChevronDownFilled } from '@fluentui/react-icons';\n\nimport { cn } from '../../utils/cn';\nimport { CodeBlock } from './code-block';\nimport { CopyToClipboardButton } from './code-block';\nimport { getNodeText } from '../../utils/get-node-text';\nimport { capitalize } from '../../utils/string';\n\ntype CodeBlockProps = ComponentPropsWithoutRef<typeof CodeBlock>;\n\nexport type CodeGroupPropsBase = {\n dropdown?: boolean;\n isSmallText?: boolean;\n noMargins?: boolean;\n children?: ReactElement<CodeBlockProps>[] | ReactElement<CodeBlockProps>;\n onChange?: (index: number) => void;\n};\n\nexport type CodeGroupProps = CodeGroupPropsBase &\n Omit<ComponentPropsWithoutRef<'div'>, keyof CodeGroupPropsBase | 'dir'>;\n\ntype CodeBlockChild = Exclude<React.ReactElement<CodeBlockProps>, boolean | null | undefined>;\n\nexport const CodeGroup = forwardRef<HTMLDivElement, CodeGroupProps>(function CodeGroup(\n { children, onChange, className, dropdown, noMargins, ...restProps },\n ref\n) {\n // Filter out props that are incompatible with TabsPrimitive.Root\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { defaultValue, ...props } = restProps as any;\n const triggerRefs = useRef<Map<number, HTMLButtonElement>>(new Map());\n const childArr = Array.isArray(children)\n ? children\n : (React.Children.toArray(children) as Array<CodeBlockChild>);\n\n const [selectedTab, setSelectedTab] = useState(0);\n\n const handleValueChange = useCallback(\n (value: string) => {\n const index = Number(value);\n const wasFocusOnTab = document.activeElement?.getAttribute('role') === 'tab';\n\n setSelectedTab(index);\n onChange?.(index);\n\n if (wasFocusOnTab) {\n requestAnimationFrame(() => {\n const trigger = triggerRefs.current.get(index);\n if (trigger) {\n trigger.focus();\n }\n });\n }\n },\n [onChange]\n );\n\n if (!children) {\n return null;\n }\n\n if (childArr.length === 0) {\n console.warn('CodeGroup has no children, expected at least one CodeBlock child.');\n return null;\n }\n\n const selectedIndex = Number(selectedTab);\n\n const SelectedFilename = () => {\n return (\n <div className=\"mint:flex mint:items-center mint:gap-1.5 mint:text-xs mint:font-medium mint:min-w-0\">\n <span className=\"mint:truncate mint:text-[#171717] mint:dark:text-[#fafafa]\">\n {childArr[selectedIndex]?.props.fileName}\n </span>\n </div>\n );\n };\n\n const TabList = () => {\n return (\n <TabsPrimitive.List className=\"mint:flex-1 mint:min-w-0 mint:text-xs mint:leading-6 mint:rounded-tl-xl mint:gap-1 mint:flex mint:overflow-x-auto mint:overflow-y-hidden\">\n {childArr.map((child, index) => (\n <TabItem\n key={child.props.fileName + 'TabItem' + index}\n value={String(index)}\n isSelected={selectedIndex === index}\n tabsLength={childArr.length}\n ref={(el) => {\n if (el) {\n triggerRefs.current.set(index, el);\n }\n }}\n >\n {child.props.fileName}\n </TabItem>\n ))}\n </TabsPrimitive.List>\n );\n };\n\n const LanguageDropdown = () => {\n return (\n <div className=\"mint:relative\">\n <select\n value={childArr[selectedIndex]?.props.language || ''}\n onChange={(e) => {\n const language = e.target.value;\n const index = childArr.findIndex((child) => child.props.language === language);\n if (index !== -1) {\n handleValueChange(String(index));\n }\n }}\n className=\"mint:appearance-none mint:bg-transparent mint:border mint:border-[#e5e5e5] mint:dark:border-[#262626] mint:rounded-lg mint:px-2.5 mint:pr-7 mint:py-1 mint:text-xs mint:font-medium mint:text-[#171717] mint:dark:text-[#fafafa] mint:cursor-pointer mint:focus:outline-0\"\n >\n {childArr.map((child, index) => (\n <option key={`${child.props.language}-${child.props.fileName}-${index}`} value={child.props.language}>\n {capitalize(child.props.language || '')}\n </option>\n ))}\n </select>\n <ChevronDownFilled className=\"mint:absolute mint:right-2 mint:top-1/2 mint:-translate-y-1/2 mint:w-3.5 mint:h-3.5 mint:pointer-events-none mint:text-[#737373] mint:dark:text-[#a3a3a3]\" />\n </div>\n );\n };\n\n return (\n <TabsPrimitive.Root\n defaultValue={defaultValue == undefined ? undefined : (typeof defaultValue === 'string' ? defaultValue : String(defaultValue))}\n ref={ref}\n value={String(selectedTab)}\n onValueChange={handleValueChange}\n className={cn(\n !noMargins && 'mint:mt-4 mint:mb-4',\n 'mint:flex mint:flex-col not-prose mint:relative mint:overflow-hidden mint:rounded-2xl mint:border mint:border-[#e5e5e5] mint:dark:border-[#262626] mint:bg-white mint:dark:bg-[#0a0a0a]',\n className\n )}\n asChild={false}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {...(props as any)}\n >\n <div\n className={cn(\n 'mint:flex mint:items-center mint:justify-between mint:gap-2 mint:relative mint:px-2.5 mint:py-2',\n dropdown ? '' : ''\n )}\n >\n {dropdown ? <SelectedFilename /> : <TabList />}\n <div className=\"mint:flex mint:items-center mint:justify-end mint:shrink-0 mint:gap-1.5\">\n {dropdown && <LanguageDropdown />}\n <CopyToClipboardButton\n textToCopy={getNodeText(childArr[selectedIndex]?.props?.children)}\n showTooltip={true}\n />\n </div>\n </div>\n <div className=\"mint:flex mint:flex-1 mint:overflow-hidden\">\n {childArr.map((child, index) => {\n return (\n <TabsPrimitive.Content\n key={`${child.props.fileName}-${child.props.language}-${index}`}\n value={String(index)}\n className=\"mint:w-full mint:min-w-full mint:max-w-full mint:h-full mint:max-h-full\"\n tabIndex={-1}\n >\n <div className=\"mint:overflow-scroll mint:max-h-[calc(40vh-3rem)] mint:scrollbar-thin mint:scrollbar-thumb-rounded mint:scrollbar-track-zinc-200 mint:dark:scrollbar-track-zinc-800 mint:scrollbar-thumb-black/15 mint:dark:scrollbar-thumb-white/20 mint:hover:scrollbar-thumb-black/20 mint:dark:hover:scrollbar-thumb-white/25 mint:active:scrollbar-thumb-black/20 mint:dark:active:scrollbar-thumb-white/25\">\n {child}\n </div>\n </TabsPrimitive.Content>\n );\n })}\n </div>\n </TabsPrimitive.Root>\n );\n});\n\nconst TabItem = forwardRef<\n React.ElementRef<typeof TabsPrimitive.Trigger>,\n {\n children: ReactNode;\n value: string;\n isSelected: boolean;\n tabsLength: number;\n }\n>(function TabItem({ children, value, isSelected, tabsLength }, ref) {\n return (\n <TabsPrimitive.Trigger\n ref={ref}\n value={value}\n className={cn(\n 'mint:group mint:flex mint:items-center mint:relative mint:gap-1.5 mint:my-1 mint:mb-1.5 mint:outline-0 mint:whitespace-nowrap mint:font-medium mint:ml-0! mint:first:ml-2.5! mint:focus:outline-2',\n isSelected && 'mint:text-[#9263f1] mint:dark:text-[#c9aaf9]',\n !isSelected && 'mint:text-[#737373] mint:dark:text-[#a3a3a3]'\n )}\n >\n <div\n className={cn(\n 'mint:flex mint:items-center mint:gap-1.5 mint:px-1.5 mint:rounded-lg mint:z-10',\n tabsLength > 1 &&\n 'mint:group-hover:bg-[#f5f5f5] mint:group-hover:dark:bg-[#1a1a1a] mint:group-hover:text-[#9263f1] mint:group-hover:dark:text-[#c9aaf9]'\n )}\n >\n {children}\n </div>\n\n {isSelected && (\n <div className=\"mint:absolute mint:-bottom-1.5 mint:left-0 mint:right-0 mint:h-0.5 mint:rounded-full mint:bg-[#9263f1] mint:dark:bg-[#c9aaf9]\" />\n )}\n </TabsPrimitive.Trigger>\n );\n});\n\nexport function CodeBlockTooltip({ text }: { text: string }) {\n return (\n <div\n aria-hidden\n className=\"mint:absolute mint:top-11 mint:left-1/2 mint:transform mint:whitespace-nowrap mint:-translate-x-1/2 mint:-translate-y-1/2 mint:peer-hover:opacity-100 mint:opacity-0 mint:text-white mint:rounded-lg mint:px-1.5 mint:py-0.5 mint:text-xs mint:bg-primary-dark\"\n >\n {text}\n </div>\n );\n}\n"],"names":["CodeGroup","forwardRef","children","onChange","className","dropdown","noMargins","restProps","ref","defaultValue","props","triggerRefs","useRef","childArr","React","selectedTab","setSelectedTab","useState","handleValueChange","useCallback","value","index","wasFocusOnTab","_a","trigger","selectedIndex","SelectedFilename","jsx","TabList","TabsPrimitive","child","TabItem","el","LanguageDropdown","jsxs","e","language","capitalize","ChevronDownFilled","cn","CopyToClipboardButton","getNodeText","_b","isSelected","tabsLength","CodeBlockTooltip","text"],"mappings":";;;;;;;;AAkCO,MAAMA,IAAYC,EAA2C,SAClE,EAAE,UAAAC,GAAU,UAAAC,GAAU,WAAAC,GAAW,UAAAC,GAAU,WAAAC,GAAW,GAAGC,EAAA,GACzDC,GACA;;AAGA,QAAM,EAAE,cAAAC,GAAc,GAAGC,EAAA,IAAUH,GAC7BI,IAAcC,EAAuC,oBAAI,KAAK,GAC9DC,IAAW,MAAM,QAAQX,CAAQ,IACnCA,IACCY,EAAM,SAAS,QAAQZ,CAAQ,GAE9B,CAACa,GAAaC,CAAc,IAAIC,EAAS,CAAC,GAE1CC,IAAoBC;AAAA,IACxB,CAACC,MAAkB;;AACjB,YAAMC,IAAQ,OAAOD,CAAK,GACpBE,MAAgBC,IAAA,SAAS,kBAAT,gBAAAA,EAAwB,aAAa,aAAY;AAEvE,MAAAP,EAAeK,CAAK,GACpBlB,KAAA,QAAAA,EAAWkB,IAEPC,KACF,sBAAsB,MAAM;AAC1B,cAAME,IAAUb,EAAY,QAAQ,IAAIU,CAAK;AAC7C,QAAIG,KACFA,EAAQ,MAAA;AAAA,MAEZ,CAAC;AAAA,IAEL;AAAA,IACA,CAACrB,CAAQ;AAAA,EAAA;AAGX,MAAI,CAACD;AACH,WAAO;AAGT,MAAI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AA,UAAd;AAAA,YAEC,OAAO,OAAOR,CAAK;AAAA,YACnB,WAAU;AAAA,YACV,UAAU;AAAA,YAEV,UAAA,gBAAAM,EAAC,OAAA,EAAI,WAAU,oYACZ,UAAAG,EAAA,CACH;AAAA,UAAA;AAAA,UAPK,GAAGA,EAAM,MAAM,QAAQ,IAAIA,EAAM,MAAM,QAAQ,IAAIT,CAAK;AAAA,QAAA,CAUlE,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC,GAEKU,IAAU9B,EAQd,SAAiB,EAAE,UAAAC,GAAU,OAAAkB,GAAO,YAAAuB,GAAY,YAAAC,EAAA,GAAcpC,GAAK;AACnE,SACE,gBAAA0B;AAAA,IAACL,EAAc;AAAA,IAAd;AAAA,MACC,KAAArB;AAAA,MACA,OAAAY;AAAA,MACA,WAAWmB;AAAA,QACT;AAAA,QACAI,KAAc;AAAA,QACd,CAACA,KAAc;AAAA,MAAA;AAAA,MAGjB,UAAA;AAAA,QAAA,gBAAAhB;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAWY;AAAA,cACT;AAAA,cACAK,IAAa,KACX;AAAA,YAAA;AAAA,YAGH,UAAA1C;AAAA,UAAA;AAAA,QAAA;AAAA,QAGFyC,KACC,gBAAAhB,EAAC,OAAA,EAAI,WAAU,gIAAA,CAAgI;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIvJ,CAAC;AAEM,SAASkB,EAAiB,EAAE,MAAAC,KAA0B;AAC3D,SACE,gBAAAnB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,eAAW;AAAA,MACX,WAAU;AAAA,MAET,UAAAmB;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -15,7 +15,7 @@ const y = i.forwardRef(
|
|
|
15
15
|
/* @__PURE__ */ m(
|
|
16
16
|
"div",
|
|
17
17
|
{
|
|
18
|
-
className: "mint:relative mint:block mint:mb-4 mint:mt-
|
|
18
|
+
className: "mint:relative mint:block mint:mb-4 mint:mt-4",
|
|
19
19
|
role: "region",
|
|
20
20
|
"aria-label": "Data table",
|
|
21
21
|
children: [
|
|
@@ -32,7 +32,7 @@ const y = i.forwardRef(
|
|
|
32
32
|
]
|
|
33
33
|
}
|
|
34
34
|
),
|
|
35
|
-
/* @__PURE__ */ r("div", { className: "mint:mt-
|
|
35
|
+
/* @__PURE__ */ r("div", { className: "mint:mt-1 mint:overflow-x-auto", children: /* @__PURE__ */ r(
|
|
36
36
|
"table",
|
|
37
37
|
{
|
|
38
38
|
ref: l,
|