@traefik-labs/faency 12.2.0 → 12.2.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.
- package/dist/components/Blockquote/Blockquote.vanilla.css.cjs +0 -1
- package/dist/components/Blockquote/Blockquote.vanilla.css.cjs.map +1 -1
- package/dist/components/Blockquote/Blockquote.vanilla.css.js +0 -1
- package/dist/components/Blockquote/Blockquote.vanilla.css.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.cjs +18 -8
- package/dist/components/CodeBlock/CodeBlock.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.js +18 -8
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.cjs +10 -8
- package/dist/components/CodeBlock/CodeBlock.vanilla.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.css.cjs +6 -4
- package/dist/components/CodeBlock/CodeBlock.vanilla.css.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.css.js +6 -4
- package/dist/components/CodeBlock/CodeBlock.vanilla.css.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.js +11 -9
- package/dist/components/CodeBlock/CodeBlock.vanilla.js.map +1 -1
- package/dist/components/Label/Label.vanilla.css.cjs +1 -0
- package/dist/components/Label/Label.vanilla.css.cjs.map +1 -1
- package/dist/components/Label/Label.vanilla.css.js +1 -0
- package/dist/components/Label/Label.vanilla.css.js.map +1 -1
- package/dist/faency.css +6 -3
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
;/* empty css */
|
|
4
3
|
;/* empty css */
|
|
5
4
|
const createRuntimeFn = require("@vanilla-extract/recipes/createRuntimeFn");
|
|
6
5
|
var blockquoteRecipe = createRuntimeFn.createRuntimeFn({ defaultClassName: "kyxdzh1 kyxdzh0", variantClassNames: { size: { "0": "kyxdzh2", "1": "kyxdzh3", "2": "kyxdzh4", "3": "kyxdzh5", "4": "kyxdzh6", "5": "kyxdzh7", "6": "kyxdzh8", "7": "kyxdzh9", "8": "kyxdzha", "9": "kyxdzhb", "10": "kyxdzhc", "11": "kyxdzhd", "12": "kyxdzhe", inherit: "kyxdzhf" }, weight: { light: "kyxdzhg", regular: "kyxdzhh", medium: "kyxdzhi", semiBold: "kyxdzhj", bold: "kyxdzhk" }, variant: { red: "kyxdzhl", subtle: "kyxdzhm", "default": "kyxdzhn", contrast: "kyxdzho", inherit: "kyxdzhp", invalid: "kyxdzhq" }, gradient: { true: "kyxdzhr" }, transform: { uppercase: "kyxdzhs", capitalize: "kyxdzht", capitalizeWords: "kyxdzhu" }, noWrap: { true: "kyxdzhv" } }, defaultVariants: { size: "3", variant: "default" }, compoundVariants: [] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Blockquote.vanilla.css.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Blockquote.vanilla.css.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* empty css */
|
|
2
1
|
/* empty css */
|
|
3
2
|
import { createRuntimeFn } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
4
3
|
var blockquoteRecipe = createRuntimeFn({ defaultClassName: "kyxdzh1 kyxdzh0", variantClassNames: { size: { "0": "kyxdzh2", "1": "kyxdzh3", "2": "kyxdzh4", "3": "kyxdzh5", "4": "kyxdzh6", "5": "kyxdzh7", "6": "kyxdzh8", "7": "kyxdzh9", "8": "kyxdzha", "9": "kyxdzhb", "10": "kyxdzhc", "11": "kyxdzhd", "12": "kyxdzhe", inherit: "kyxdzhf" }, weight: { light: "kyxdzhg", regular: "kyxdzhh", medium: "kyxdzhi", semiBold: "kyxdzhj", bold: "kyxdzhk" }, variant: { red: "kyxdzhl", subtle: "kyxdzhm", "default": "kyxdzhn", contrast: "kyxdzho", inherit: "kyxdzhp", invalid: "kyxdzhq" }, gradient: { true: "kyxdzhr" }, transform: { uppercase: "kyxdzhs", capitalize: "kyxdzht", capitalizeWords: "kyxdzhu" }, noWrap: { true: "kyxdzhv" } }, defaultVariants: { size: "3", variant: "default" }, compoundVariants: [] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Blockquote.vanilla.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Blockquote.vanilla.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -146,15 +146,25 @@ const CodeBlock = React.forwardRef(
|
|
|
146
146
|
style: { maxHeight, ...highlightStyle, backgroundColor: "inherit", ...style },
|
|
147
147
|
noBorder,
|
|
148
148
|
...props,
|
|
149
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
150
|
-
|
|
149
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
150
|
+
Box.Box,
|
|
151
151
|
{
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
152
|
+
css: {
|
|
153
|
+
p: "$4",
|
|
154
|
+
...copyable && isLeft && isBottom ? { pb: "$7" } : {},
|
|
155
|
+
...copyable && isLeft && !isBottom ? { pt: "$7" } : {}
|
|
156
|
+
},
|
|
157
|
+
children: tokens.map((line, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
158
|
+
"div",
|
|
159
|
+
{
|
|
160
|
+
...getLineProps({ line }),
|
|
161
|
+
style: wrapText ? { whiteSpace: "pre-wrap", wordBreak: "break-all" } : void 0,
|
|
162
|
+
children: line.map((token, key) => /* @__PURE__ */ jsxRuntime.jsx("span", { ...getTokenProps({ token }) }, key))
|
|
163
|
+
},
|
|
164
|
+
i
|
|
165
|
+
))
|
|
166
|
+
}
|
|
167
|
+
)
|
|
158
168
|
}
|
|
159
169
|
),
|
|
160
170
|
copyButton && /* @__PURE__ */ jsxRuntime.jsx(CopyButtonWrapper, { ref: buttonWrapperRef, position: buttonPosition, children: copyButton })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.cjs","sources":["../../../components/CodeBlock/CodeBlock.tsx"],"sourcesContent":["import './prism-extend';\n\nimport { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { Highlight, Language, Prism, themes } from 'prism-react-renderer';\nimport React, {\n ComponentProps,\n forwardRef,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { CSS, styled } from '../../stitches.config';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { useColorScheme } from '../colorSchemeContext';\nimport type { CodeBlockCopyButtonAlign, CodeBlockLanguage } from './index';\n\nconst Pre = styled('pre', {\n m: 0,\n borderRadius: '$2',\n overflow: 'auto',\n border: '1px solid $colors$deepBlue3',\n fontSize: '$2',\n lineHeight: 1.6,\n\n variants: {\n noBorder: {\n true: { border: 'none' },\n },\n },\n});\n\nconst CopyButtonWrapper = styled('div', {\n position: 'absolute',\n zIndex: 1,\n variants: {\n position: {\n top: { top: '$2', right: '$3' },\n topLeft: { top: '$2', left: '$3' },\n bottomRight: { bottom: '$2', right: '$3' },\n bottomLeft: { bottom: '$2', left: '$3' },\n },\n },\n\n defaultVariants: {\n position: 'top',\n },\n});\n\nexport type CodeBlockProps = {\n lang?: CodeBlockLanguage;\n code: string;\n copyable?: boolean;\n copyText?: string;\n copiedText?: string;\n copyButtonAlign?: CodeBlockCopyButtonAlign;\n onCopy?: () => void;\n noBorder?: boolean;\n wrapText?: boolean;\n colorScheme?: 'light' | 'dark';\n maxHeight?: number | string;\n css?: CSS;\n} & Omit<ComponentProps<typeof Pre>, 'css'>;\n\nexport const CodeBlock = forwardRef<HTMLPreElement, CodeBlockProps>(\n (\n {\n lang = 'text',\n code,\n copyable = false,\n copyText,\n copiedText,\n copyButtonAlign = 'top right',\n onCopy,\n noBorder,\n wrapText = false,\n colorScheme,\n maxHeight = 424,\n css,\n style,\n className,\n ...props\n },\n ref,\n ) => {\n const systemScheme = useColorScheme();\n const resolvedScheme = colorScheme ?? systemScheme;\n const prismTheme = resolvedScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n const buttonPosition = isBottom\n ? isLeft\n ? 'bottomLeft'\n : 'bottomRight'\n : isLeft\n ? 'topLeft'\n : 'top';\n\n const [copied, setCopied] = useState(false);\n\n const preRef = useRef<HTMLPreElement | null>(\n null,\n ) as React.MutableRefObject<HTMLPreElement | null>;\n const buttonWrapperRef = useRef<HTMLDivElement>(null);\n\n const setPreRef = useCallback(\n (node: HTMLPreElement | null) => {\n preRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLPreElement | null>).current = node;\n },\n [ref],\n );\n\n useLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const isBottomAlign = isBottom;\n const borderH = noBorder ? 0 : 2;\n\n const update = () => {\n if (!isLeft) {\n const vScrollbar = Math.max(0, pre.offsetWidth - pre.clientWidth - borderH);\n wrapper.style.right = `${16 + vScrollbar}px`;\n }\n if (isBottomAlign) {\n const hScrollbar = Math.max(0, pre.offsetHeight - pre.clientHeight - borderH);\n wrapper.style.bottom = `${8 + hScrollbar}px`;\n }\n };\n\n update();\n const observer = new ResizeObserver(update);\n observer.observe(pre);\n return () => observer.disconnect();\n }, [copyable, isBottom, isLeft, noBorder]);\n\n const handleCopy = async () => {\n try {\n await navigator.clipboard.writeText(code);\n setCopied(true);\n onCopy?.();\n setTimeout(() => setCopied(false), 1500);\n } catch {\n // clipboard write failed (e.g. permission denied) — leave UI unchanged\n }\n };\n\n const copyButton = copyable ? (\n <Button\n variant=\"secondary\"\n ghost\n size=\"small\"\n type=\"button\"\n onClick={handleCopy}\n css={{\n color: '$hiContrast',\n gap: '$1',\n backgroundColor: '$codeBlockCopyButtonBg',\n height: '32px',\n }}\n >\n <AccessibleIcon label={copied ? 'Copied' : 'Copy'}>\n {copied ? <CheckIcon /> : <CopyIcon />}\n </AccessibleIcon>\n {copied ? copiedText : copyText}\n </Button>\n ) : null;\n\n return (\n <Highlight\n theme={prismTheme}\n code={code}\n language={(Prism.languages[lang] != null ? lang : 'text') as Language}\n >\n {({\n className: highlightClass,\n style: highlightStyle,\n tokens,\n getLineProps,\n getTokenProps,\n }) => (\n <Box css={{ position: 'relative', ...css }}>\n <Pre\n ref={setPreRef}\n className={[highlightClass, className].filter(Boolean).join(' ')}\n style={{ maxHeight, ...highlightStyle, backgroundColor: 'inherit', ...style }}\n noBorder={noBorder}\n {...props}\n >\n <Box css={{ p: '$4', ...(copyable && isBottom ? { pb: '$7' } : {}) }}>\n {tokens.map((line, i) => (\n <div\n key={i}\n {...getLineProps({ line })}\n style={\n wrapText ? { whiteSpace: 'pre-wrap', wordBreak: 'break-all' } : undefined\n }\n >\n {line.map((token, key) => (\n <span key={key} {...getTokenProps({ token })} />\n ))}\n </div>\n ))}\n </Box>\n </Pre>\n {copyButton && (\n <CopyButtonWrapper ref={buttonWrapperRef} position={buttonPosition}>\n {copyButton}\n </CopyButtonWrapper>\n )}\n </Box>\n )}\n </Highlight>\n );\n },\n);\n\nCodeBlock.displayName = 'CodeBlock';\n"],"names":["styled","forwardRef","useColorScheme","themes","useState","useRef","useCallback","useLayoutEffect","jsxs","Button","jsx","AccessibleIcon","CheckIcon","CopyIcon","Highlight","Prism","Box"],"mappings":";;;;;;;;;;;AAoBA,MAAM,MAAMA,gBAAAA,OAAO,OAAO;AAAA,EACxB,GAAG;AAAA,EACH,cAAc;AAAA,EACd,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,YAAY;AAAA,EAEZ,UAAU;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O,EAAA,GAAhC,GAAmC,CAC/C;AAAA,gBAAA;AAAA,gBARI;AAAA,cAAA,CAUR,EAAA,CACH;AAAA,YAAA;AAAA,UAAA;AAAA,UAED,cACCA,2BAAAA,IAAC,mBAAA,EAAkB,KAAK,kBAAkB,UAAU,gBACjD,UAAA,WAAA,CACH;AAAA,QAAA,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,UAAU,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"CodeBlock.cjs","sources":["../../../components/CodeBlock/CodeBlock.tsx"],"sourcesContent":["import './prism-extend';\n\nimport { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { Highlight, Language, Prism, themes } from 'prism-react-renderer';\nimport React, {\n ComponentProps,\n forwardRef,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { CSS, styled } from '../../stitches.config';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { useColorScheme } from '../colorSchemeContext';\nimport type { CodeBlockCopyButtonAlign, CodeBlockLanguage } from './index';\n\nconst Pre = styled('pre', {\n m: 0,\n borderRadius: '$2',\n overflow: 'auto',\n border: '1px solid $colors$deepBlue3',\n fontSize: '$2',\n lineHeight: 1.6,\n\n variants: {\n noBorder: {\n true: { border: 'none' },\n },\n },\n});\n\nconst CopyButtonWrapper = styled('div', {\n position: 'absolute',\n zIndex: 1,\n variants: {\n position: {\n top: { top: '$2', right: '$3' },\n topLeft: { top: '$2', left: '$3' },\n bottomRight: { bottom: '$2', right: '$3' },\n bottomLeft: { bottom: '$2', left: '$3' },\n },\n },\n\n defaultVariants: {\n position: 'top',\n },\n});\n\nexport type CodeBlockProps = {\n lang?: CodeBlockLanguage;\n code: string;\n copyable?: boolean;\n copyText?: string;\n copiedText?: string;\n copyButtonAlign?: CodeBlockCopyButtonAlign;\n onCopy?: () => void;\n noBorder?: boolean;\n wrapText?: boolean;\n colorScheme?: 'light' | 'dark';\n maxHeight?: number | string;\n css?: CSS;\n} & Omit<ComponentProps<typeof Pre>, 'css'>;\n\nexport const CodeBlock = forwardRef<HTMLPreElement, CodeBlockProps>(\n (\n {\n lang = 'text',\n code,\n copyable = false,\n copyText,\n copiedText,\n copyButtonAlign = 'top right',\n onCopy,\n noBorder,\n wrapText = false,\n colorScheme,\n maxHeight = 424,\n css,\n style,\n className,\n ...props\n },\n ref,\n ) => {\n const systemScheme = useColorScheme();\n const resolvedScheme = colorScheme ?? systemScheme;\n const prismTheme = resolvedScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n const buttonPosition = isBottom\n ? isLeft\n ? 'bottomLeft'\n : 'bottomRight'\n : isLeft\n ? 'topLeft'\n : 'top';\n\n const [copied, setCopied] = useState(false);\n\n const preRef = useRef<HTMLPreElement | null>(\n null,\n ) as React.MutableRefObject<HTMLPreElement | null>;\n const buttonWrapperRef = useRef<HTMLDivElement>(null);\n\n const setPreRef = useCallback(\n (node: HTMLPreElement | null) => {\n preRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLPreElement | null>).current = node;\n },\n [ref],\n );\n\n useLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const isBottomAlign = isBottom;\n const borderH = noBorder ? 0 : 2;\n\n const update = () => {\n if (!isLeft) {\n const vScrollbar = Math.max(0, pre.offsetWidth - pre.clientWidth - borderH);\n wrapper.style.right = `${16 + vScrollbar}px`;\n }\n if (isBottomAlign) {\n const hScrollbar = Math.max(0, pre.offsetHeight - pre.clientHeight - borderH);\n wrapper.style.bottom = `${8 + hScrollbar}px`;\n }\n };\n\n update();\n const observer = new ResizeObserver(update);\n observer.observe(pre);\n return () => observer.disconnect();\n }, [copyable, isBottom, isLeft, noBorder]);\n\n const handleCopy = async () => {\n try {\n await navigator.clipboard.writeText(code);\n setCopied(true);\n onCopy?.();\n setTimeout(() => setCopied(false), 1500);\n } catch {\n // clipboard write failed (e.g. permission denied) — leave UI unchanged\n }\n };\n\n const copyButton = copyable ? (\n <Button\n variant=\"secondary\"\n ghost\n size=\"small\"\n type=\"button\"\n onClick={handleCopy}\n css={{\n color: '$hiContrast',\n gap: '$1',\n backgroundColor: '$codeBlockCopyButtonBg',\n height: '32px',\n }}\n >\n <AccessibleIcon label={copied ? 'Copied' : 'Copy'}>\n {copied ? <CheckIcon /> : <CopyIcon />}\n </AccessibleIcon>\n {copied ? copiedText : copyText}\n </Button>\n ) : null;\n\n return (\n <Highlight\n theme={prismTheme}\n code={code}\n language={(Prism.languages[lang] != null ? lang : 'text') as Language}\n >\n {({\n className: highlightClass,\n style: highlightStyle,\n tokens,\n getLineProps,\n getTokenProps,\n }) => (\n <Box css={{ position: 'relative', ...css }}>\n <Pre\n ref={setPreRef}\n className={[highlightClass, className].filter(Boolean).join(' ')}\n style={{ maxHeight, ...highlightStyle, backgroundColor: 'inherit', ...style }}\n noBorder={noBorder}\n {...props}\n >\n <Box\n css={{\n p: '$4',\n ...(copyable && isLeft && isBottom ? { pb: '$7' } : {}),\n ...(copyable && isLeft && !isBottom ? { pt: '$7' } : {}),\n }}\n >\n {tokens.map((line, i) => (\n <div\n key={i}\n {...getLineProps({ line })}\n style={\n wrapText ? { whiteSpace: 'pre-wrap', wordBreak: 'break-all' } : undefined\n }\n >\n {line.map((token, key) => (\n <span key={key} {...getTokenProps({ token })} />\n ))}\n </div>\n ))}\n </Box>\n </Pre>\n {copyButton && (\n <CopyButtonWrapper ref={buttonWrapperRef} position={buttonPosition}>\n {copyButton}\n </CopyButtonWrapper>\n )}\n </Box>\n )}\n </Highlight>\n );\n },\n);\n\nCodeBlock.displayName = 'CodeBlock';\n"],"names":["styled","forwardRef","useColorScheme","themes","useState","useRef","useCallback","useLayoutEffect","jsxs","Button","jsx","AccessibleIcon","Che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Y,UAAU,CAAC,WAAW,EAAE,IAAI,SAAS,CAAA;AAAA,kBAAC;AAAA,kBAGvD,UAAA,OAAO,IAAI,CAAC,MAAM,MACjBN,2BAAAA;AAAAA,oBAAC;AAAA,oBAAA;AAAA,sBAEE,GAAG,aAAa,EAAE,MAAM;AAAA,sBACzB,OACE,WAAW,EAAE,YAAY,YAAY,WAAW,gBAAgB;AAAA,sBAGjE,UAAA,KAAK,IAAI,CAAC,OAAO,QAChBA,2BAAAA,IAAC,QAAA,EAAgB,GAAG,cAAc,EAAE,MAAA,CAAO,EAAA,GAAhC,GAAmC,CAC/C;AAAA,oBAAA;AAAA,oBARI;AAAA,kBAAA,CAUR;AAAA,gBAAA;AAAA,cAAA;AAAA,YACH;AAAA,UAAA;AAAA,UAED,cACCA,2BAAAA,IAAC,mBAAA,EAAkB,KAAK,kBAAkB,UAAU,gBACjD,UAAA,WAAA,CACH;AAAA,QAAA,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,UAAU,cAAc;;"}
|
|
@@ -144,15 +144,25 @@ const CodeBlock = forwardRef(
|
|
|
144
144
|
style: { maxHeight, ...highlightStyle, backgroundColor: "inherit", ...style },
|
|
145
145
|
noBorder,
|
|
146
146
|
...props,
|
|
147
|
-
children: /* @__PURE__ */ jsx(
|
|
148
|
-
|
|
147
|
+
children: /* @__PURE__ */ jsx(
|
|
148
|
+
Box,
|
|
149
149
|
{
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
css: {
|
|
151
|
+
p: "$4",
|
|
152
|
+
...copyable && isLeft && isBottom ? { pb: "$7" } : {},
|
|
153
|
+
...copyable && isLeft && !isBottom ? { pt: "$7" } : {}
|
|
154
|
+
},
|
|
155
|
+
children: tokens.map((line, i) => /* @__PURE__ */ jsx(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
...getLineProps({ line }),
|
|
159
|
+
style: wrapText ? { whiteSpace: "pre-wrap", wordBreak: "break-all" } : void 0,
|
|
160
|
+
children: line.map((token, key) => /* @__PURE__ */ jsx("span", { ...getTokenProps({ token }) }, key))
|
|
161
|
+
},
|
|
162
|
+
i
|
|
163
|
+
))
|
|
164
|
+
}
|
|
165
|
+
)
|
|
156
166
|
}
|
|
157
167
|
),
|
|
158
168
|
copyButton && /* @__PURE__ */ jsx(CopyButtonWrapper, { ref: buttonWrapperRef, position: buttonPosition, children: copyButton })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.js","sources":["../../../components/CodeBlock/CodeBlock.tsx"],"sourcesContent":["import './prism-extend';\n\nimport { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { Highlight, Language, Prism, themes } from 'prism-react-renderer';\nimport React, {\n ComponentProps,\n forwardRef,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { CSS, styled } from '../../stitches.config';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { useColorScheme } from '../colorSchemeContext';\nimport type { CodeBlockCopyButtonAlign, CodeBlockLanguage } from './index';\n\nconst Pre = styled('pre', {\n m: 0,\n borderRadius: '$2',\n overflow: 'auto',\n border: '1px solid $colors$deepBlue3',\n fontSize: '$2',\n lineHeight: 1.6,\n\n variants: {\n noBorder: {\n true: { border: 'none' },\n },\n },\n});\n\nconst CopyButtonWrapper = styled('div', {\n position: 'absolute',\n zIndex: 1,\n variants: {\n position: {\n top: { top: '$2', right: '$3' },\n topLeft: { top: '$2', left: '$3' },\n bottomRight: { bottom: '$2', right: '$3' },\n bottomLeft: { bottom: '$2', left: '$3' },\n },\n },\n\n defaultVariants: {\n position: 'top',\n },\n});\n\nexport type CodeBlockProps = {\n lang?: CodeBlockLanguage;\n code: string;\n copyable?: boolean;\n copyText?: string;\n copiedText?: string;\n copyButtonAlign?: CodeBlockCopyButtonAlign;\n onCopy?: () => void;\n noBorder?: boolean;\n wrapText?: boolean;\n colorScheme?: 'light' | 'dark';\n maxHeight?: number | string;\n css?: CSS;\n} & Omit<ComponentProps<typeof Pre>, 'css'>;\n\nexport const CodeBlock = forwardRef<HTMLPreElement, CodeBlockProps>(\n (\n {\n lang = 'text',\n code,\n copyable = false,\n copyText,\n copiedText,\n copyButtonAlign = 'top right',\n onCopy,\n noBorder,\n wrapText = false,\n colorScheme,\n maxHeight = 424,\n css,\n style,\n className,\n ...props\n },\n ref,\n ) => {\n const systemScheme = useColorScheme();\n const resolvedScheme = colorScheme ?? systemScheme;\n const prismTheme = resolvedScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n const buttonPosition = isBottom\n ? isLeft\n ? 'bottomLeft'\n : 'bottomRight'\n : isLeft\n ? 'topLeft'\n : 'top';\n\n const [copied, setCopied] = useState(false);\n\n const preRef = useRef<HTMLPreElement | null>(\n null,\n ) as React.MutableRefObject<HTMLPreElement | null>;\n const buttonWrapperRef = useRef<HTMLDivElement>(null);\n\n const setPreRef = useCallback(\n (node: HTMLPreElement | null) => {\n preRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLPreElement | null>).current = node;\n },\n [ref],\n );\n\n useLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const isBottomAlign = isBottom;\n const borderH = noBorder ? 0 : 2;\n\n const update = () => {\n if (!isLeft) {\n const vScrollbar = Math.max(0, pre.offsetWidth - pre.clientWidth - borderH);\n wrapper.style.right = `${16 + vScrollbar}px`;\n }\n if (isBottomAlign) {\n const hScrollbar = Math.max(0, pre.offsetHeight - pre.clientHeight - borderH);\n wrapper.style.bottom = `${8 + hScrollbar}px`;\n }\n };\n\n update();\n const observer = new ResizeObserver(update);\n observer.observe(pre);\n return () => observer.disconnect();\n }, [copyable, isBottom, isLeft, noBorder]);\n\n const handleCopy = async () => {\n try {\n await navigator.clipboard.writeText(code);\n setCopied(true);\n onCopy?.();\n setTimeout(() => setCopied(false), 1500);\n } catch {\n // clipboard write failed (e.g. permission denied) — leave UI unchanged\n }\n };\n\n const copyButton = copyable ? (\n <Button\n variant=\"secondary\"\n ghost\n size=\"small\"\n type=\"button\"\n onClick={handleCopy}\n css={{\n color: '$hiContrast',\n gap: '$1',\n backgroundColor: '$codeBlockCopyButtonBg',\n height: '32px',\n }}\n >\n <AccessibleIcon label={copied ? 'Copied' : 'Copy'}>\n {copied ? <CheckIcon /> : <CopyIcon />}\n </AccessibleIcon>\n {copied ? copiedText : copyText}\n </Button>\n ) : null;\n\n return (\n <Highlight\n theme={prismTheme}\n code={code}\n language={(Prism.languages[lang] != null ? lang : 'text') as Language}\n >\n {({\n className: highlightClass,\n style: highlightStyle,\n tokens,\n getLineProps,\n getTokenProps,\n }) => (\n <Box css={{ position: 'relative', ...css }}>\n <Pre\n ref={setPreRef}\n className={[highlightClass, className].filter(Boolean).join(' ')}\n style={{ maxHeight, ...highlightStyle, backgroundColor: 'inherit', ...style }}\n noBorder={noBorder}\n {...props}\n >\n <Box css={{ p: '$4', ...(copyable && isBottom ? { pb: '$7' } : {}) }}>\n {tokens.map((line, i) => (\n <div\n key={i}\n {...getLineProps({ line })}\n style={\n wrapText ? { whiteSpace: 'pre-wrap', wordBreak: 'break-all' } : undefined\n }\n >\n {line.map((token, key) => (\n <span key={key} {...getTokenProps({ token })} />\n ))}\n </div>\n ))}\n </Box>\n </Pre>\n {copyButton && (\n <CopyButtonWrapper ref={buttonWrapperRef} position={buttonPosition}>\n {copyButton}\n </CopyButtonWrapper>\n )}\n </Box>\n )}\n </Highlight>\n );\n },\n);\n\nCodeBlock.displayName = 'CodeBlock';\n"],"names":[],"mappings":";;;;;;;;;AAoBA,MAAM,MAAM,OAAO,OAAO;AAAA,EACxB,GAAG;AAAA,EACH,cAAc;AAAA,EACd,UA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kB,UAAU,gBACjD,UAAA,WAAA,CACH;AAAA,QAAA,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,UAAU,cAAc;"}
|
|
1
|
+
{"version":3,"file":"CodeBlock.js","sources":["../../../components/CodeBlock/CodeBlock.tsx"],"sourcesContent":["import './prism-extend';\n\nimport { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { Highlight, Language, Prism, themes } from 'prism-react-renderer';\nimport React, {\n ComponentProps,\n forwardRef,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { CSS, styled } from '../../stitches.config';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { useColorScheme } from '../colorSchemeContext';\nimport type { CodeBlockCopyButtonAlign, CodeBlockLanguage } from './index';\n\nconst Pre = styled('pre', {\n m: 0,\n borderRadius: '$2',\n overflow: 'auto',\n border: '1px solid $colors$deepBlue3',\n fontSize: '$2',\n lineHeight: 1.6,\n\n variants: {\n noBorder: {\n true: { border: 'none' },\n },\n },\n});\n\nconst CopyButtonWrapper = styled('div', {\n position: 'absolute',\n zIndex: 1,\n variants: {\n position: {\n top: { top: '$2', right: '$3' },\n topLeft: { top: '$2', left: '$3' },\n bottomRight: { bottom: '$2', right: '$3' },\n bottomLeft: { bottom: '$2', left: '$3' },\n },\n },\n\n defaultVariants: {\n position: 'top',\n },\n});\n\nexport type CodeBlockProps = {\n lang?: CodeBlockLanguage;\n code: string;\n copyable?: boolean;\n copyText?: string;\n copiedText?: string;\n copyButtonAlign?: CodeBlockCopyButtonAlign;\n onCopy?: () => void;\n noBorder?: boolean;\n wrapText?: boolean;\n colorScheme?: 'light' | 'dark';\n maxHeight?: number | string;\n css?: CSS;\n} & Omit<ComponentProps<typeof Pre>, 'css'>;\n\nexport const CodeBlock = forwardRef<HTMLPreElement, CodeBlockProps>(\n (\n {\n lang = 'text',\n code,\n copyable = false,\n copyText,\n copiedText,\n copyButtonAlign = 'top right',\n onCopy,\n noBorder,\n wrapText = false,\n colorScheme,\n maxHeight = 424,\n css,\n style,\n className,\n ...props\n },\n ref,\n ) => {\n const systemScheme = useColorScheme();\n const resolvedScheme = colorScheme ?? systemScheme;\n const prismTheme = resolvedScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n const buttonPosition = isBottom\n ? isLeft\n ? 'bottomLeft'\n : 'bottomRight'\n : isLeft\n ? 'topLeft'\n : 'top';\n\n const [copied, setCopied] = useState(false);\n\n const preRef = useRef<HTMLPreElement | null>(\n null,\n ) as React.MutableRefObject<HTMLPreElement | null>;\n const buttonWrapperRef = useRef<HTMLDivElement>(null);\n\n const setPreRef = useCallback(\n (node: HTMLPreElement | null) => {\n preRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLPreElement | null>).current = node;\n },\n [ref],\n );\n\n useLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const isBottomAlign = isBottom;\n const borderH = noBorder ? 0 : 2;\n\n const update = () => {\n if (!isLeft) {\n const vScrollbar = Math.max(0, pre.offsetWidth - pre.clientWidth - borderH);\n wrapper.style.right = `${16 + vScrollbar}px`;\n }\n if (isBottomAlign) {\n const hScrollbar = Math.max(0, pre.offsetHeight - pre.clientHeight - borderH);\n wrapper.style.bottom = `${8 + hScrollbar}px`;\n }\n };\n\n update();\n const observer = new ResizeObserver(update);\n observer.observe(pre);\n return () => observer.disconnect();\n }, [copyable, isBottom, isLeft, noBorder]);\n\n const handleCopy = async () => {\n try {\n await navigator.clipboard.writeText(code);\n setCopied(true);\n onCopy?.();\n setTimeout(() => setCopied(false), 1500);\n } catch {\n // clipboard write failed (e.g. permission denied) — leave UI unchanged\n }\n };\n\n const copyButton = copyable ? (\n <Button\n variant=\"secondary\"\n ghost\n size=\"small\"\n type=\"button\"\n onClick={handleCopy}\n css={{\n color: '$hiContrast',\n gap: '$1',\n backgroundColor: '$codeBlockCopyButtonBg',\n height: '32px',\n }}\n >\n <AccessibleIcon label={copied ? 'Copied' : 'Copy'}>\n {copied ? <CheckIcon /> : <CopyIcon />}\n </AccessibleIcon>\n {copied ? copiedText : copyText}\n </Button>\n ) : null;\n\n return (\n <Highlight\n theme={prismTheme}\n code={code}\n language={(Prism.languages[lang] != null ? lang : 'text') as Language}\n >\n {({\n className: highlightClass,\n style: highlightStyle,\n tokens,\n getLineProps,\n getTokenProps,\n }) => (\n <Box css={{ position: 'relative', ...css }}>\n <Pre\n ref={setPreRef}\n className={[highlightClass, className].filter(Boolean).join(' ')}\n style={{ maxHeight, ...highlightStyle, backgroundColor: 'inherit', ...style }}\n noBorder={noBorder}\n {...props}\n >\n <Box\n css={{\n p: '$4',\n ...(copyable && isLeft && isBottom ? { pb: '$7' } : {}),\n ...(copyable && isLeft && !isBottom ? { pt: '$7' } : {}),\n }}\n >\n {tokens.map((line, i) => (\n <div\n key={i}\n {...getLineProps({ line })}\n style={\n wrapText ? { whiteSpace: 'pre-wrap', wordBreak: 'break-all' } : undefined\n }\n >\n {line.map((token, key) => (\n <span key={key} {...getTokenProps({ token })} />\n ))}\n </div>\n ))}\n </Box>\n </Pre>\n {copyButton && (\n <CopyButtonWrapper ref={buttonWrapperRef} position={buttonPosition}>\n {copyButton}\n </CopyButtonWrapper>\n )}\n </Box>\n )}\n </Highlight>\n );\n },\n);\n\nCodeBlock.displayName = 'CodeBlock';\n"],"names":[],"mappings":";;;;;;;;;AAoBA,MAAM,MAAM,OAAO,OAAO;AAAA,EACxB,GAAG;AAAA,EACH,cAAc;AAAA,EACd,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,YAAY;AAAA,EAEZ,UAAU;AAAA,IACR,UAAU;AAAA,MACR,MAAM,EAAE,QAAQ,OAAA;AAAA,IAAO;AAAA,E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,UAAU,gBACjD,UAAA,WAAA,CACH;AAAA,QAAA,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,UAAU,cAAc;"}
|
|
@@ -31,6 +31,8 @@ const CodeBlockVanilla = React.forwardRef(
|
|
|
31
31
|
const { colors, resolvedTheme } = themeContext.useVanillaExtractTheme();
|
|
32
32
|
const effectiveScheme = colorScheme ?? resolvedTheme;
|
|
33
33
|
const prismTheme = effectiveScheme === "dark" ? prismReactRenderer.themes.nightOwl : prismReactRenderer.themes.nightOwlLight;
|
|
34
|
+
const isBottom = copyButtonAlign.includes("bottom");
|
|
35
|
+
const isLeft = copyButtonAlign.includes("left");
|
|
34
36
|
const { style: cssStyles, vars } = cssProps.processCSSProp(css, colors);
|
|
35
37
|
const containerStyles = {
|
|
36
38
|
position: "relative",
|
|
@@ -55,15 +57,13 @@ const CodeBlockVanilla = React.forwardRef(
|
|
|
55
57
|
const pre2 = preRef.current;
|
|
56
58
|
const wrapper = buttonWrapperRef.current;
|
|
57
59
|
if (!pre2 || !wrapper) return;
|
|
58
|
-
const isLeftAlign = copyButtonAlign.includes("left");
|
|
59
|
-
const isBottomAlign = copyButtonAlign.includes("bottom");
|
|
60
60
|
const borderH = noBorder ? 0 : 2;
|
|
61
61
|
const update = () => {
|
|
62
|
-
if (!
|
|
62
|
+
if (!isLeft) {
|
|
63
63
|
const vScrollbar = Math.max(0, pre2.offsetWidth - pre2.clientWidth - borderH);
|
|
64
64
|
wrapper.style.right = `${16 + vScrollbar}px`;
|
|
65
65
|
}
|
|
66
|
-
if (
|
|
66
|
+
if (isBottom) {
|
|
67
67
|
const hScrollbar = Math.max(0, pre2.offsetHeight - pre2.clientHeight - borderH);
|
|
68
68
|
wrapper.style.bottom = `${8 + hScrollbar}px`;
|
|
69
69
|
}
|
|
@@ -72,7 +72,7 @@ const CodeBlockVanilla = React.forwardRef(
|
|
|
72
72
|
const observer = new ResizeObserver(update);
|
|
73
73
|
observer.observe(pre2);
|
|
74
74
|
return () => observer.disconnect();
|
|
75
|
-
}, [copyable,
|
|
75
|
+
}, [copyable, isBottom, isLeft, noBorder]);
|
|
76
76
|
const handleCopy = async () => {
|
|
77
77
|
try {
|
|
78
78
|
await navigator.clipboard.writeText(code);
|
|
@@ -82,8 +82,6 @@ const CodeBlockVanilla = React.forwardRef(
|
|
|
82
82
|
} catch {
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
|
-
const isBottom = copyButtonAlign.includes("bottom");
|
|
86
|
-
const isLeft = copyButtonAlign.includes("left");
|
|
87
85
|
const buttonPositionClass = isBottom ? isLeft ? CodeBlock_vanilla_css.copyButtonWrapperBottomLeft : CodeBlock_vanilla_css.copyButtonWrapperBottomRight : isLeft ? CodeBlock_vanilla_css.copyButtonWrapperTopLeft : CodeBlock_vanilla_css.copyButtonWrapperTop;
|
|
88
86
|
const copyButton = copyable ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
89
87
|
Button_vanilla.ButtonVanilla,
|
|
@@ -133,7 +131,11 @@ const CodeBlockVanilla = React.forwardRef(
|
|
|
133
131
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
134
132
|
"div",
|
|
135
133
|
{
|
|
136
|
-
className: [
|
|
134
|
+
className: [
|
|
135
|
+
CodeBlock_vanilla_css.codeContent,
|
|
136
|
+
copyable && isLeft && isBottom ? CodeBlock_vanilla_css.codeContentBottomPadding : "",
|
|
137
|
+
copyable && isLeft && !isBottom ? CodeBlock_vanilla_css.codeContentTopPadding : ""
|
|
138
|
+
].filter(Boolean).join(" "),
|
|
137
139
|
children: tokens.map((line, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
138
140
|
"div",
|
|
139
141
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.vanilla.cjs","sources":["../../../components/CodeBlock/CodeBlock.vanilla.tsx"],"sourcesContent":["import './prism-extend';\n\nimport { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { Highlight, Language, Prism, themes } from 'prism-react-renderer';\nimport React, {\n forwardRef,\n HTMLAttributes,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { ButtonVanilla } from '../Button';\nimport {\n codeContent,\n codeContentBottomPadding,\n copyButtonWrapperBottomLeft,\n copyButtonWrapperBottomRight,\n copyButtonWrapperTop,\n copyButtonWrapperTopLeft,\n pre,\n preNoBorder,\n} from './CodeBlock.vanilla.css';\nimport type { CodeBlockCopyButtonAlign, CodeBlockLanguage } from './index';\n\nexport interface CodeBlockVanillaProps\n extends Omit<HTMLAttributes<HTMLPreElement>, 'css'>,\n CSSProps {\n lang?: CodeBlockLanguage;\n code: string;\n copyable?: boolean;\n copyText?: string;\n copiedText?: string;\n copyButtonAlign?: CodeBlockCopyButtonAlign;\n onCopy?: () => void;\n noBorder?: boolean;\n wrapText?: boolean;\n colorScheme?: 'light' | 'dark';\n maxHeight?: number | string;\n}\n\nexport const CodeBlockVanilla = forwardRef<HTMLPreElement, CodeBlockVanillaProps>(\n (\n {\n lang = 'text',\n code,\n copyable = false,\n copyText,\n copiedText,\n copyButtonAlign = 'top right',\n onCopy,\n noBorder,\n wrapText = false,\n colorScheme,\n maxHeight = 424,\n css,\n style,\n className,\n ...props\n },\n ref,\n ) => {\n const { colors, resolvedTheme } = useVanillaExtractTheme();\n const effectiveScheme = colorScheme ?? resolvedTheme;\n const prismTheme = effectiveScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n const containerStyles = {\n position: 'relative' as const,\n ...cssStyles,\n ...assignInlineVars(vars),\n };\n\n const [copied, setCopied] = useState(false);\n\n const preRef = useRef<HTMLPreElement | null>(\n null,\n ) as React.MutableRefObject<HTMLPreElement | null>;\n const buttonWrapperRef = useRef<HTMLDivElement>(null);\n\n const setPreRef = useCallback(\n (node: HTMLPreElement | null) => {\n preRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLPreElement | null>).current = node;\n },\n [ref],\n );\n\n useLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const isLeftAlign = copyButtonAlign.includes('left');\n const isBottomAlign = copyButtonAlign.includes('bottom');\n const borderH = noBorder ? 0 : 2;\n\n const update = () => {\n if (!isLeftAlign) {\n const vScrollbar = Math.max(0, pre.offsetWidth - pre.clientWidth - borderH);\n wrapper.style.right = `${16 + vScrollbar}px`;\n }\n if (isBottomAlign) {\n const hScrollbar = Math.max(0, pre.offsetHeight - pre.clientHeight - borderH);\n wrapper.style.bottom = `${8 + hScrollbar}px`;\n }\n };\n\n update();\n const observer = new ResizeObserver(update);\n observer.observe(pre);\n return () => observer.disconnect();\n }, [copyable, copyButtonAlign, noBorder]);\n\n const handleCopy = async () => {\n try {\n await navigator.clipboard.writeText(code);\n setCopied(true);\n onCopy?.();\n setTimeout(() => setCopied(false), 1500);\n } catch {\n // clipboard write failed (e.g. permission denied) — leave UI unchanged\n }\n };\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n const buttonPositionClass = isBottom\n ? isLeft\n ? copyButtonWrapperBottomLeft\n : copyButtonWrapperBottomRight\n : isLeft\n ? copyButtonWrapperTopLeft\n : copyButtonWrapperTop;\n\n const copyButton = copyable ? (\n <ButtonVanilla\n variant=\"secondary\"\n ghost\n size=\"small\"\n type=\"button\"\n onClick={handleCopy}\n css={{\n color: '$hiContrast',\n gap: '$1',\n backgroundColor: '$codeBlockCopyButtonBg',\n height: '32px',\n }}\n >\n <AccessibleIcon label={copied ? 'Copied' : 'Copy'}>\n {copied ? <CheckIcon /> : <CopyIcon />}\n </AccessibleIcon>\n {copied ? copiedText : copyText}\n </ButtonVanilla>\n ) : null;\n\n return (\n <Highlight\n theme={prismTheme}\n code={code}\n language={(Prism.languages[lang] != null ? lang : 'text') as Language}\n >\n {({\n className: highlightClass,\n style: highlightStyle,\n tokens,\n getLineProps,\n getTokenProps,\n }) => (\n <div style={containerStyles}>\n <pre\n ref={setPreRef}\n className={[pre, noBorder ? preNoBorder : '', highlightClass, className]\n .filter(Boolean)\n .join(' ')}\n style={{\n maxHeight,\n ...highlightStyle,\n backgroundColor: 'inherit',\n ...style,\n }}\n {...props}\n >\n <div\n className={[codeContent, copyable && isBottom ? codeContentBottomPadding : '']\n .filter(Boolean)\n .join(' ')}\n >\n {tokens.map((line, i) => (\n <div\n key={i}\n {...getLineProps({ line })}\n style={\n wrapText ? { whiteSpace: 'pre-wrap', wordBreak: 'break-all' } : undefined\n }\n >\n {line.map((token, key) => (\n <span key={key} {...getTokenProps({ token })} />\n ))}\n </div>\n ))}\n </div>\n </pre>\n {copyButton && (\n <div ref={buttonWrapperRef} className={buttonPositionClass}>\n {copyButton}\n </div>\n )}\n </div>\n )}\n </Highlight>\n );\n },\n);\n\nCodeBlockVanilla.displayName = 'CodeBlockVanilla';\n"],"names":["forwardRef","useVanillaExtractTheme","themes","processCSSProp","assignInlineVars","useState","useRef","useCallback","useLayoutEffect","pre","copyButtonWrapperBottomLeft","copyButtonWrapperBottomRight","copyButtonWrapperTopLeft","copyButtonWrapperTop","jsxs","ButtonVanilla","jsx","AccessibleIcon","CheckIcon","CopyIcon","Highlight","Prism","preNoBorder","codeContent","codeContentBottomPadding"],"mappings":";;;;;;;;;;;;AA8CO,MAAM,mBAAmBA,MAAAA;AAAAA,EAC9B,CACE;AAAA,IACE,OAAO;AAAA,IACP;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;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js","sources":["../../../components/CodeBlock/CodeBlock.vanilla.tsx"],"sourcesContent":["import './prism-extend';\n\nimport { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { Highlight, Language, Prism, themes } from 'prism-react-renderer';\nimport React, {\n forwardRef,\n HTMLAttributes,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { ButtonVanilla } from '../Button';\nimport {\n codeContent,\n codeContentBottomPadding,\n codeContentTopPadding,\n copyButtonWrapperBottomLeft,\n copyButtonWrapperBottomRight,\n copyButtonWrapperTop,\n copyButtonWrapperTopLeft,\n pre,\n preNoBorder,\n} from './CodeBlock.vanilla.css';\nimport type { CodeBlockCopyButtonAlign, CodeBlockLanguage } from './index';\n\nexport interface CodeBlockVanillaProps\n extends Omit<HTMLAttributes<HTMLPreElement>, 'css'>,\n CSSProps {\n lang?: CodeBlockLanguage;\n code: string;\n copyable?: boolean;\n copyText?: string;\n copiedText?: string;\n copyButtonAlign?: CodeBlockCopyButtonAlign;\n onCopy?: () => void;\n noBorder?: boolean;\n wrapText?: boolean;\n colorScheme?: 'light' | 'dark';\n maxHeight?: number | string;\n}\n\nexport const CodeBlockVanilla = forwardRef<HTMLPreElement, CodeBlockVanillaProps>(\n (\n {\n lang = 'text',\n code,\n copyable = false,\n copyText,\n copiedText,\n copyButtonAlign = 'top right',\n onCopy,\n noBorder,\n wrapText = false,\n colorScheme,\n maxHeight = 424,\n css,\n style,\n className,\n ...props\n },\n ref,\n ) => {\n const { colors, resolvedTheme } = useVanillaExtractTheme();\n const effectiveScheme = colorScheme ?? resolvedTheme;\n const prismTheme = effectiveScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n const containerStyles = {\n position: 'relative' as const,\n ...cssStyles,\n ...assignInlineVars(vars),\n };\n\n const [copied, setCopied] = useState(false);\n\n const preRef = useRef<HTMLPreElement | null>(\n null,\n ) as React.MutableRefObject<HTMLPreElement | null>;\n const buttonWrapperRef = useRef<HTMLDivElement>(null);\n\n const setPreRef = useCallback(\n (node: HTMLPreElement | null) => {\n preRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLPreElement | null>).current = node;\n },\n [ref],\n );\n\n useLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const borderH = noBorder ? 0 : 2;\n\n const update = () => {\n if (!isLeft) {\n const vScrollbar = Math.max(0, pre.offsetWidth - pre.clientWidth - borderH);\n wrapper.style.right = `${16 + vScrollbar}px`;\n }\n if (isBottom) {\n const hScrollbar = Math.max(0, pre.offsetHeight - pre.clientHeight - borderH);\n wrapper.style.bottom = `${8 + hScrollbar}px`;\n }\n };\n\n update();\n const observer = new ResizeObserver(update);\n observer.observe(pre);\n return () => observer.disconnect();\n }, [copyable, isBottom, isLeft, noBorder]);\n\n const handleCopy = async () => {\n try {\n await navigator.clipboard.writeText(code);\n setCopied(true);\n onCopy?.();\n setTimeout(() => setCopied(false), 1500);\n } catch {\n // clipboard write failed (e.g. permission denied) — leave UI unchanged\n }\n };\n\n const buttonPositionClass = isBottom\n ? isLeft\n ? copyButtonWrapperBottomLeft\n : copyButtonWrapperBottomRight\n : isLeft\n ? copyButtonWrapperTopLeft\n : copyButtonWrapperTop;\n\n const copyButton = copyable ? (\n <ButtonVanilla\n variant=\"secondary\"\n ghost\n size=\"small\"\n type=\"button\"\n onClick={handleCopy}\n css={{\n color: '$hiContrast',\n gap: '$1',\n backgroundColor: '$codeBlockCopyButtonBg',\n height: '32px',\n }}\n >\n <AccessibleIcon label={copied ? 'Copied' : 'Copy'}>\n {copied ? <CheckIcon /> : <CopyIcon />}\n </AccessibleIcon>\n {copied ? copiedText : copyText}\n </ButtonVanilla>\n ) : null;\n\n return (\n <Highlight\n theme={prismTheme}\n code={code}\n language={(Prism.languages[lang] != null ? lang : 'text') as Language}\n >\n {({\n className: highlightClass,\n style: highlightStyle,\n tokens,\n getLineProps,\n getTokenProps,\n }) => (\n <div style={containerStyles}>\n <pre\n ref={setPreRef}\n className={[pre, noBorder ? preNoBorder : '', highlightClass, className]\n .filter(Boolean)\n .join(' ')}\n style={{\n maxHeight,\n ...highlightStyle,\n backgroundColor: 'inherit',\n ...style,\n }}\n {...props}\n >\n <div\n className={[\n codeContent,\n copyable && isLeft && isBottom ? codeContentBottomPadding : '',\n copyable && isLeft && !isBottom ? codeContentTopPadding : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {tokens.map((line, i) => (\n <div\n key={i}\n {...getLineProps({ line })}\n style={\n wrapText ? { whiteSpace: 'pre-wrap', wordBreak: 'break-all' } : undefined\n }\n >\n {line.map((token, key) => (\n <span key={key} {...getTokenProps({ token })} />\n ))}\n </div>\n ))}\n </div>\n </pre>\n {copyButton && (\n <div ref={buttonWrapperRef} className={buttonPositionClass}>\n {copyButton}\n </div>\n )}\n </div>\n )}\n </Highlight>\n );\n },\n);\n\nCodeBlockVanilla.displayName = 'CodeBlockVanilla';\n"],"names":["forwardRef","useVanillaExtractTheme","themes","processCSSProp","assignInlineVars","useState","useRef","useCallback","useLayoutEffect","pre","copyButtonWrapperBottomLeft","copyButtonWrapperBottomRight","copyButtonWrapperTopLeft","copyButtonWrapperTop","jsxs","ButtonVanilla","jsx","AccessibleIcon","CheckIcon","CopyIcon","Highlight","Prism","preNoBorder","codeContent","codeContentBottomPadding","codeContentTopPadding"],"mappings":";;;;;;;;;;;;AA+CO,MAAM,mBAAmBA,MAAAA;AAAAA,EAC9B,CACE;AAAA,IACE,OAAO;AAAA,IACP;AAAA,IACA,WAAW;AAAA,IACX;AA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AAA,QAAA,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,iBAAiB,cAAc;;"}
|
|
@@ -5,12 +5,14 @@ var pre = "_1krwcuz0";
|
|
|
5
5
|
var preNoBorder = "_1krwcuz1";
|
|
6
6
|
var codeContent = "_1krwcuz2";
|
|
7
7
|
var codeContentBottomPadding = "_1krwcuz3";
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
8
|
+
var codeContentTopPadding = "_1krwcuz4";
|
|
9
|
+
var copyButtonWrapperTop = "_1krwcuz5";
|
|
10
|
+
var copyButtonWrapperTopLeft = "_1krwcuz6";
|
|
11
|
+
var copyButtonWrapperBottomRight = "_1krwcuz7";
|
|
12
|
+
var copyButtonWrapperBottomLeft = "_1krwcuz8";
|
|
12
13
|
exports.codeContent = codeContent;
|
|
13
14
|
exports.codeContentBottomPadding = codeContentBottomPadding;
|
|
15
|
+
exports.codeContentTopPadding = codeContentTopPadding;
|
|
14
16
|
exports.copyButtonWrapperBottomLeft = copyButtonWrapperBottomLeft;
|
|
15
17
|
exports.copyButtonWrapperBottomRight = copyButtonWrapperBottomRight;
|
|
16
18
|
exports.copyButtonWrapperTop = copyButtonWrapperTop;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.vanilla.css.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CodeBlock.vanilla.css.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3,13 +3,15 @@ var pre = "_1krwcuz0";
|
|
|
3
3
|
var preNoBorder = "_1krwcuz1";
|
|
4
4
|
var codeContent = "_1krwcuz2";
|
|
5
5
|
var codeContentBottomPadding = "_1krwcuz3";
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
6
|
+
var codeContentTopPadding = "_1krwcuz4";
|
|
7
|
+
var copyButtonWrapperTop = "_1krwcuz5";
|
|
8
|
+
var copyButtonWrapperTopLeft = "_1krwcuz6";
|
|
9
|
+
var copyButtonWrapperBottomRight = "_1krwcuz7";
|
|
10
|
+
var copyButtonWrapperBottomLeft = "_1krwcuz8";
|
|
10
11
|
export {
|
|
11
12
|
codeContent,
|
|
12
13
|
codeContentBottomPadding,
|
|
14
|
+
codeContentTopPadding,
|
|
13
15
|
copyButtonWrapperBottomLeft,
|
|
14
16
|
copyButtonWrapperBottomRight,
|
|
15
17
|
copyButtonWrapperTop,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.vanilla.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CodeBlock.vanilla.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -5,7 +5,7 @@ import { themes, Highlight, Prism } from "prism-react-renderer";
|
|
|
5
5
|
import { forwardRef, useState, useRef, useCallback, useLayoutEffect } from "react";
|
|
6
6
|
import { processCSSProp } from "../../styles/cssProps.js";
|
|
7
7
|
import { useVanillaExtractTheme } from "../../styles/themeContext.js";
|
|
8
|
-
import { pre, preNoBorder, codeContent, codeContentBottomPadding, copyButtonWrapperBottomLeft, copyButtonWrapperBottomRight, copyButtonWrapperTopLeft, copyButtonWrapperTop } from "./CodeBlock.vanilla.css.js";
|
|
8
|
+
import { pre, preNoBorder, codeContent, codeContentBottomPadding, codeContentTopPadding, copyButtonWrapperBottomLeft, copyButtonWrapperBottomRight, copyButtonWrapperTopLeft, copyButtonWrapperTop } from "./CodeBlock.vanilla.css.js";
|
|
9
9
|
import { ButtonVanilla } from "../Button/Button.vanilla.js";
|
|
10
10
|
import { AccessibleIcon } from "../AccessibleIcon/AccessibleIcon.js";
|
|
11
11
|
const CodeBlockVanilla = forwardRef(
|
|
@@ -29,6 +29,8 @@ const CodeBlockVanilla = forwardRef(
|
|
|
29
29
|
const { colors, resolvedTheme } = useVanillaExtractTheme();
|
|
30
30
|
const effectiveScheme = colorScheme ?? resolvedTheme;
|
|
31
31
|
const prismTheme = effectiveScheme === "dark" ? themes.nightOwl : themes.nightOwlLight;
|
|
32
|
+
const isBottom = copyButtonAlign.includes("bottom");
|
|
33
|
+
const isLeft = copyButtonAlign.includes("left");
|
|
32
34
|
const { style: cssStyles, vars } = processCSSProp(css, colors);
|
|
33
35
|
const containerStyles = {
|
|
34
36
|
position: "relative",
|
|
@@ -53,15 +55,13 @@ const CodeBlockVanilla = forwardRef(
|
|
|
53
55
|
const pre2 = preRef.current;
|
|
54
56
|
const wrapper = buttonWrapperRef.current;
|
|
55
57
|
if (!pre2 || !wrapper) return;
|
|
56
|
-
const isLeftAlign = copyButtonAlign.includes("left");
|
|
57
|
-
const isBottomAlign = copyButtonAlign.includes("bottom");
|
|
58
58
|
const borderH = noBorder ? 0 : 2;
|
|
59
59
|
const update = () => {
|
|
60
|
-
if (!
|
|
60
|
+
if (!isLeft) {
|
|
61
61
|
const vScrollbar = Math.max(0, pre2.offsetWidth - pre2.clientWidth - borderH);
|
|
62
62
|
wrapper.style.right = `${16 + vScrollbar}px`;
|
|
63
63
|
}
|
|
64
|
-
if (
|
|
64
|
+
if (isBottom) {
|
|
65
65
|
const hScrollbar = Math.max(0, pre2.offsetHeight - pre2.clientHeight - borderH);
|
|
66
66
|
wrapper.style.bottom = `${8 + hScrollbar}px`;
|
|
67
67
|
}
|
|
@@ -70,7 +70,7 @@ const CodeBlockVanilla = forwardRef(
|
|
|
70
70
|
const observer = new ResizeObserver(update);
|
|
71
71
|
observer.observe(pre2);
|
|
72
72
|
return () => observer.disconnect();
|
|
73
|
-
}, [copyable,
|
|
73
|
+
}, [copyable, isBottom, isLeft, noBorder]);
|
|
74
74
|
const handleCopy = async () => {
|
|
75
75
|
try {
|
|
76
76
|
await navigator.clipboard.writeText(code);
|
|
@@ -80,8 +80,6 @@ const CodeBlockVanilla = forwardRef(
|
|
|
80
80
|
} catch {
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
|
-
const isBottom = copyButtonAlign.includes("bottom");
|
|
84
|
-
const isLeft = copyButtonAlign.includes("left");
|
|
85
83
|
const buttonPositionClass = isBottom ? isLeft ? copyButtonWrapperBottomLeft : copyButtonWrapperBottomRight : isLeft ? copyButtonWrapperTopLeft : copyButtonWrapperTop;
|
|
86
84
|
const copyButton = copyable ? /* @__PURE__ */ jsxs(
|
|
87
85
|
ButtonVanilla,
|
|
@@ -131,7 +129,11 @@ const CodeBlockVanilla = forwardRef(
|
|
|
131
129
|
children: /* @__PURE__ */ jsx(
|
|
132
130
|
"div",
|
|
133
131
|
{
|
|
134
|
-
className: [
|
|
132
|
+
className: [
|
|
133
|
+
codeContent,
|
|
134
|
+
copyable && isLeft && isBottom ? codeContentBottomPadding : "",
|
|
135
|
+
copyable && isLeft && !isBottom ? codeContentTopPadding : ""
|
|
136
|
+
].filter(Boolean).join(" "),
|
|
135
137
|
children: tokens.map((line, i) => /* @__PURE__ */ jsx(
|
|
136
138
|
"div",
|
|
137
139
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.vanilla.js","sources":["../../../components/CodeBlock/CodeBlock.vanilla.tsx"],"sourcesContent":["import './prism-extend';\n\nimport { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { Highlight, Language, Prism, themes } from 'prism-react-renderer';\nimport React, {\n forwardRef,\n HTMLAttributes,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { ButtonVanilla } from '../Button';\nimport {\n codeContent,\n codeContentBottomPadding,\n copyButtonWrapperBottomLeft,\n copyButtonWrapperBottomRight,\n copyButtonWrapperTop,\n copyButtonWrapperTopLeft,\n pre,\n preNoBorder,\n} from './CodeBlock.vanilla.css';\nimport type { CodeBlockCopyButtonAlign, CodeBlockLanguage } from './index';\n\nexport interface CodeBlockVanillaProps\n extends Omit<HTMLAttributes<HTMLPreElement>, 'css'>,\n CSSProps {\n lang?: CodeBlockLanguage;\n code: string;\n copyable?: boolean;\n copyText?: string;\n copiedText?: string;\n copyButtonAlign?: CodeBlockCopyButtonAlign;\n onCopy?: () => void;\n noBorder?: boolean;\n wrapText?: boolean;\n colorScheme?: 'light' | 'dark';\n maxHeight?: number | string;\n}\n\nexport const CodeBlockVanilla = forwardRef<HTMLPreElement, CodeBlockVanillaProps>(\n (\n {\n lang = 'text',\n code,\n copyable = false,\n copyText,\n copiedText,\n copyButtonAlign = 'top right',\n onCopy,\n noBorder,\n wrapText = false,\n colorScheme,\n maxHeight = 424,\n css,\n style,\n className,\n ...props\n },\n ref,\n ) => {\n const { colors, resolvedTheme } = useVanillaExtractTheme();\n const effectiveScheme = colorScheme ?? resolvedTheme;\n const prismTheme = effectiveScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n const containerStyles = {\n position: 'relative' as const,\n ...cssStyles,\n ...assignInlineVars(vars),\n };\n\n const [copied, setCopied] = useState(false);\n\n const preRef = useRef<HTMLPreElement | null>(\n null,\n ) as React.MutableRefObject<HTMLPreElement | null>;\n const buttonWrapperRef = useRef<HTMLDivElement>(null);\n\n const setPreRef = useCallback(\n (node: HTMLPreElement | null) => {\n preRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLPreElement | null>).current = node;\n },\n [ref],\n );\n\n useLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const
|
|
1
|
+
{"version":3,"file":"CodeBlock.vanilla.js","sources":["../../../components/CodeBlock/CodeBlock.vanilla.tsx"],"sourcesContent":["import './prism-extend';\n\nimport { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { Highlight, Language, Prism, themes } from 'prism-react-renderer';\nimport React, {\n forwardRef,\n HTMLAttributes,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { ButtonVanilla } from '../Button';\nimport {\n codeContent,\n codeContentBottomPadding,\n codeContentTopPadding,\n copyButtonWrapperBottomLeft,\n copyButtonWrapperBottomRight,\n copyButtonWrapperTop,\n copyButtonWrapperTopLeft,\n pre,\n preNoBorder,\n} from './CodeBlock.vanilla.css';\nimport type { CodeBlockCopyButtonAlign, CodeBlockLanguage } from './index';\n\nexport interface CodeBlockVanillaProps\n extends Omit<HTMLAttributes<HTMLPreElement>, 'css'>,\n CSSProps {\n lang?: CodeBlockLanguage;\n code: string;\n copyable?: boolean;\n copyText?: string;\n copiedText?: string;\n copyButtonAlign?: CodeBlockCopyButtonAlign;\n onCopy?: () => void;\n noBorder?: boolean;\n wrapText?: boolean;\n colorScheme?: 'light' | 'dark';\n maxHeight?: number | string;\n}\n\nexport const CodeBlockVanilla = forwardRef<HTMLPreElement, CodeBlockVanillaProps>(\n (\n {\n lang = 'text',\n code,\n copyable = false,\n copyText,\n copiedText,\n copyButtonAlign = 'top right',\n onCopy,\n noBorder,\n wrapText = false,\n colorScheme,\n maxHeight = 424,\n css,\n style,\n className,\n ...props\n },\n ref,\n ) => {\n const { colors, resolvedTheme } = useVanillaExtractTheme();\n const effectiveScheme = colorScheme ?? resolvedTheme;\n const prismTheme = effectiveScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n const containerStyles = {\n position: 'relative' as const,\n ...cssStyles,\n ...assignInlineVars(vars),\n };\n\n const [copied, setCopied] = useState(false);\n\n const preRef = useRef<HTMLPreElement | null>(\n null,\n ) as React.MutableRefObject<HTMLPreElement | null>;\n const buttonWrapperRef = useRef<HTMLDivElement>(null);\n\n const setPreRef = useCallback(\n (node: HTMLPreElement | null) => {\n preRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLPreElement | null>).current = node;\n },\n [ref],\n );\n\n useLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const borderH = noBorder ? 0 : 2;\n\n const update = () => {\n if (!isLeft) {\n const vScrollbar = Math.max(0, pre.offsetWidth - pre.clientWidth - borderH);\n wrapper.style.right = `${16 + vScrollbar}px`;\n }\n if (isBottom) {\n const hScrollbar = Math.max(0, pre.offsetHeight - pre.clientHeight - borderH);\n wrapper.style.bottom = `${8 + hScrollbar}px`;\n }\n };\n\n update();\n const observer = new ResizeObserver(update);\n observer.observe(pre);\n return () => observer.disconnect();\n }, [copyable, isBottom, isLeft, noBorder]);\n\n const handleCopy = async () => {\n try {\n await navigator.clipboard.writeText(code);\n setCopied(true);\n onCopy?.();\n setTimeout(() => setCopied(false), 1500);\n } catch {\n // clipboard write failed (e.g. permission denied) — leave UI unchanged\n }\n };\n\n const buttonPositionClass = isBottom\n ? isLeft\n ? copyButtonWrapperBottomLeft\n : copyButtonWrapperBottomRight\n : isLeft\n ? copyButtonWrapperTopLeft\n : copyButtonWrapperTop;\n\n const copyButton = copyable ? (\n <ButtonVanilla\n variant=\"secondary\"\n ghost\n size=\"small\"\n type=\"button\"\n onClick={handleCopy}\n css={{\n color: '$hiContrast',\n gap: '$1',\n backgroundColor: '$codeBlockCopyButtonBg',\n height: '32px',\n }}\n >\n <AccessibleIcon label={copied ? 'Copied' : 'Copy'}>\n {copied ? <CheckIcon /> : <CopyIcon />}\n </AccessibleIcon>\n {copied ? copiedText : copyText}\n </ButtonVanilla>\n ) : null;\n\n return (\n <Highlight\n theme={prismTheme}\n code={code}\n language={(Prism.languages[lang] != null ? lang : 'text') as Language}\n >\n {({\n className: highlightClass,\n style: highlightStyle,\n tokens,\n getLineProps,\n getTokenProps,\n }) => (\n <div style={containerStyles}>\n <pre\n ref={setPreRef}\n className={[pre, noBorder ? preNoBorder : '', highlightClass, className]\n .filter(Boolean)\n .join(' ')}\n style={{\n maxHeight,\n ...highlightStyle,\n backgroundColor: 'inherit',\n ...style,\n }}\n {...props}\n >\n <div\n className={[\n codeContent,\n copyable && isLeft && isBottom ? codeContentBottomPadding : '',\n copyable && isLeft && !isBottom ? codeContentTopPadding : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {tokens.map((line, i) => (\n <div\n key={i}\n {...getLineProps({ line })}\n style={\n wrapText ? { whiteSpace: 'pre-wrap', wordBreak: 'break-all' } : undefined\n }\n >\n {line.map((token, key) => (\n <span key={key} {...getTokenProps({ token })} />\n ))}\n </div>\n ))}\n </div>\n </pre>\n {copyButton && (\n <div ref={buttonWrapperRef} className={buttonPositionClass}>\n {copyButton}\n </div>\n )}\n </div>\n )}\n </Highlight>\n );\n },\n);\n\nCodeBlockVanilla.displayName = 'CodeBlockVanilla';\n"],"names":["pre"],"mappings":";;;;;;;;;;AA+CO,MAAM,mBAAmB;AAAA,EAC9B,CACE;AAAA,IACE,OAAO;AAAA,IACP;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,EAAE,QAAQ,cAAA,IAAkB,uBAAA;AAClC,UAAM,kBAAkB,eAAe;AACvC,UAAM,aAAa,oBAAoB,SAAS,OAAO,WAAW,OAAO;AAEzE,UAAM,WAAW,gBAAgB,SAAS,QAAQ;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oBACA,YAAY,UAAU,WAAW,2BAA2B;AAAA,oBAC5D,YAAY,UAAU,CAAC,WAAW,wBAAwB;AAAA,kBAAA,EAEzD,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,kBAEV,UAAA,OAAO,IAAI,CAAC,MAAM,MACjB;AAAA,oBAAC;AAAA,oBAAA;AAAA,sBAEE,GAAG,aAAa,EAAE,MAAM;AAAA,sBACzB,OACE,WAAW,EAAE,YAAY,YAAY,WAAW,gBAAgB;AAAA,sBAGjE,UAAA,KAAK,IAAI,CAAC,OAAO,QAChB,oBAAC,QAAA,EAAgB,GAAG,cAAc,EAAE,MAAA,CAAO,EAAA,GAAhC,GAAmC,CAC/C;AAAA,oBAAA;AAAA,oBARI;AAAA,kBAAA,CAUR;AAAA,gBAAA;AAAA,cAAA;AAAA,YACH;AAAA,UAAA;AAAA,UAED,cACC,oBAAC,OAAA,EAAI,KAAK,kBAAkB,WAAW,qBACpC,UAAA,WAAA,CACH;AAAA,QAAA,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,iBAAiB,cAAc;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
;/* empty css */
|
|
3
4
|
;/* empty css */
|
|
4
5
|
const createRuntimeFn = require("@vanilla-extract/recipes/createRuntimeFn");
|
|
5
6
|
var labelRecipe = createRuntimeFn.createRuntimeFn({ defaultClassName: "_14umx1r1 _14umx1r0", variantClassNames: { size: { "0": "_14umx1r2", "1": "_14umx1r3", "2": "_14umx1r4", "3": "_14umx1r5", "4": "_14umx1r6", "5": "_14umx1r7", "6": "_14umx1r8", "7": "_14umx1r9", "8": "_14umx1ra", "9": "_14umx1rb", "10": "_14umx1rc", "11": "_14umx1rd", "12": "_14umx1re", inherit: "_14umx1rf" }, weight: { light: "_14umx1rg", regular: "_14umx1rh", medium: "_14umx1ri", semiBold: "_14umx1rj", bold: "_14umx1rk" }, variant: { red: "_14umx1rl", subtle: "_14umx1rm", "default": "_14umx1rn", contrast: "_14umx1ro", inherit: "_14umx1rp", invalid: "_14umx1rq" }, gradient: { true: "_14umx1rr" }, transform: { uppercase: "_14umx1rs", capitalize: "_14umx1rt", capitalizeWords: "_14umx1ru" }, noWrap: { true: "_14umx1rv" } }, defaultVariants: { size: "0", variant: "subtle", transform: "capitalize" }, compoundVariants: [] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Label.vanilla.css.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Label.vanilla.css.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* empty css */
|
|
1
2
|
/* empty css */
|
|
2
3
|
import { createRuntimeFn } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
3
4
|
var labelRecipe = createRuntimeFn({ defaultClassName: "_14umx1r1 _14umx1r0", variantClassNames: { size: { "0": "_14umx1r2", "1": "_14umx1r3", "2": "_14umx1r4", "3": "_14umx1r5", "4": "_14umx1r6", "5": "_14umx1r7", "6": "_14umx1r8", "7": "_14umx1r9", "8": "_14umx1ra", "9": "_14umx1rb", "10": "_14umx1rc", "11": "_14umx1rd", "12": "_14umx1re", inherit: "_14umx1rf" }, weight: { light: "_14umx1rg", regular: "_14umx1rh", medium: "_14umx1ri", semiBold: "_14umx1rj", bold: "_14umx1rk" }, variant: { red: "_14umx1rl", subtle: "_14umx1rm", "default": "_14umx1rn", contrast: "_14umx1ro", inherit: "_14umx1rp", invalid: "_14umx1rq" }, gradient: { true: "_14umx1rr" }, transform: { uppercase: "_14umx1rs", capitalize: "_14umx1rt", capitalizeWords: "_14umx1ru" }, noWrap: { true: "_14umx1rv" } }, defaultVariants: { size: "0", variant: "subtle", transform: "capitalize" }, compoundVariants: [] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Label.vanilla.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Label.vanilla.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/faency.css
CHANGED
|
@@ -6072,24 +6072,27 @@
|
|
|
6072
6072
|
padding-bottom: var(--_17h2n96a0);
|
|
6073
6073
|
}
|
|
6074
6074
|
._1krwcuz4 {
|
|
6075
|
+
padding-top: var(--_17h2n96a0);
|
|
6076
|
+
}
|
|
6077
|
+
._1krwcuz5 {
|
|
6075
6078
|
position: absolute;
|
|
6076
6079
|
z-index: 1;
|
|
6077
6080
|
top: var(--_17h2n969v);
|
|
6078
6081
|
right: var(--_17h2n969w);
|
|
6079
6082
|
}
|
|
6080
|
-
.
|
|
6083
|
+
._1krwcuz6 {
|
|
6081
6084
|
position: absolute;
|
|
6082
6085
|
z-index: 1;
|
|
6083
6086
|
top: var(--_17h2n969v);
|
|
6084
6087
|
left: var(--_17h2n969w);
|
|
6085
6088
|
}
|
|
6086
|
-
.
|
|
6089
|
+
._1krwcuz7 {
|
|
6087
6090
|
position: absolute;
|
|
6088
6091
|
z-index: 1;
|
|
6089
6092
|
bottom: var(--_17h2n969v);
|
|
6090
6093
|
right: var(--_17h2n969w);
|
|
6091
6094
|
}
|
|
6092
|
-
.
|
|
6095
|
+
._1krwcuz8 {
|
|
6093
6096
|
position: absolute;
|
|
6094
6097
|
z-index: 1;
|
|
6095
6098
|
bottom: var(--_17h2n969v);
|