@multiplatform.one/markdown 11.12.2 → 11.13.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/cjs/MdxCodeBlock/index.cjs +20 -98
- package/dist/cjs/MdxCodeBlock/index.native.cjs +23 -104
- package/dist/cjs/MdxCodeBlock/index.native.js +23 -104
- package/dist/cjs/MdxCodeBlock/index.native.js.map +1 -1
- package/dist/cjs/components/CodeBlock.cjs +4 -25
- package/dist/cjs/components/CodeBlock.native.cjs +4 -26
- package/dist/cjs/components/CodeBlock.native.js +4 -26
- package/dist/cjs/components/CodeBlock.native.js.map +1 -1
- package/dist/esm/MdxCodeBlock/index.mjs +23 -101
- package/dist/esm/MdxCodeBlock/index.mjs.map +1 -1
- package/dist/esm/MdxCodeBlock/index.native.js +26 -107
- package/dist/esm/MdxCodeBlock/index.native.js.map +1 -1
- package/dist/esm/components/CodeBlock.mjs +5 -26
- package/dist/esm/components/CodeBlock.mjs.map +1 -1
- package/dist/esm/components/CodeBlock.native.js +5 -27
- package/dist/esm/components/CodeBlock.native.js.map +1 -1
- package/dist/jsx/MdxCodeBlock/index.mjs +23 -101
- package/dist/jsx/MdxCodeBlock/index.mjs.map +1 -1
- package/dist/jsx/MdxCodeBlock/index.native.cjs +23 -104
- package/dist/jsx/MdxCodeBlock/index.native.js +23 -104
- package/dist/jsx/MdxCodeBlock/index.native.js.map +1 -1
- package/dist/jsx/components/CodeBlock.mjs +5 -26
- package/dist/jsx/components/CodeBlock.mjs.map +1 -1
- package/dist/jsx/components/CodeBlock.native.cjs +4 -26
- package/dist/jsx/components/CodeBlock.native.js +4 -26
- package/dist/jsx/components/CodeBlock.native.js.map +1 -1
- package/package.json +10 -10
- package/src/MdxCodeBlock/index.tsx +33 -127
- package/src/MdxCodeBlock/mdxCodeBlock.spec.tsx +50 -49
- package/src/components/CodeBlock.tsx +12 -46
- package/src/stories/Code.stories.tsx +2 -1
- package/types/MdxCodeBlock/index.d.ts +6 -0
- package/types/MdxCodeBlock/index.d.ts.map +1 -1
- package/types/components/CodeBlock.d.ts +4 -6
- package/types/components/CodeBlock.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.native.js","names":[],"sources":["cjs/components/CodeBlock.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar CodeBlock_exports = {};\n__export(CodeBlock_exports, {\n CodeBlock: () => CodeBlock\n});\nmodule.exports = __toCommonJS(CodeBlock_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_components = require(\"@multiplatform.one/components\");\nvar
|
|
1
|
+
{"version":3,"file":"CodeBlock.native.js","names":[],"sources":["cjs/components/CodeBlock.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar CodeBlock_exports = {};\n__export(CodeBlock_exports, {\n CodeBlock: () => CodeBlock\n});\nmodule.exports = __toCommonJS(CodeBlock_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_components = require(\"@multiplatform.one/components\");\nvar import_tamagui = require(\"tamagui\");\nfunction CodeBlock(param) {\n var { children, lang, theme: themeProp = \"auto\" } = param;\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.View, {\n marginVertical: \"2\",\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.CodeBlock, {\n language: lang || \"text\",\n theme: themeProp === \"auto\" ? void 0 : themeProp,\n children\n })\n });\n}\n//# sourceMappingURL=CodeBlock.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,oBAAoB,CAAC;AACzB,SAAS,mBAAmB,EAC1B,iBAAiB,UACnB,CAAC;AACD,OAAO,UAAU,aAAa,iBAAiB;AAC/C,IAAI,qBAAqB,QAAQ,mBAAmB;AACpD,IAAI,oBAAoB,QAAQ,+BAA+B;AAC/D,IAAI,iBAAiB,QAAQ,SAAS;AACtC,SAAS,UAAU,OAAO;CACxB,IAAI,EAAE,UAAU,MAAM,OAAO,YAAY,WAAW;CACpD,OAAuB,iBAAC,GAAG,mBAAmB,IAAG,CAAE,eAAe,MAAM;EACtE,gBAAgB;EAChB,UAA0B,iBAAC,GAAG,mBAAmB,IAAG,CAAE,kBAAkB,WAAW;GACjF,UAAU,QAAQ;GAClB,OAAO,cAAc,SAAS,KAAK,IAAI;GACvC;EACF,CAAC;CACH,CAAC;AACH"}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import { Button,
|
|
2
|
-
import { useResolvedKnobs } from "@multiplatform.one/theme";
|
|
3
|
-
import { LinearGradient } from "@tamagui/linear-gradient";
|
|
1
|
+
import { Button, CodeBlock } from "@multiplatform.one/components";
|
|
4
2
|
import rangeParser from "parse-numeric-range";
|
|
5
3
|
import { useContext, useMemo, useState } from "react";
|
|
6
|
-
import {
|
|
7
|
-
import { CheckCircleIcon, ClipboardIcon } from "../icons/index.mjs";
|
|
8
|
-
import { useCutoffGradientColors } from "../shared/cutoffGradient.mjs";
|
|
9
|
-
import { tokenPx } from "../shared/tokenPx.mjs";
|
|
4
|
+
import { XStack, YStack } from "tamagui";
|
|
10
5
|
import { MDXCodeBlockContext } from "./mdxCodeBlockContext.mjs";
|
|
11
|
-
import {
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
7
|
|
|
13
|
-
const zIndex = { localTop: 100 };
|
|
14
8
|
function extractCodeText(children) {
|
|
15
9
|
if (typeof children === "string") return children;
|
|
16
10
|
if (Array.isArray(children)) return children.map(extractCodeText).join("");
|
|
@@ -25,109 +19,37 @@ function extractLanguage(className) {
|
|
|
25
19
|
return match?.[1] || "text";
|
|
26
20
|
}
|
|
27
21
|
function MDXCodeBlock(props) {
|
|
28
|
-
const { children, className, copyable, id, isCollapsible, isHighlightingLines, showLineNumbers
|
|
22
|
+
const { children, className, copyable, id, isCollapsible, isHighlightingLines, showLineNumbers, size, line } = {
|
|
29
23
|
...useContext(MDXCodeBlockContext),
|
|
30
24
|
...props
|
|
31
25
|
};
|
|
32
|
-
const { knobProps } = useResolvedKnobs();
|
|
33
|
-
const gradientColors = useCutoffGradientColors();
|
|
34
|
-
const cutoffMaxHeight = tokenPx(knobProps.sizeToken, 24) * 16;
|
|
35
|
-
const gradientHeight = tokenPx(knobProps.sizeToken, 24) * 8;
|
|
36
|
-
const iconPx = tokenPx(knobProps.label.fontSize, 14, "fontSize");
|
|
37
26
|
const codeText = useMemo(() => extractCodeText(children).replace(/\n$/, ""), [children]);
|
|
38
27
|
const language = useMemo(() => extractLanguage(className), [className]);
|
|
39
|
-
const tokens = useShikiTokens(codeText, language);
|
|
40
|
-
const lines = tokens?.length ?? codeText.split("\n").length;
|
|
41
|
-
const showLineNumbers = propShowLineNumbers ?? lines > 10;
|
|
42
28
|
const [isCollapsed, setIsCollapsed] = useState(isCollapsible);
|
|
43
|
-
const isLong = lines > 22;
|
|
44
|
-
const [isCutoff, setIsCutoff] = useState(isLong && !isCollapsible);
|
|
45
|
-
const { hasCopied, onCopy } = useClipboard(codeText);
|
|
46
29
|
const highlightLines = useMemo(() => {
|
|
47
30
|
if (!isHighlightingLines || !line) return [];
|
|
48
31
|
return rangeParser(line);
|
|
49
32
|
}, [isHighlightingLines, line]);
|
|
50
|
-
|
|
51
|
-
|
|
33
|
+
const shown = !isCollapsed || !isCollapsible;
|
|
34
|
+
return /* @__PURE__ */ jsxs(YStack, {
|
|
52
35
|
marginBottom: "4",
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}), /* @__PURE__ */ jsx(XStack, {
|
|
71
|
-
position: "absolute",
|
|
72
|
-
bottom: "4",
|
|
73
|
-
left: 0,
|
|
74
|
-
right: 0,
|
|
75
|
-
justifyContent: "center",
|
|
76
|
-
zIndex: zIndex.localTop + 1,
|
|
77
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
78
|
-
onPress: () => setIsCutoff(false),
|
|
79
|
-
children: "Show more"
|
|
80
|
-
})
|
|
81
|
-
})] }),
|
|
82
|
-
(!isCollapsed || !isCollapsible) && /* @__PURE__ */ jsx(Pre, {
|
|
83
|
-
padding: 0,
|
|
84
|
-
marginBottom: 0,
|
|
85
|
-
id,
|
|
86
|
-
"data-line-numbers": showLineNumbers ? "true" : "false",
|
|
87
|
-
children: /* @__PURE__ */ jsx(ScrollView, {
|
|
88
|
-
style: { width: "100%" },
|
|
89
|
-
contentContainerStyle: { minWidth: "100%" },
|
|
90
|
-
horizontal: true,
|
|
91
|
-
showsHorizontalScrollIndicator: false,
|
|
92
|
-
children: /* @__PURE__ */ jsx(Code, {
|
|
93
|
-
backgroundColor: "transparent",
|
|
94
|
-
flex: 1,
|
|
95
|
-
borderWidth: 0,
|
|
96
|
-
...knobProps.panelPadding,
|
|
97
|
-
size: size ?? knobProps.sizeToken,
|
|
98
|
-
...codeProps,
|
|
99
|
-
children: /* @__PURE__ */ jsx(HighlightedCode, {
|
|
100
|
-
tokens,
|
|
101
|
-
highlightLines,
|
|
102
|
-
showLineNumbers,
|
|
103
|
-
children: codeText
|
|
104
|
-
})
|
|
105
|
-
})
|
|
106
|
-
})
|
|
107
|
-
}),
|
|
108
|
-
/* @__PURE__ */ jsxs(XStack, {
|
|
109
|
-
position: "absolute",
|
|
110
|
-
top: "3",
|
|
111
|
-
insetInlineEnd: "3",
|
|
112
|
-
...knobProps.gap,
|
|
113
|
-
children: [(!isCollapsed || !isCollapsible) && (copyable ?? true) && /* @__PURE__ */ jsx(TooltipSimple, {
|
|
114
|
-
label: hasCopied ? "Copied" : "Copy to clipboard",
|
|
115
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
116
|
-
"aria-label": "Copy code to clipboard",
|
|
117
|
-
size: "2",
|
|
118
|
-
display: "max-xs:none",
|
|
119
|
-
icon: hasCopied ? /* @__PURE__ */ jsx(CheckCircleIcon, { size: iconPx }) : /* @__PURE__ */ jsx(ClipboardIcon, { size: iconPx }),
|
|
120
|
-
onPress: onCopy
|
|
121
|
-
})
|
|
122
|
-
}), isCollapsible && /* @__PURE__ */ jsx(Button, {
|
|
123
|
-
"aria-label": "Show or hide code",
|
|
124
|
-
size: "2",
|
|
125
|
-
onPress: () => setIsCollapsed((x) => !x),
|
|
126
|
-
children: isCollapsed ? "Show code" : "Hide code"
|
|
127
|
-
})]
|
|
128
|
-
})
|
|
129
|
-
]
|
|
130
|
-
}) })
|
|
36
|
+
gap: "2",
|
|
37
|
+
id,
|
|
38
|
+
"data-mdx-code-block": "",
|
|
39
|
+
children: [isCollapsible ? /* @__PURE__ */ jsx(XStack, { children: /* @__PURE__ */ jsx(Button, {
|
|
40
|
+
"aria-label": "Show or hide code",
|
|
41
|
+
"aria-expanded": shown,
|
|
42
|
+
size: "2",
|
|
43
|
+
onPress: () => setIsCollapsed((x) => !x),
|
|
44
|
+
children: shown ? "Hide code" : "Show code"
|
|
45
|
+
}) }) : null, shown ? /* @__PURE__ */ jsx(CodeBlock, {
|
|
46
|
+
language,
|
|
47
|
+
copyable,
|
|
48
|
+
showLineNumbers,
|
|
49
|
+
highlightLines,
|
|
50
|
+
size,
|
|
51
|
+
children: codeText
|
|
52
|
+
}) : null]
|
|
131
53
|
});
|
|
132
54
|
}
|
|
133
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["esm/MdxCodeBlock/index.js"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["esm/MdxCodeBlock/index.js"],"sourcesContent":["import { Button, CodeBlock } from \"@multiplatform.one/components\";\nimport rangeParser from \"parse-numeric-range\";\nimport { useContext, useMemo, useState } from \"react\";\nimport { XStack, YStack } from \"tamagui\";\nimport { MDXCodeBlockContext } from \"./mdxCodeBlockContext\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\nfunction extractCodeText(children) {\n if (typeof children === \"string\") return children;\n if (Array.isArray(children)) return children.map(extractCodeText).join(\"\");\n if (children && typeof children === \"object\" && \"props\" in children) {\n return extractCodeText(children.props?.children);\n }\n return String(children ?? \"\");\n}\nfunction extractLanguage(className) {\n if (!className) return \"text\";\n const match = className.match(/language-(\\w+)/);\n return match?.[1] || \"text\";\n}\nfunction MDXCodeBlock(props) {\n const {\n children,\n className,\n copyable,\n id,\n isCollapsible,\n isHighlightingLines,\n showLineNumbers,\n size,\n line\n } = { ...useContext(MDXCodeBlockContext), ...props };\n const codeText = useMemo(() => extractCodeText(children).replace(/\\n$/, \"\"), [children]);\n const language = useMemo(() => extractLanguage(className), [className]);\n const [isCollapsed, setIsCollapsed] = useState(isCollapsible);\n const highlightLines = useMemo(() => {\n if (!isHighlightingLines || !line) return [];\n return rangeParser(line);\n }, [isHighlightingLines, line]);\n const shown = !isCollapsed || !isCollapsible;\n return /* @__PURE__ */ jsxs(YStack, { marginBottom: \"4\", gap: \"2\", id, \"data-mdx-code-block\": \"\", children: [\n isCollapsible ? /* @__PURE__ */ jsx(XStack, { children: /* @__PURE__ */ jsx(\n Button,\n {\n \"aria-label\": \"Show or hide code\",\n \"aria-expanded\": shown,\n size: \"2\",\n onPress: () => setIsCollapsed((x) => !x),\n children: shown ? \"Hide code\" : \"Show code\"\n }\n ) }) : null,\n shown ? /* @__PURE__ */ jsx(\n CodeBlock,\n {\n language,\n copyable,\n showLineNumbers,\n highlightLines,\n size,\n children: codeText\n }\n ) : null\n ] });\n}\nexport {\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AAE,CAAC,IAAI,MACP,QAAwB,oBACtB,WACA;GACE;GACA;GACA;GACA;GACA;GACA,UAAU;EACZ,CACF,IAAI,IACN;CAAE,CAAC;AACL"}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Button,
|
|
3
|
-
import { useResolvedKnobs } from "@multiplatform.one/theme";
|
|
4
|
-
import { LinearGradient } from "@tamagui/linear-gradient";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, CodeBlock } from "@multiplatform.one/components";
|
|
5
3
|
import rangeParser from "parse-numeric-range";
|
|
6
4
|
import { useContext, useMemo, useState } from "react";
|
|
7
|
-
import {
|
|
8
|
-
import { CheckCircleIcon, ClipboardIcon } from "../icons/index.native.js";
|
|
9
|
-
import { useCutoffGradientColors } from "../shared/cutoffGradient.native.js";
|
|
10
|
-
import { tokenPx } from "../shared/tokenPx.native.js";
|
|
5
|
+
import { XStack, YStack } from "tamagui";
|
|
11
6
|
import { MDXCodeBlockContext } from "./mdxCodeBlockContext.native.js";
|
|
12
7
|
|
|
13
|
-
var zIndex = { localTop: 100 };
|
|
14
8
|
function extractCodeText(children) {
|
|
15
9
|
if (typeof children === "string") return children;
|
|
16
10
|
if (Array.isArray(children)) return children.map(extractCodeText).join("");
|
|
@@ -26,120 +20,45 @@ function extractLanguage(className) {
|
|
|
26
20
|
return (match === null || match === void 0 ? void 0 : match[1]) || "text";
|
|
27
21
|
}
|
|
28
22
|
function MDXCodeBlock(props) {
|
|
29
|
-
var
|
|
30
|
-
var { children, className, copyable, id, isCollapsible, isHighlightingLines, showLineNumbers: propShowLineNumbers, size, line, ...codeProps } = {
|
|
23
|
+
var { children, className, copyable, id, isCollapsible, isHighlightingLines, showLineNumbers, size, line } = {
|
|
31
24
|
...useContext(MDXCodeBlockContext),
|
|
32
25
|
...props
|
|
33
26
|
};
|
|
34
|
-
var { knobProps } = useResolvedKnobs();
|
|
35
|
-
var gradientColors = useCutoffGradientColors();
|
|
36
|
-
var cutoffMaxHeight = tokenPx(knobProps.sizeToken, 24) * 16;
|
|
37
|
-
var gradientHeight = tokenPx(knobProps.sizeToken, 24) * 8;
|
|
38
|
-
var iconPx = tokenPx(knobProps.label.fontSize, 14, "fontSize");
|
|
39
27
|
var codeText = useMemo(function() {
|
|
40
28
|
return extractCodeText(children).replace(/\n$/, "");
|
|
41
29
|
}, [children]);
|
|
42
30
|
var language = useMemo(function() {
|
|
43
31
|
return extractLanguage(className);
|
|
44
32
|
}, [className]);
|
|
45
|
-
var tokens = useShikiTokens(codeText, language);
|
|
46
|
-
var lines = (_ref = tokens === null || tokens === void 0 ? void 0 : tokens.length) !== null && _ref !== void 0 ? _ref : codeText.split("\n").length;
|
|
47
|
-
var showLineNumbers = propShowLineNumbers !== null && propShowLineNumbers !== void 0 ? propShowLineNumbers : lines > 10;
|
|
48
33
|
var [isCollapsed, setIsCollapsed] = useState(isCollapsible);
|
|
49
|
-
var isLong = lines > 22;
|
|
50
|
-
var [isCutoff, setIsCutoff] = useState(isLong && !isCollapsible);
|
|
51
|
-
var { hasCopied, onCopy } = useClipboard(codeText);
|
|
52
34
|
var highlightLines = useMemo(function() {
|
|
53
35
|
if (!isHighlightingLines || !line) return [];
|
|
54
36
|
return rangeParser(line);
|
|
55
37
|
}, [isHighlightingLines, line]);
|
|
56
|
-
|
|
57
|
-
|
|
38
|
+
var shown = !isCollapsed || !isCollapsible;
|
|
39
|
+
return /* @__PURE__ */ jsxs(YStack, {
|
|
58
40
|
marginBottom: "4",
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
41
|
+
gap: "2",
|
|
42
|
+
id,
|
|
43
|
+
"data-mdx-code-block": "",
|
|
44
|
+
children: [isCollapsible ? /* @__PURE__ */ jsx(XStack, { children: /* @__PURE__ */ jsx(Button, {
|
|
45
|
+
"aria-label": "Show or hide code",
|
|
46
|
+
"aria-expanded": shown,
|
|
47
|
+
size: "2",
|
|
48
|
+
onPress: function onPress() {
|
|
49
|
+
return setIsCollapsed(function(x) {
|
|
50
|
+
return !x;
|
|
51
|
+
});
|
|
65
52
|
},
|
|
66
|
-
children:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
zIndex: zIndex.localTop
|
|
76
|
-
}), /* @__PURE__ */ jsx(XStack, {
|
|
77
|
-
position: "absolute",
|
|
78
|
-
bottom: "4",
|
|
79
|
-
left: 0,
|
|
80
|
-
right: 0,
|
|
81
|
-
justifyContent: "center",
|
|
82
|
-
zIndex: zIndex.localTop + 1,
|
|
83
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
84
|
-
onPress: function onPress() {
|
|
85
|
-
return setIsCutoff(false);
|
|
86
|
-
},
|
|
87
|
-
children: "Show more"
|
|
88
|
-
})
|
|
89
|
-
})] }),
|
|
90
|
-
(!isCollapsed || !isCollapsible) && /* @__PURE__ */ jsx(Pre, {
|
|
91
|
-
padding: 0,
|
|
92
|
-
marginBottom: 0,
|
|
93
|
-
id,
|
|
94
|
-
"data-line-numbers": showLineNumbers ? "true" : "false",
|
|
95
|
-
children: /* @__PURE__ */ jsx(ScrollView, {
|
|
96
|
-
style: { width: "100%" },
|
|
97
|
-
contentContainerStyle: { minWidth: "100%" },
|
|
98
|
-
horizontal: true,
|
|
99
|
-
showsHorizontalScrollIndicator: false,
|
|
100
|
-
children: /* @__PURE__ */ jsx(Code, {
|
|
101
|
-
backgroundColor: "transparent",
|
|
102
|
-
flex: 1,
|
|
103
|
-
borderWidth: 0,
|
|
104
|
-
...knobProps.panelPadding,
|
|
105
|
-
size: size !== null && size !== void 0 ? size : knobProps.sizeToken,
|
|
106
|
-
...codeProps,
|
|
107
|
-
children: /* @__PURE__ */ jsx(HighlightedCode, {
|
|
108
|
-
tokens,
|
|
109
|
-
highlightLines,
|
|
110
|
-
showLineNumbers,
|
|
111
|
-
children: codeText
|
|
112
|
-
})
|
|
113
|
-
})
|
|
114
|
-
})
|
|
115
|
-
}),
|
|
116
|
-
/* @__PURE__ */ jsxs(XStack, {
|
|
117
|
-
position: "absolute",
|
|
118
|
-
top: "3",
|
|
119
|
-
insetInlineEnd: "3",
|
|
120
|
-
...knobProps.gap,
|
|
121
|
-
children: [(!isCollapsed || !isCollapsible) && (copyable !== null && copyable !== void 0 ? copyable : true) && /* @__PURE__ */ jsx(TooltipSimple, {
|
|
122
|
-
label: hasCopied ? "Copied" : "Copy to clipboard",
|
|
123
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
124
|
-
"aria-label": "Copy code to clipboard",
|
|
125
|
-
size: "2",
|
|
126
|
-
display: "max-xs:none",
|
|
127
|
-
icon: hasCopied ? /* @__PURE__ */ jsx(CheckCircleIcon, { size: iconPx }) : /* @__PURE__ */ jsx(ClipboardIcon, { size: iconPx }),
|
|
128
|
-
onPress: onCopy
|
|
129
|
-
})
|
|
130
|
-
}), isCollapsible && /* @__PURE__ */ jsx(Button, {
|
|
131
|
-
"aria-label": "Show or hide code",
|
|
132
|
-
size: "2",
|
|
133
|
-
onPress: function onPress() {
|
|
134
|
-
return setIsCollapsed(function(x) {
|
|
135
|
-
return !x;
|
|
136
|
-
});
|
|
137
|
-
},
|
|
138
|
-
children: isCollapsed ? "Show code" : "Hide code"
|
|
139
|
-
})]
|
|
140
|
-
})
|
|
141
|
-
]
|
|
142
|
-
}) })
|
|
53
|
+
children: shown ? "Hide code" : "Show code"
|
|
54
|
+
}) }) : null, shown ? /* @__PURE__ */ jsx(CodeBlock, {
|
|
55
|
+
language,
|
|
56
|
+
copyable,
|
|
57
|
+
showLineNumbers,
|
|
58
|
+
highlightLines,
|
|
59
|
+
size,
|
|
60
|
+
children: codeText
|
|
61
|
+
}) : null]
|
|
143
62
|
});
|
|
144
63
|
}
|
|
145
64
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.js","names":["_Fragment"],"sources":["esm/MdxCodeBlock/index.native.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nimport { Button, Code, ErrorBoundary, HighlightedCode, Pre, useClipboard, useShikiTokens, ScrollView } from \"@multiplatform.one/components\";\nimport { useResolvedKnobs } from \"@multiplatform.one/theme\";\nimport { LinearGradient } from \"@tamagui/linear-gradient\";\nimport rangeParser from \"parse-numeric-range\";\nimport { useContext, useMemo, useState } from \"react\";\nimport { TooltipSimple, XStack, YStack } from \"tamagui\";\nimport { CheckCircleIcon, ClipboardIcon } from \"../icons\";\nimport { useCutoffGradientColors } from \"../shared/cutoffGradient\";\nimport { tokenPx } from \"../shared/tokenPx\";\nimport { MDXCodeBlockContext } from \"./mdxCodeBlockContext\";\nvar zIndex = {\n localTop: 100\n};\nfunction extractCodeText(children) {\n if (typeof children === \"string\") return children;\n if (Array.isArray(children)) return children.map(extractCodeText).join(\"\");\n if (children && typeof children === \"object\" && \"props\" in children) {\n var _children_props;\n return extractCodeText((_children_props = children.props) === null || _children_props === void 0 ? void 0 : _children_props.children);\n }\n return String(children !== null && children !== void 0 ? children : \"\");\n}\nfunction extractLanguage(className) {\n if (!className) return \"text\";\n var match = className.match(/language-(\\w+)/);\n return (match === null || match === void 0 ? void 0 : match[1]) || \"text\";\n}\nfunction MDXCodeBlock(props) {\n var _ref;\n var { children, className, copyable, id, isCollapsible, isHighlightingLines, showLineNumbers: propShowLineNumbers, size, line, ...codeProps } = {\n ...useContext(MDXCodeBlockContext),\n ...props\n };\n var { knobProps } = useResolvedKnobs();\n var gradientColors = useCutoffGradientColors();\n var cutoffMaxHeight = tokenPx(knobProps.sizeToken, 24) * 16;\n var gradientHeight = tokenPx(knobProps.sizeToken, 24) * 8;\n var iconPx = tokenPx(knobProps.label.fontSize, 14, \"fontSize\");\n var codeText = useMemo(function() {\n return extractCodeText(children).replace(/\\n$/, \"\");\n }, [\n children\n ]);\n var language = useMemo(function() {\n return extractLanguage(className);\n }, [\n className\n ]);\n var tokens = useShikiTokens(codeText, language);\n var lines = (_ref = tokens === null || tokens === void 0 ? void 0 : tokens.length) !== null && _ref !== void 0 ? _ref : codeText.split(\"\\n\").length;\n var showLineNumbers = propShowLineNumbers !== null && propShowLineNumbers !== void 0 ? propShowLineNumbers : lines > 10;\n var [isCollapsed, setIsCollapsed] = useState(isCollapsible);\n var isLong = lines > 22;\n var [isCutoff, setIsCutoff] = useState(isLong && !isCollapsible);\n var { hasCopied, onCopy } = useClipboard(codeText);\n var highlightLines = useMemo(function() {\n if (!isHighlightingLines || !line) return [];\n return rangeParser(line);\n }, [\n isHighlightingLines,\n line\n ]);\n return /* @__PURE__ */ _jsx(YStack, {\n position: \"relative\",\n marginBottom: \"4\",\n children: /* @__PURE__ */ _jsx(ErrorBoundary, {\n children: /* @__PURE__ */ _jsxs(YStack, {\n position: \"relative\",\n ...isCutoff && {\n maxHeight: cutoffMaxHeight,\n overflow: \"hidden\",\n ...knobProps.borderRadiusNested\n },\n children: [\n (!isCollapsed || !isCollapsible) && isCutoff && /* @__PURE__ */ _jsxs(_Fragment, {\n children: [\n /* @__PURE__ */ _jsx(LinearGradient, {\n position: \"absolute\",\n bottom: 0,\n left: 0,\n right: 0,\n height: gradientHeight,\n colors: gradientColors,\n pointerEvents: \"none\",\n zIndex: zIndex.localTop\n }),\n /* @__PURE__ */ _jsx(XStack, {\n position: \"absolute\",\n bottom: \"4\",\n left: 0,\n right: 0,\n justifyContent: \"center\",\n zIndex: zIndex.localTop + 1,\n children: /* @__PURE__ */ _jsx(Button, {\n onPress: function onPress() {\n return setIsCutoff(false);\n },\n children: \"Show more\"\n })\n })\n ]\n }),\n (!isCollapsed || !isCollapsible) && /* @__PURE__ */ _jsx(Pre, {\n padding: 0,\n marginBottom: 0,\n id,\n \"data-line-numbers\": showLineNumbers ? \"true\" : \"false\",\n children: /* @__PURE__ */ _jsx(ScrollView, {\n style: {\n width: \"100%\"\n },\n contentContainerStyle: {\n minWidth: \"100%\"\n },\n horizontal: true,\n showsHorizontalScrollIndicator: false,\n children: /* @__PURE__ */ _jsx(Code, {\n backgroundColor: \"transparent\",\n flex: 1,\n borderWidth: 0,\n // SP-PAD + T-VALUE via sizeToken (spec MdxCodeBlock; LC-18):\n // inset is the panelPadding role, content type rides the size\n // token — components-CodeBlock parity. Explicit props eject.\n ...knobProps.panelPadding,\n size: size !== null && size !== void 0 ? size : knobProps.sizeToken,\n ...codeProps,\n children: /* @__PURE__ */ _jsx(HighlightedCode, {\n tokens,\n highlightLines,\n showLineNumbers,\n children: codeText\n })\n })\n })\n }),\n /* @__PURE__ */ _jsxs(XStack, {\n position: \"absolute\",\n top: \"3\",\n insetInlineEnd: \"3\",\n ...knobProps.gap,\n children: [\n (!isCollapsed || !isCollapsible) && (copyable !== null && copyable !== void 0 ? copyable : true) && /* @__PURE__ */ _jsx(TooltipSimple, {\n label: hasCopied ? \"Copied\" : \"Copy to clipboard\",\n children: /* @__PURE__ */ _jsx(Button, {\n \"aria-label\": \"Copy code to clipboard\",\n size: \"2\",\n display: \"max-xs:none\",\n icon: hasCopied ? /* @__PURE__ */ _jsx(CheckCircleIcon, {\n size: iconPx\n }) : /* @__PURE__ */ _jsx(ClipboardIcon, {\n size: iconPx\n }),\n onPress: onCopy\n })\n }),\n isCollapsible && /* @__PURE__ */ _jsx(Button, {\n \"aria-label\": \"Show or hide code\",\n size: \"2\",\n onPress: function onPress() {\n return setIsCollapsed(function(x) {\n return !x;\n });\n },\n children: isCollapsed ? \"Show code\" : \"Hide code\"\n })\n ]\n })\n ]\n })\n })\n });\n}\nexport {\n MDXCodeBlock\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;;;;;;;;;AAWA,IAAI,SAAS,EACX,UAAU,IACZ;AACA,SAAS,gBAAgB,UAAU;CACjC,IAAI,OAAO,aAAa,UAAU,OAAO;CACzC,IAAI,MAAM,QAAQ,QAAQ,GAAG,OAAO,SAAS,IAAI,eAAe,CAAC,CAAC,KAAK,EAAE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a;OAIb,GAAG,UAAU;OACb,MAAM,SAAS,QAAQ,SAAS,KAAK,IAAI,OAAO,UAAU;OAC1D,GAAG;OACH,UAA0B,oBAAK,iBAAiB;QAC9C;QACA;QACA;QACA,UAAU;OACZ,CAAC;MACH,CAAC;KACH,CAAC;IACH,CAAC;IACe,qBAAM,QAAQ;KAC5B,UAAU;KACV,KAAK;KACL,gBAAgB;KAChB,GAAG,UAAU;KACb,UAAU,EACP,CAAC,eAAe,CAAC,mBAAmB,aAAa,QAAQ,aAAa,KAAK,IAAI,WAAW,SAAyB,oBAAK,eAAe;MACtI,OAAO,YAAY,WAAW;MAC9B,UAA0B,oBAAK,QAAQ;OACrC,cAAc;OACd,MAAM;OACN,SAAS;OACT,MAAM,YAA4B,oBAAK,iBAAiB,EACtD,MAAM,OACR,CAAC,IAAoB,oBAAK,eAAe,EACvC,MAAM,OACR,CAAC;OACD,SAAS;MACX,CAAC;KACH,CAAC,GACD,iBAAiC,oBAAK,QAAQ;MAC5C,cAAc;MACd,MAAM;MACN,SAAS,SAAS,UAAU;OAC1B,OAAO,eAAe,SAAS,GAAG;QAChC,OAAO,CAAC;OACV,CAAC;MACH;MACA,UAAU,cAAc,cAAc;KACxC,CAAC,CACH;IACF,CAAC;GACH;EACF,CAAC,EACH,CAAC;CACH,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["esm/MdxCodeBlock/index.native.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { Button, CodeBlock } from \"@multiplatform.one/components\";\nimport rangeParser from \"parse-numeric-range\";\nimport { useContext, useMemo, useState } from \"react\";\nimport { XStack, YStack } from \"tamagui\";\nimport { MDXCodeBlockContext } from \"./mdxCodeBlockContext\";\nfunction extractCodeText(children) {\n if (typeof children === \"string\") return children;\n if (Array.isArray(children)) return children.map(extractCodeText).join(\"\");\n if (children && typeof children === \"object\" && \"props\" in children) {\n var _children_props;\n return extractCodeText((_children_props = children.props) === null || _children_props === void 0 ? void 0 : _children_props.children);\n }\n return String(children !== null && children !== void 0 ? children : \"\");\n}\nfunction extractLanguage(className) {\n if (!className) return \"text\";\n var match = className.match(/language-(\\w+)/);\n return (match === null || match === void 0 ? void 0 : match[1]) || \"text\";\n}\nfunction MDXCodeBlock(props) {\n var { children, className, copyable, id, isCollapsible, isHighlightingLines, showLineNumbers, size, line } = {\n ...useContext(MDXCodeBlockContext),\n ...props\n };\n var codeText = useMemo(function() {\n return extractCodeText(children).replace(/\\n$/, \"\");\n }, [\n children\n ]);\n var language = useMemo(function() {\n return extractLanguage(className);\n }, [\n className\n ]);\n var [isCollapsed, setIsCollapsed] = useState(isCollapsible);\n var highlightLines = useMemo(function() {\n if (!isHighlightingLines || !line) return [];\n return rangeParser(line);\n }, [\n isHighlightingLines,\n line\n ]);\n var shown = !isCollapsed || !isCollapsible;\n return /* @__PURE__ */ _jsxs(YStack, {\n marginBottom: \"4\",\n gap: \"2\",\n id,\n \"data-mdx-code-block\": \"\",\n children: [\n isCollapsible ? /* @__PURE__ */ _jsx(XStack, {\n children: /* @__PURE__ */ _jsx(Button, {\n \"aria-label\": \"Show or hide code\",\n \"aria-expanded\": shown,\n size: \"2\",\n onPress: function onPress() {\n return setIsCollapsed(function(x) {\n return !x;\n });\n },\n children: shown ? \"Hide code\" : \"Show code\"\n })\n }) : null,\n shown ? /* @__PURE__ */ _jsx(CodeBlock, {\n language,\n copyable,\n showLineNumbers,\n highlightLines,\n size,\n children: codeText\n }) : null\n ]\n });\n}\nexport {\n MDXCodeBlock\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;;;;AAMA,SAAS,gBAAgB,UAAU;CACjC,IAAI,OAAO,aAAa,UAAU,OAAO;CACzC,IAAI,MAAM,QAAQ,QAAQ,GAAG,OAAO,SAAS,IAAI,eAAe,CAAC,CAAC,KAAK,EAAE;CACzE,IAAI,YAAY,OAAO,aAAa,YAAY,WAAW,UAAU;EACnE,IAAI;EACJ,OAAO,iB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AAW;GACtC;GACA;GACA;GACA;GACA;GACA,UAAU;EACZ,CAAC,IAAI,IACP;CACF,CAAC;AACH"}
|
|
@@ -1,35 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { edgeColorAt, useResolvedKnobs } from "@multiplatform.one/theme";
|
|
1
|
+
import { CodeBlock as CodeBlock$1 } from "@multiplatform.one/components";
|
|
3
2
|
import { View } from "tamagui";
|
|
4
|
-
import { markdownCodeColors } from "../shared/colorRamps.mjs";
|
|
5
3
|
import { jsx } from "react/jsx-runtime";
|
|
6
4
|
|
|
7
5
|
function CodeBlock({ children, lang, theme: themeProp = "auto" }) {
|
|
8
|
-
const { knobProps } = useResolvedKnobs();
|
|
9
|
-
const tokens = useShikiTokens(children, lang || "text", themeProp === "auto" ? void 0 : themeProp);
|
|
10
6
|
return /* @__PURE__ */ jsx(View, {
|
|
11
|
-
...knobProps.borderRadiusNested ?? { borderRadius: "4" },
|
|
12
|
-
backgroundColor: markdownCodeColors.background.base,
|
|
13
|
-
borderWidth: knobProps.borderRadius.borderWidth,
|
|
14
|
-
borderColor: edgeColorAt(markdownCodeColors.border.base, knobProps.borderWidthStop),
|
|
15
|
-
...knobProps.panelPadding,
|
|
16
7
|
marginVertical: "2",
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
children: /* @__PURE__ */ jsx(Code, {
|
|
22
|
-
backgroundColor: "transparent",
|
|
23
|
-
borderWidth: 0,
|
|
24
|
-
padding: 0,
|
|
25
|
-
color: markdownCodeColors.text.base,
|
|
26
|
-
fontSize: knobProps.sizeToken,
|
|
27
|
-
children: /* @__PURE__ */ jsx(HighlightedCode, {
|
|
28
|
-
tokens,
|
|
29
|
-
fontSize: knobProps.sizeToken,
|
|
30
|
-
children
|
|
31
|
-
})
|
|
32
|
-
})
|
|
8
|
+
children: /* @__PURE__ */ jsx(CodeBlock$1, {
|
|
9
|
+
language: lang || "text",
|
|
10
|
+
theme: themeProp === "auto" ? void 0 : themeProp,
|
|
11
|
+
children
|
|
33
12
|
})
|
|
34
13
|
});
|
|
35
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.js","names":[],"sources":["esm/components/CodeBlock.js"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"CodeBlock.js","names":["HouseCodeBlock"],"sources":["esm/components/CodeBlock.js"],"sourcesContent":["import { CodeBlock as HouseCodeBlock } from \"@multiplatform.one/components\";\nimport { View } from \"tamagui\";\nimport { jsx } from \"react/jsx-runtime\";\nfunction CodeBlock({ children, lang, theme: themeProp = \"auto\" }) {\n return /* @__PURE__ */ jsx(View, { marginVertical: \"2\", children: /* @__PURE__ */ jsx(\n HouseCodeBlock,\n {\n language: lang || \"text\",\n theme: themeProp === \"auto\" ? void 0 : themeProp,\n children\n }\n ) });\n}\nexport {\n CodeBlock\n};\n//# sourceMappingURL=CodeBlock.js.map\n"],"mappings":";;;;;AAGA,SAAS,UAAU,EAAE,UAAU,MAAM,OAAO,YAAY,UAAU;CAChE,OAAuB,oBAAI,MAAM;EAAE,gBAAgB;EAAK,UAA0B,oBAChFA,aACA;GACE,UAAU,QAAQ;GAClB,OAAO,cAAc,SAAS,KAAK,IAAI;GACvC;EACF,CACF;CAAE,CAAC;AACL"}
|
|
@@ -1,37 +1,15 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { edgeColorAt, useResolvedKnobs } from "@multiplatform.one/theme";
|
|
2
|
+
import { CodeBlock as CodeBlock$1 } from "@multiplatform.one/components";
|
|
4
3
|
import { View } from "tamagui";
|
|
5
|
-
import { markdownCodeColors } from "../shared/colorRamps.native.js";
|
|
6
4
|
|
|
7
5
|
function CodeBlock(param) {
|
|
8
6
|
var { children, lang, theme: themeProp = "auto" } = param;
|
|
9
|
-
var _knobProps_borderRadiusNested;
|
|
10
|
-
var { knobProps } = useResolvedKnobs();
|
|
11
|
-
var tokens = useShikiTokens(children, lang || "text", themeProp === "auto" ? void 0 : themeProp);
|
|
12
7
|
return /* @__PURE__ */ jsx(View, {
|
|
13
|
-
...(_knobProps_borderRadiusNested = knobProps.borderRadiusNested) !== null && _knobProps_borderRadiusNested !== void 0 ? _knobProps_borderRadiusNested : { borderRadius: "4" },
|
|
14
|
-
backgroundColor: markdownCodeColors.background.base,
|
|
15
|
-
borderWidth: knobProps.borderRadius.borderWidth,
|
|
16
|
-
borderColor: edgeColorAt(markdownCodeColors.border.base, knobProps.borderWidthStop),
|
|
17
|
-
...knobProps.panelPadding,
|
|
18
8
|
marginVertical: "2",
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
children: /* @__PURE__ */ jsx(Code, {
|
|
24
|
-
backgroundColor: "transparent",
|
|
25
|
-
borderWidth: 0,
|
|
26
|
-
padding: 0,
|
|
27
|
-
color: markdownCodeColors.text.base,
|
|
28
|
-
fontSize: knobProps.sizeToken,
|
|
29
|
-
children: /* @__PURE__ */ jsx(HighlightedCode, {
|
|
30
|
-
tokens,
|
|
31
|
-
fontSize: knobProps.sizeToken,
|
|
32
|
-
children
|
|
33
|
-
})
|
|
34
|
-
})
|
|
9
|
+
children: /* @__PURE__ */ jsx(CodeBlock$1, {
|
|
10
|
+
language: lang || "text",
|
|
11
|
+
theme: themeProp === "auto" ? void 0 : themeProp,
|
|
12
|
+
children
|
|
35
13
|
})
|
|
36
14
|
});
|
|
37
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.native.js","names":[],"sources":["esm/components/CodeBlock.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport {
|
|
1
|
+
{"version":3,"file":"CodeBlock.native.js","names":["HouseCodeBlock"],"sources":["esm/components/CodeBlock.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { CodeBlock as HouseCodeBlock } from \"@multiplatform.one/components\";\nimport { View } from \"tamagui\";\nfunction CodeBlock(param) {\n var { children, lang, theme: themeProp = \"auto\" } = param;\n return /* @__PURE__ */ _jsx(View, {\n marginVertical: \"2\",\n children: /* @__PURE__ */ _jsx(HouseCodeBlock, {\n language: lang || \"text\",\n theme: themeProp === \"auto\" ? void 0 : themeProp,\n children\n })\n });\n}\nexport {\n CodeBlock\n};\n//# sourceMappingURL=CodeBlock.js.map\n"],"mappings":";;;;;AAGA,SAAS,UAAU,OAAO;CACxB,IAAI,EAAE,UAAU,MAAM,OAAO,YAAY,WAAW;CACpD,OAAuB,oBAAK,MAAM;EAChC,gBAAgB;EAChB,UAA0B,oBAAKA,aAAgB;GAC7C,UAAU,QAAQ;GAClB,OAAO,cAAc,SAAS,KAAK,IAAI;GACvC;EACF,CAAC;CACH,CAAC;AACH"}
|