@multiplatform.one/markdown 11.12.2 → 11.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/cjs/MdxCodeBlock/index.cjs +20 -98
  2. package/dist/cjs/MdxCodeBlock/index.native.cjs +23 -104
  3. package/dist/cjs/MdxCodeBlock/index.native.js +23 -104
  4. package/dist/cjs/MdxCodeBlock/index.native.js.map +1 -1
  5. package/dist/cjs/components/CodeBlock.cjs +4 -25
  6. package/dist/cjs/components/CodeBlock.native.cjs +4 -26
  7. package/dist/cjs/components/CodeBlock.native.js +4 -26
  8. package/dist/cjs/components/CodeBlock.native.js.map +1 -1
  9. package/dist/esm/MdxCodeBlock/index.mjs +23 -101
  10. package/dist/esm/MdxCodeBlock/index.mjs.map +1 -1
  11. package/dist/esm/MdxCodeBlock/index.native.js +26 -107
  12. package/dist/esm/MdxCodeBlock/index.native.js.map +1 -1
  13. package/dist/esm/components/CodeBlock.mjs +5 -26
  14. package/dist/esm/components/CodeBlock.mjs.map +1 -1
  15. package/dist/esm/components/CodeBlock.native.js +5 -27
  16. package/dist/esm/components/CodeBlock.native.js.map +1 -1
  17. package/dist/jsx/MdxCodeBlock/index.mjs +23 -101
  18. package/dist/jsx/MdxCodeBlock/index.mjs.map +1 -1
  19. package/dist/jsx/MdxCodeBlock/index.native.cjs +23 -104
  20. package/dist/jsx/MdxCodeBlock/index.native.js +23 -104
  21. package/dist/jsx/MdxCodeBlock/index.native.js.map +1 -1
  22. package/dist/jsx/components/CodeBlock.mjs +5 -26
  23. package/dist/jsx/components/CodeBlock.mjs.map +1 -1
  24. package/dist/jsx/components/CodeBlock.native.cjs +4 -26
  25. package/dist/jsx/components/CodeBlock.native.js +4 -26
  26. package/dist/jsx/components/CodeBlock.native.js.map +1 -1
  27. package/package.json +10 -10
  28. package/src/MdxCodeBlock/index.tsx +33 -127
  29. package/src/MdxCodeBlock/mdxCodeBlock.spec.tsx +50 -49
  30. package/src/components/CodeBlock.tsx +12 -46
  31. package/src/stories/Code.stories.tsx +2 -1
  32. package/types/MdxCodeBlock/index.d.ts +6 -0
  33. package/types/MdxCodeBlock/index.d.ts.map +1 -1
  34. package/types/components/CodeBlock.d.ts +4 -6
  35. package/types/components/CodeBlock.d.ts.map +1 -1
@@ -1,16 +1,10 @@
1
- import { Button, Code, ErrorBoundary, HighlightedCode, Pre, ScrollView, useClipboard, useShikiTokens } from "@multiplatform.one/components";
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 { TooltipSimple, XStack, YStack } from "tamagui";
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 { Fragment, jsx, jsxs } from "react/jsx-runtime";
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: propShowLineNumbers, size, line, ...codeProps } = {
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
- return /* @__PURE__ */ jsx(YStack, {
51
- position: "relative",
33
+ const shown = !isCollapsed || !isCollapsible;
34
+ return /* @__PURE__ */ jsxs(YStack, {
52
35
  marginBottom: "4",
53
- children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxs(YStack, {
54
- position: "relative",
55
- ...isCutoff && {
56
- maxHeight: cutoffMaxHeight,
57
- overflow: "hidden",
58
- ...knobProps.borderRadiusNested
59
- },
60
- children: [
61
- (!isCollapsed || !isCollapsible) && isCutoff && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(LinearGradient, {
62
- position: "absolute",
63
- bottom: 0,
64
- left: 0,
65
- right: 0,
66
- height: gradientHeight,
67
- colors: gradientColors,
68
- pointerEvents: "none",
69
- zIndex: zIndex.localTop
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":["jsx/MdxCodeBlock/index.js"],"sourcesContent":["import {\n Button,\n Code,\n ErrorBoundary,\n HighlightedCode,\n Pre,\n useClipboard,\n useShikiTokens,\n ScrollView\n} 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\";\nimport { Fragment, jsx, jsxs } from \"react/jsx-runtime\";\nconst zIndex = { localTop: 100 };\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: propShowLineNumbers,\n size,\n line,\n ...codeProps\n } = { ...useContext(MDXCodeBlockContext), ...props };\n const { knobProps } = useResolvedKnobs();\n const gradientColors = useCutoffGradientColors();\n const cutoffMaxHeight = tokenPx(knobProps.sizeToken, 24) * 16;\n const gradientHeight = tokenPx(knobProps.sizeToken, 24) * 8;\n const iconPx = tokenPx(knobProps.label.fontSize, 14, \"fontSize\");\n const codeText = useMemo(() => extractCodeText(children).replace(/\\n$/, \"\"), [children]);\n const language = useMemo(() => extractLanguage(className), [className]);\n const tokens = useShikiTokens(codeText, language);\n const lines = tokens?.length ?? codeText.split(\"\\n\").length;\n const showLineNumbers = propShowLineNumbers ?? lines > 10;\n const [isCollapsed, setIsCollapsed] = useState(isCollapsible);\n const isLong = lines > 22;\n const [isCutoff, setIsCutoff] = useState(isLong && !isCollapsible);\n const { hasCopied, onCopy } = useClipboard(codeText);\n const highlightLines = useMemo(() => {\n if (!isHighlightingLines || !line) return [];\n return rangeParser(line);\n }, [isHighlightingLines, line]);\n return /* @__PURE__ */ jsx(YStack, { position: \"relative\", marginBottom: \"4\", children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxs(\n YStack,\n {\n position: \"relative\",\n ...isCutoff && {\n maxHeight: cutoffMaxHeight,\n overflow: \"hidden\",\n ...knobProps.borderRadiusNested\n },\n children: [\n (!isCollapsed || !isCollapsible) && isCutoff && /* @__PURE__ */ jsxs(Fragment, { children: [\n /* @__PURE__ */ jsx(\n LinearGradient,\n {\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 ),\n /* @__PURE__ */ jsx(\n XStack,\n {\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, { onPress: () => setIsCutoff(false), children: \"Show more\" })\n }\n )\n ] }),\n (!isCollapsed || !isCollapsible) && /* @__PURE__ */ jsx(\n Pre,\n {\n padding: 0,\n marginBottom: 0,\n id,\n \"data-line-numbers\": showLineNumbers ? \"true\" : \"false\",\n children: /* @__PURE__ */ jsx(\n ScrollView,\n {\n style: { width: \"100%\" },\n contentContainerStyle: { minWidth: \"100%\" },\n horizontal: true,\n showsHorizontalScrollIndicator: false,\n children: /* @__PURE__ */ jsx(\n Code,\n {\n backgroundColor: \"transparent\",\n flex: 1,\n borderWidth: 0,\n ...knobProps.panelPadding,\n size: size ?? knobProps.sizeToken,\n ...codeProps,\n children: /* @__PURE__ */ jsx(\n HighlightedCode,\n {\n tokens,\n highlightLines,\n showLineNumbers,\n children: codeText\n }\n )\n }\n )\n }\n )\n }\n ),\n /* @__PURE__ */ jsxs(XStack, { position: \"absolute\", top: \"3\", insetInlineEnd: \"3\", ...knobProps.gap, children: [\n (!isCollapsed || !isCollapsible) && (copyable ?? true) && /* @__PURE__ */ jsx(TooltipSimple, { label: hasCopied ? \"Copied\" : \"Copy to clipboard\", children: /* @__PURE__ */ jsx(\n Button,\n {\n \"aria-label\": \"Copy code to clipboard\",\n size: \"2\",\n display: \"max-xs:none\",\n icon: hasCopied ? /* @__PURE__ */ jsx(CheckCircleIcon, { size: iconPx }) : /* @__PURE__ */ jsx(ClipboardIcon, { size: iconPx }),\n onPress: onCopy\n }\n ) }),\n isCollapsible && /* @__PURE__ */ jsx(\n Button,\n {\n \"aria-label\": \"Show or hide code\",\n size: \"2\",\n onPress: () => setIsCollapsed((x) => !x),\n children: isCollapsed ? \"Show code\" : \"Hide code\"\n }\n )\n ] })\n ]\n }\n ) }) });\n}\nexport {\n MDXCodeBlock\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAM,SAAS,EAAE,UAAU,IAAI;AAC/B,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,OAAO,gBAAgB,SAAS,OAAO,QAAQ;CACjD;CACA,OAAO,OAAO,YAAY,EAAE;AAC9B;AACA,SAAS,gBAAg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H,iBAAiC,oBAC/B,QACA;MACE,cAAc;MACd,MAAM;MACN,eAAe,gBAAgB,MAAM,CAAC,CAAC;MACvC,UAAU,cAAc,cAAc;KACxC,CACF,CACF;IAAE,CAAC;GACL;EACF,CACF,EAAE,CAAC;CAAE,CAAC;AACR"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["jsx/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 {\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,OAAO,gBAAgB,SAAS,OAAO,QAAQ;CACjD;CACA,OAAO,OAAO,YAAY,EAAE;AAC9B;AACA,SAAS,gBAAgB,WAAW;CAClC,IAAI,CAAC,WAAW,OAAO;CACvB,MAAM,QAAQ,UAAU,MAAM,gBAAgB;CAC9C,OAAO,QAAQ,MAAM;AACvB;AACA,SAAS,aAAa,OAAO;CAC3B,MAAM,EACJ,UACA,WACA,UACA,IACA,eACA,qBACA,iBACA,MACA,SACE;EAAE,GAAG,WAAW,mBAAmB;EAAG,GAAG;CAAM;CACnD,MAAM,WAAW,cAAc,gBAAgB,QAAQ,CAAC,CAAC,QAAQ,OAAO,EAAE,GAAG,CAAC,QAAQ,CAAC;CACvF,MAAM,WAAW,cAAc,gBAAgB,SAAS,GAAG,CAAC,SAAS,CAAC;CACtE,MAAM,CAAC,aAAa,kBAAkB,SAAS,aAAa;CAC5D,MAAM,iBAAiB,cAAc;EACnC,IAAI,CAAC,uBAAuB,CAAC,MAAM,OAAO,CAAC;EAC3C,OAAO,YAAY,IAAI;CACzB,GAAG,CAAC,qBAAqB,IAAI,CAAC;CAC9B,MAAM,QAAQ,CAAC,eAAe,CAAC;CAC/B,OAAuB,qBAAK,QAAQ;EAAE,cAAc;EAAK,KAAK;EAAK;EAAI,uBAAuB;EAAI,UAAU,CAC1G,gBAAgC,oBAAI,QAAQ,EAAE,UAA0B,oBACtE,QACA;GACE,cAAc;GACd,iBAAiB;GACjB,MAAM;GACN,eAAe,gBAAgB,MAAM,CAAC,CAAC;GACvC,UAAU,QAAQ,cAAc;EAClC,CACF,EAAE,CAAC,IAAI,MACP,QAAwB,oBACtB,WACA;GACE;GACA;GACA;GACA;GACA;GACA,UAAU;EACZ,CACF,IAAI,IACN;CAAE,CAAC;AACL"}
@@ -31,16 +31,10 @@ __export(MdxCodeBlock_exports, { MDXCodeBlock: () => MDXCodeBlock });
31
31
  module.exports = __toCommonJS(MdxCodeBlock_exports);
32
32
  var import_jsx_runtime = require("react/jsx-runtime");
33
33
  var import_components = require("@multiplatform.one/components");
34
- var import_theme = require("@multiplatform.one/theme");
35
- var import_linear_gradient = require("@tamagui/linear-gradient");
36
34
  var import_parse_numeric_range = __toESM(require("parse-numeric-range"));
37
35
  var import_react = require("react");
38
36
  var import_tamagui = require("tamagui");
39
- var import_icons = require("../icons/index.native.js");
40
- var import_cutoffGradient = require("../shared/cutoffGradient.native.js");
41
- var import_tokenPx = require("../shared/tokenPx.native.js");
42
37
  var import_mdxCodeBlockContext = require("./mdxCodeBlockContext.native.js");
43
- var zIndex = { localTop: 100 };
44
38
  function extractCodeText(children) {
45
39
  if (typeof children === "string") return children;
46
40
  if (Array.isArray(children)) return children.map(extractCodeText).join("");
@@ -56,119 +50,44 @@ function extractLanguage(className) {
56
50
  return (match === null || match === void 0 ? void 0 : match[1]) || "text";
57
51
  }
58
52
  function MDXCodeBlock(props) {
59
- var _ref;
60
- var { children, className, copyable, id, isCollapsible, isHighlightingLines, showLineNumbers: propShowLineNumbers, size, line, ...codeProps } = {
53
+ var { children, className, copyable, id, isCollapsible, isHighlightingLines, showLineNumbers, size, line } = {
61
54
  ...(0, import_react.useContext)(import_mdxCodeBlockContext.MDXCodeBlockContext),
62
55
  ...props
63
56
  };
64
- var { knobProps } = (0, import_theme.useResolvedKnobs)();
65
- var gradientColors = (0, import_cutoffGradient.useCutoffGradientColors)();
66
- var cutoffMaxHeight = (0, import_tokenPx.tokenPx)(knobProps.sizeToken, 24) * 16;
67
- var gradientHeight = (0, import_tokenPx.tokenPx)(knobProps.sizeToken, 24) * 8;
68
- var iconPx = (0, import_tokenPx.tokenPx)(knobProps.label.fontSize, 14, "fontSize");
69
57
  var codeText = (0, import_react.useMemo)(function() {
70
58
  return extractCodeText(children).replace(/\n$/, "");
71
59
  }, [children]);
72
60
  var language = (0, import_react.useMemo)(function() {
73
61
  return extractLanguage(className);
74
62
  }, [className]);
75
- var tokens = (0, import_components.useShikiTokens)(codeText, language);
76
- var lines = (_ref = tokens === null || tokens === void 0 ? void 0 : tokens.length) !== null && _ref !== void 0 ? _ref : codeText.split("\n").length;
77
- var showLineNumbers = propShowLineNumbers !== null && propShowLineNumbers !== void 0 ? propShowLineNumbers : lines > 10;
78
63
  var [isCollapsed, setIsCollapsed] = (0, import_react.useState)(isCollapsible);
79
- var isLong = lines > 22;
80
- var [isCutoff, setIsCutoff] = (0, import_react.useState)(isLong && !isCollapsible);
81
- var { hasCopied, onCopy } = (0, import_components.useClipboard)(codeText);
82
64
  var highlightLines = (0, import_react.useMemo)(function() {
83
65
  if (!isHighlightingLines || !line) return [];
84
66
  return (0, import_parse_numeric_range.default)(line);
85
67
  }, [isHighlightingLines, line]);
86
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
87
- position: "relative",
68
+ var shown = !isCollapsed || !isCollapsible;
69
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.YStack, {
88
70
  marginBottom: "4",
89
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.YStack, {
90
- position: "relative",
91
- ...isCutoff && {
92
- maxHeight: cutoffMaxHeight,
93
- overflow: "hidden",
94
- ...knobProps.borderRadiusNested
71
+ gap: "2",
72
+ id,
73
+ "data-mdx-code-block": "",
74
+ children: [isCollapsible ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.XStack, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Button, {
75
+ "aria-label": "Show or hide code",
76
+ "aria-expanded": shown,
77
+ size: "2",
78
+ onPress: function onPress() {
79
+ return setIsCollapsed(function(x) {
80
+ return !x;
81
+ });
95
82
  },
96
- children: [
97
- (!isCollapsed || !isCollapsible) && isCutoff && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_linear_gradient.LinearGradient, {
98
- position: "absolute",
99
- bottom: 0,
100
- left: 0,
101
- right: 0,
102
- height: gradientHeight,
103
- colors: gradientColors,
104
- pointerEvents: "none",
105
- zIndex: zIndex.localTop
106
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.XStack, {
107
- position: "absolute",
108
- bottom: "4",
109
- left: 0,
110
- right: 0,
111
- justifyContent: "center",
112
- zIndex: zIndex.localTop + 1,
113
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Button, {
114
- onPress: function onPress() {
115
- return setIsCutoff(false);
116
- },
117
- children: "Show more"
118
- })
119
- })] }),
120
- (!isCollapsed || !isCollapsible) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Pre, {
121
- padding: 0,
122
- marginBottom: 0,
123
- id,
124
- "data-line-numbers": showLineNumbers ? "true" : "false",
125
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ScrollView, {
126
- style: { width: "100%" },
127
- contentContainerStyle: { minWidth: "100%" },
128
- horizontal: true,
129
- showsHorizontalScrollIndicator: false,
130
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Code, {
131
- backgroundColor: "transparent",
132
- flex: 1,
133
- borderWidth: 0,
134
- ...knobProps.panelPadding,
135
- size: size !== null && size !== void 0 ? size : knobProps.sizeToken,
136
- ...codeProps,
137
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.HighlightedCode, {
138
- tokens,
139
- highlightLines,
140
- showLineNumbers,
141
- children: codeText
142
- })
143
- })
144
- })
145
- }),
146
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
147
- position: "absolute",
148
- top: "3",
149
- insetInlineEnd: "3",
150
- ...knobProps.gap,
151
- children: [(!isCollapsed || !isCollapsible) && (copyable !== null && copyable !== void 0 ? copyable : true) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.TooltipSimple, {
152
- label: hasCopied ? "Copied" : "Copy to clipboard",
153
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Button, {
154
- "aria-label": "Copy code to clipboard",
155
- size: "2",
156
- display: "max-xs:none",
157
- icon: hasCopied ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CheckCircleIcon, { size: iconPx }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ClipboardIcon, { size: iconPx }),
158
- onPress: onCopy
159
- })
160
- }), isCollapsible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Button, {
161
- "aria-label": "Show or hide code",
162
- size: "2",
163
- onPress: function onPress() {
164
- return setIsCollapsed(function(x) {
165
- return !x;
166
- });
167
- },
168
- children: isCollapsed ? "Show code" : "Hide code"
169
- })]
170
- })
171
- ]
172
- }) })
83
+ children: shown ? "Hide code" : "Show code"
84
+ }) }) : null, shown ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.CodeBlock, {
85
+ language,
86
+ copyable,
87
+ showLineNumbers,
88
+ highlightLines,
89
+ size,
90
+ children: codeText
91
+ }) : null]
173
92
  });
174
93
  }
@@ -31,16 +31,10 @@ __export(MdxCodeBlock_exports, { MDXCodeBlock: () => MDXCodeBlock });
31
31
  module.exports = __toCommonJS(MdxCodeBlock_exports);
32
32
  var import_jsx_runtime = require("react/jsx-runtime");
33
33
  var import_components = require("@multiplatform.one/components");
34
- var import_theme = require("@multiplatform.one/theme");
35
- var import_linear_gradient = require("@tamagui/linear-gradient");
36
34
  var import_parse_numeric_range = __toESM(require("parse-numeric-range"));
37
35
  var import_react = require("react");
38
36
  var import_tamagui = require("tamagui");
39
- var import_icons = require("../icons/index.native.js");
40
- var import_cutoffGradient = require("../shared/cutoffGradient.native.js");
41
- var import_tokenPx = require("../shared/tokenPx.native.js");
42
37
  var import_mdxCodeBlockContext = require("./mdxCodeBlockContext.native.js");
43
- var zIndex = { localTop: 100 };
44
38
  function extractCodeText(children) {
45
39
  if (typeof children === "string") return children;
46
40
  if (Array.isArray(children)) return children.map(extractCodeText).join("");
@@ -56,120 +50,45 @@ function extractLanguage(className) {
56
50
  return (match === null || match === void 0 ? void 0 : match[1]) || "text";
57
51
  }
58
52
  function MDXCodeBlock(props) {
59
- var _ref;
60
- var { children, className, copyable, id, isCollapsible, isHighlightingLines, showLineNumbers: propShowLineNumbers, size, line, ...codeProps } = {
53
+ var { children, className, copyable, id, isCollapsible, isHighlightingLines, showLineNumbers, size, line } = {
61
54
  ...(0, import_react.useContext)(import_mdxCodeBlockContext.MDXCodeBlockContext),
62
55
  ...props
63
56
  };
64
- var { knobProps } = (0, import_theme.useResolvedKnobs)();
65
- var gradientColors = (0, import_cutoffGradient.useCutoffGradientColors)();
66
- var cutoffMaxHeight = (0, import_tokenPx.tokenPx)(knobProps.sizeToken, 24) * 16;
67
- var gradientHeight = (0, import_tokenPx.tokenPx)(knobProps.sizeToken, 24) * 8;
68
- var iconPx = (0, import_tokenPx.tokenPx)(knobProps.label.fontSize, 14, "fontSize");
69
57
  var codeText = (0, import_react.useMemo)(function() {
70
58
  return extractCodeText(children).replace(/\n$/, "");
71
59
  }, [children]);
72
60
  var language = (0, import_react.useMemo)(function() {
73
61
  return extractLanguage(className);
74
62
  }, [className]);
75
- var tokens = (0, import_components.useShikiTokens)(codeText, language);
76
- var lines = (_ref = tokens === null || tokens === void 0 ? void 0 : tokens.length) !== null && _ref !== void 0 ? _ref : codeText.split("\n").length;
77
- var showLineNumbers = propShowLineNumbers !== null && propShowLineNumbers !== void 0 ? propShowLineNumbers : lines > 10;
78
63
  var [isCollapsed, setIsCollapsed] = (0, import_react.useState)(isCollapsible);
79
- var isLong = lines > 22;
80
- var [isCutoff, setIsCutoff] = (0, import_react.useState)(isLong && !isCollapsible);
81
- var { hasCopied, onCopy } = (0, import_components.useClipboard)(codeText);
82
64
  var highlightLines = (0, import_react.useMemo)(function() {
83
65
  if (!isHighlightingLines || !line) return [];
84
66
  return (0, import_parse_numeric_range.default)(line);
85
67
  }, [isHighlightingLines, line]);
86
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
87
- position: "relative",
68
+ var shown = !isCollapsed || !isCollapsible;
69
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.YStack, {
88
70
  marginBottom: "4",
89
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.YStack, {
90
- position: "relative",
91
- ...isCutoff && {
92
- maxHeight: cutoffMaxHeight,
93
- overflow: "hidden",
94
- ...knobProps.borderRadiusNested
71
+ gap: "2",
72
+ id,
73
+ "data-mdx-code-block": "",
74
+ children: [isCollapsible ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.XStack, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Button, {
75
+ "aria-label": "Show or hide code",
76
+ "aria-expanded": shown,
77
+ size: "2",
78
+ onPress: function onPress() {
79
+ return setIsCollapsed(function(x) {
80
+ return !x;
81
+ });
95
82
  },
96
- children: [
97
- (!isCollapsed || !isCollapsible) && isCutoff && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_linear_gradient.LinearGradient, {
98
- position: "absolute",
99
- bottom: 0,
100
- left: 0,
101
- right: 0,
102
- height: gradientHeight,
103
- colors: gradientColors,
104
- pointerEvents: "none",
105
- zIndex: zIndex.localTop
106
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.XStack, {
107
- position: "absolute",
108
- bottom: "4",
109
- left: 0,
110
- right: 0,
111
- justifyContent: "center",
112
- zIndex: zIndex.localTop + 1,
113
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Button, {
114
- onPress: function onPress() {
115
- return setIsCutoff(false);
116
- },
117
- children: "Show more"
118
- })
119
- })] }),
120
- (!isCollapsed || !isCollapsible) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Pre, {
121
- padding: 0,
122
- marginBottom: 0,
123
- id,
124
- "data-line-numbers": showLineNumbers ? "true" : "false",
125
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ScrollView, {
126
- style: { width: "100%" },
127
- contentContainerStyle: { minWidth: "100%" },
128
- horizontal: true,
129
- showsHorizontalScrollIndicator: false,
130
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Code, {
131
- backgroundColor: "transparent",
132
- flex: 1,
133
- borderWidth: 0,
134
- ...knobProps.panelPadding,
135
- size: size !== null && size !== void 0 ? size : knobProps.sizeToken,
136
- ...codeProps,
137
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.HighlightedCode, {
138
- tokens,
139
- highlightLines,
140
- showLineNumbers,
141
- children: codeText
142
- })
143
- })
144
- })
145
- }),
146
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
147
- position: "absolute",
148
- top: "3",
149
- insetInlineEnd: "3",
150
- ...knobProps.gap,
151
- children: [(!isCollapsed || !isCollapsible) && (copyable !== null && copyable !== void 0 ? copyable : true) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.TooltipSimple, {
152
- label: hasCopied ? "Copied" : "Copy to clipboard",
153
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Button, {
154
- "aria-label": "Copy code to clipboard",
155
- size: "2",
156
- display: "max-xs:none",
157
- icon: hasCopied ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CheckCircleIcon, { size: iconPx }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ClipboardIcon, { size: iconPx }),
158
- onPress: onCopy
159
- })
160
- }), isCollapsible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Button, {
161
- "aria-label": "Show or hide code",
162
- size: "2",
163
- onPress: function onPress() {
164
- return setIsCollapsed(function(x) {
165
- return !x;
166
- });
167
- },
168
- children: isCollapsed ? "Show code" : "Hide code"
169
- })]
170
- })
171
- ]
172
- }) })
83
+ children: shown ? "Hide code" : "Show code"
84
+ }) }) : null, shown ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.CodeBlock, {
85
+ language,
86
+ copyable,
87
+ showLineNumbers,
88
+ highlightLines,
89
+ size,
90
+ children: codeText
91
+ }) : null]
173
92
  });
174
93
  }
175
94
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.native.js","names":[],"sources":["jsx/MdxCodeBlock/index.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar MdxCodeBlock_exports = {};\n__export(MdxCodeBlock_exports, {\n MDXCodeBlock: () => MDXCodeBlock\n});\nmodule.exports = __toCommonJS(MdxCodeBlock_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_components = require(\"@multiplatform.one/components\");\nvar import_theme = require(\"@multiplatform.one/theme\");\nvar import_linear_gradient = require(\"@tamagui/linear-gradient\");\nvar import_parse_numeric_range = __toESM(require(\"parse-numeric-range\"));\nvar import_react = require(\"react\");\nvar import_tamagui = require(\"tamagui\");\nvar import_icons = require(\"../icons\");\nvar import_cutoffGradient = require(\"../shared/cutoffGradient\");\nvar import_tokenPx = require(\"../shared/tokenPx\");\nvar import_mdxCodeBlockContext = require(\"./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 ...(0, import_react.useContext)(import_mdxCodeBlockContext.MDXCodeBlockContext),\n ...props\n };\n var { knobProps } = (0, import_theme.useResolvedKnobs)();\n var gradientColors = (0, import_cutoffGradient.useCutoffGradientColors)();\n var cutoffMaxHeight = (0, import_tokenPx.tokenPx)(knobProps.sizeToken, 24) * 16;\n var gradientHeight = (0, import_tokenPx.tokenPx)(knobProps.sizeToken, 24) * 8;\n var iconPx = (0, import_tokenPx.tokenPx)(knobProps.label.fontSize, 14, \"fontSize\");\n var codeText = (0, import_react.useMemo)(function() {\n return extractCodeText(children).replace(/\\n$/, \"\");\n }, [\n children\n ]);\n var language = (0, import_react.useMemo)(function() {\n return extractLanguage(className);\n }, [\n className\n ]);\n var tokens = (0, import_components.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] = (0, import_react.useState)(isCollapsible);\n var isLong = lines > 22;\n var [isCutoff, setIsCutoff] = (0, import_react.useState)(isLong && !isCollapsible);\n var { hasCopied, onCopy } = (0, import_components.useClipboard)(codeText);\n var highlightLines = (0, import_react.useMemo)(function() {\n if (!isHighlightingLines || !line) return [];\n return (0, import_parse_numeric_range.default)(line);\n }, [\n isHighlightingLines,\n line\n ]);\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.YStack, {\n position: \"relative\",\n marginBottom: \"4\",\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ErrorBoundary, {\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.YStack, {\n position: \"relative\",\n ...isCutoff && {\n maxHeight: cutoffMaxHeight,\n overflow: \"hidden\",\n ...knobProps.borderRadiusNested\n },\n children: [\n (!isCollapsed || !isCollapsible) && isCutoff && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {\n children: [\n /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_linear_gradient.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__ */ (0, import_jsx_runtime.jsx)(import_tamagui.XStack, {\n position: \"absolute\",\n bottom: \"4\",\n left: 0,\n right: 0,\n justifyContent: \"center\",\n zIndex: zIndex.localTop + 1,\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Button, {\n onPress: function onPress() {\n return setIsCutoff(false);\n },\n children: \"Show more\"\n })\n })\n ]\n }),\n (!isCollapsed || !isCollapsible) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Pre, {\n padding: 0,\n marginBottom: 0,\n id,\n \"data-line-numbers\": showLineNumbers ? \"true\" : \"false\",\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ScrollView, {\n style: {\n width: \"100%\"\n },\n contentContainerStyle: {\n minWidth: \"100%\"\n },\n horizontal: true,\n showsHorizontalScrollIndicator: false,\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.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__ */ (0, import_jsx_runtime.jsx)(import_components.HighlightedCode, {\n tokens,\n highlightLines,\n showLineNumbers,\n children: codeText\n })\n })\n })\n }),\n /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.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__ */ (0, import_jsx_runtime.jsx)(import_tamagui.TooltipSimple, {\n label: hasCopied ? \"Copied\" : \"Copy to clipboard\",\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Button, {\n \"aria-label\": \"Copy code to clipboard\",\n size: \"2\",\n display: \"max-xs:none\",\n icon: hasCopied ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CheckCircleIcon, {\n size: iconPx\n }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ClipboardIcon, {\n size: iconPx\n }),\n onPress: onCopy\n })\n }),\n isCollapsible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.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}\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,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,WAA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,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":["jsx/MdxCodeBlock/index.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar MdxCodeBlock_exports = {};\n__export(MdxCodeBlock_exports, {\n MDXCodeBlock: () => MDXCodeBlock\n});\nmodule.exports = __toCommonJS(MdxCodeBlock_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_components = require(\"@multiplatform.one/components\");\nvar import_parse_numeric_range = __toESM(require(\"parse-numeric-range\"));\nvar import_react = require(\"react\");\nvar import_tamagui = require(\"tamagui\");\nvar import_mdxCodeBlockContext = require(\"./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 ...(0, import_react.useContext)(import_mdxCodeBlockContext.MDXCodeBlockContext),\n ...props\n };\n var codeText = (0, import_react.useMemo)(function() {\n return extractCodeText(children).replace(/\\n$/, \"\");\n }, [\n children\n ]);\n var language = (0, import_react.useMemo)(function() {\n return extractLanguage(className);\n }, [\n className\n ]);\n var [isCollapsed, setIsCollapsed] = (0, import_react.useState)(isCollapsible);\n var highlightLines = (0, import_react.useMemo)(function() {\n if (!isHighlightingLines || !line) return [];\n return (0, import_parse_numeric_range.default)(line);\n }, [\n isHighlightingLines,\n line\n ]);\n var shown = !isCollapsed || !isCollapsible;\n return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tamagui.YStack, {\n marginBottom: \"4\",\n gap: \"2\",\n id,\n \"data-mdx-code-block\": \"\",\n children: [\n isCollapsible ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tamagui.XStack, {\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.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__ */ (0, import_jsx_runtime.jsx)(import_components.CodeBlock, {\n language,\n copyable,\n showLineNumbers,\n highlightLines,\n size,\n children: codeText\n }) : null\n ]\n });\n}\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,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,WAAW,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAC,GAAG,YAKnG,cAAc,CAAC,OAAO,CAAC,IAAI,aAAa,UAAU,QAAQ,WAAW;CAAE,OAAO;CAAK,YAAY;AAAK,CAAC,IAAI,QACzG,GACF;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,uBAAuB,CAAC;AAC5B,SAAS,sBAAsB,EAC7B,oBAAoB,aACtB,CAAC;AACD,OAAO,UAAU,aAAa,oBAAoB;AAClD,IAAI,qBAAqB,QAAQ,mBAAmB;AACpD,IAAI,oBAAoB,QAAQ,+BAA+B;AAC/D,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,uBAAuB,CAAC,MAAM,OAAO,CAAC;EAC3C,QAAQ,GAAG,2BAA2B,QAAO,CAAE,IAAI;CACrD,GAAG,CACD,qBACA,IACF,CAAC;CACD,IAAI,QAAQ,CAAC,eAAe,CAAC;CAC7B,OAAuB,iBAAC,GAAG,mBAAmB,KAAI,CAAE,eAAe,QAAQ;EACzE,cAAc;EACd,KAAK;EACL;EACA,uBAAuB;EACvB,UAAU,CACR,gBAAgC,iBAAC,GAAG,mBAAmB,IAAG,CAAE,eAAe,QAAQ,EACjF,UAA0B,iBAAC,GAAG,mBAAmB,IAAG,CAAE,kBAAkB,QAAQ;GAC9E,cAAc;GACd,iBAAiB;GACjB,MAAM;GACN,SAAS,SAAS,UAAU;IAC1B,OAAO,eAAe,SAAS,GAAG;KAChC,OAAO,CAAC;IACV,CAAC;GACH;GACA,UAAU,QAAQ,cAAc;EAClC,CAAC,EACH,CAAC,IAAI,MACL,QAAwB,iBAAC,GAAG,mBAAmB,IAAG,CAAE,kBAAkB,WAAW;GAC/E;GACA;GACA;GACA;GACA;GACA,UAAU;EACZ,CAAC,IAAI,IACP;CACF,CAAC;AACH"}
@@ -1,35 +1,14 @@
1
- import { Code, HighlightedCode, ScrollView, useShikiTokens } from "@multiplatform.one/components";
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
- overflow: "hidden",
18
- children: /* @__PURE__ */ jsx(ScrollView, {
19
- horizontal: true,
20
- showsHorizontalScrollIndicator: false,
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":["jsx/components/CodeBlock.js"],"sourcesContent":["import { Code, HighlightedCode, useShikiTokens, ScrollView } from \"@multiplatform.one/components\";\nimport { edgeColorAt, useResolvedKnobs } from \"@multiplatform.one/theme\";\nimport { View } from \"tamagui\";\nimport { markdownCodeColors } from \"../shared/colorRamps\";\nimport { jsx } from \"react/jsx-runtime\";\nfunction CodeBlock({ children, lang, theme: themeProp = \"auto\" }) {\n const { knobProps } = useResolvedKnobs();\n const tokens = useShikiTokens(\n children,\n lang || \"text\",\n themeProp === \"auto\" ? void 0 : themeProp\n );\n return /* @__PURE__ */ jsx(\n View,\n {\n ...knobProps.borderRadiusNested ?? { borderRadius: \"4\" },\n backgroundColor: markdownCodeColors.background.base,\n borderWidth: knobProps.borderRadius.borderWidth,\n borderColor: edgeColorAt(markdownCodeColors.border.base, knobProps.borderWidthStop),\n ...knobProps.panelPadding,\n marginVertical: \"2\",\n overflow: \"hidden\",\n children: /* @__PURE__ */ jsx(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, children: /* @__PURE__ */ jsx(\n Code,\n {\n backgroundColor: \"transparent\",\n borderWidth: 0,\n padding: 0,\n color: markdownCodeColors.text.base,\n fontSize: knobProps.sizeToken,\n children: /* @__PURE__ */ jsx(HighlightedCode, { tokens, fontSize: knobProps.sizeToken, children })\n }\n ) })\n }\n );\n}\nexport {\n CodeBlock\n};\n//# sourceMappingURL=CodeBlock.js.map\n"],"mappings":";;;;;;;AAKA,SAAS,UAAU,EAAE,UAAU,MAAM,OAAO,YAAY,UAAU;CAChE,MAAM,EAAE,cAAc,iBAAiB;CACvC,MAAM,SAAS,eACb,UACA,QAAQ,QACR,cAAc,SAAS,KAAK,IAAI,SAClC;CACA,OAAuB,oBACrB,MACA;EACE,GAAG,UAAU,sBAAsB,EAAE,cAAc,IAAI;EACvD,iBAAiB,mBAAmB,WAAW;EAC/C,aAAa,UAAU,aAAa;EACpC,aAAa,YAAY,mBAAmB,OAAO,MAAM,UAAU,eAAe;EAClF,GAAG,UAAU;EACb,gBAAgB;EAChB,UAAU;EACV,UAA0B,oBAAI,YAAY;GAAE,YAAY;GAAM,gCAAgC;GAAO,UAA0B,oBAC7H,MACA;IACE,iBAAiB;IACjB,aAAa;IACb,SAAS;IACT,OAAO,mBAAmB,KAAK;IAC/B,UAAU,UAAU;IACpB,UAA0B,oBAAI,iBAAiB;KAAE;KAAQ,UAAU,UAAU;KAAW;IAAS,CAAC;GACpG,CACF;EAAE,CAAC;CACL,CACF;AACF"}
1
+ {"version":3,"file":"CodeBlock.js","names":["HouseCodeBlock"],"sources":["jsx/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"}