@cryptlex/web-components 6.6.104 → 6.6.106
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/code-block.d.ts +3 -2
- package/dist/components/code-block.js +1 -1
- package/dist/components/code-block.js.map +1 -1
- package/dist/components/copy-button.d.ts +1 -1
- package/dist/components/copy-button.js +1 -1
- package/dist/components/copy-button.js.map +1 -1
- package/dist/utilities/highlight-code.js +1 -1
- package/dist/utilities/highlight-code.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
export interface CodeBlockProps extends React.ComponentProps<'div'> {
|
|
3
3
|
code: string;
|
|
4
|
-
fileName?: string;
|
|
4
|
+
fileName?: string | React.ReactNode;
|
|
5
5
|
copyText?: string;
|
|
6
|
+
variant?: 'inline' | 'block';
|
|
6
7
|
}
|
|
7
|
-
export declare function CodeBlock({ code, fileName, copyText, className, ...props }: CodeBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function CodeBlock({ code, fileName, copyText, variant, className, ...props }: CodeBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as i,jsx as e}from"react/jsx-runtime";import{classNames as l}from"../utilities/theme.js";import{CopyButton as m}from"./copy-button.js";import"clsx";import"react";import"./button.js";import"class-variance-authority";import"react-aria-components";import"./loader.js";import"./icons.js";import"@icons-pack/react-simple-icons";import"./toast.js";import"react-dom";import"./alert.js";function j({code:n,fileName:t,copyText:o,variant:r="block",className:s,...a}){const d=!!t||r==="block"&&!!o;return i("div",{className:l("rounded-md border border-border bg-elevation-1 text-sm max-h-[90vh]",s),...a,children:[d&&i("div",{className:l("flex justify-between text-muted body-sm p-icon border-b border-border"),children:[e("div",{className:"min-w-0 h-full flex items-center",children:t}),r==="block"&&o&&e("div",{className:"flex items-start",children:e(m,{label:null,textToCopy:o,variant:"ghost",size:"icon-sm","aria-label":"Copy code"})})]}),i("div",{className:"relative flex items-center",children:[r==="inline"&&o&&e("div",{className:"absolute top-0 right-0 rounded-md flex items-start pt-icon pl-14 pr-icon bg-gradient-to-r from-transparent via-elevation-1 to-elevation-1",children:e(m,{label:null,textToCopy:o,variant:"ghost",size:"icon-sm","aria-label":"Copy code"})}),e("pre",{className:l("flex p-icon overflow-auto w-full max-h-96",r==="inline"&&o&&"pr-20"),children:e("code",{dangerouslySetInnerHTML:{__html:n}})})]})]})}export{j as CodeBlock};
|
|
2
2
|
//# sourceMappingURL=code-block.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-block.js","sources":["../../lib/components/code-block.tsx"],"sourcesContent":["import React from 'react';\nimport { classNames } from '../utilities/theme';\nimport { CopyButton } from './copy-button';\n\nexport interface CodeBlockProps extends React.ComponentProps<'div'> {\n code: string;\n fileName?: string;\n copyText?: string;\n}\n\nexport function CodeBlock({ code, fileName, copyText, className, ...props }: CodeBlockProps) {\n return (\n <div\n className={classNames('rounded-md border border-border bg-elevation-1
|
|
1
|
+
{"version":3,"file":"code-block.js","sources":["../../lib/components/code-block.tsx"],"sourcesContent":["import React from 'react';\nimport { classNames } from '../utilities/theme';\nimport { CopyButton } from './copy-button';\n\nexport interface CodeBlockProps extends React.ComponentProps<'div'> {\n code: string;\n fileName?: string | React.ReactNode;\n copyText?: string;\n variant?: 'inline' | 'block';\n}\n\nexport function CodeBlock({ code, fileName, copyText, variant = 'block', className, ...props }: CodeBlockProps) {\n const showHeader = Boolean(fileName) || (variant === 'block' && Boolean(copyText));\n\n return (\n <div\n className={classNames('rounded-md border border-border bg-elevation-1 text-sm max-h-[90vh]', className)}\n {...props}\n >\n {showHeader && (\n <div className={classNames('flex justify-between text-muted body-sm p-icon border-b border-border')}>\n <div className=\"min-w-0 h-full flex items-center\">{fileName}</div>\n {variant === 'block' && copyText && (\n <div className=\"flex items-start\">\n <CopyButton\n label={null}\n textToCopy={copyText}\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label=\"Copy code\"\n />\n </div>\n )}\n </div>\n )}\n\n <div className=\"relative flex items-center\">\n {variant === 'inline' && copyText && (\n <div className=\"absolute top-0 right-0 rounded-md flex items-start pt-icon pl-14 pr-icon bg-gradient-to-r from-transparent via-elevation-1 to-elevation-1\">\n <CopyButton\n label={null}\n textToCopy={copyText}\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label=\"Copy code\"\n />\n </div>\n )}\n <pre\n className={classNames(\n 'flex p-icon overflow-auto w-full max-h-96',\n variant === 'inline' && copyText && 'pr-20'\n )}\n >\n <code dangerouslySetInnerHTML={{ __html: code }} />\n </pre>\n </div>\n </div>\n );\n}\n"],"names":["CodeBlock","code","fileName","copyText","variant","className","props","showHeader","jsxs","classNames","jsx","CopyButton"],"mappings":"uYAWO,SAASA,EAAU,CAAE,KAAAC,EAAM,SAAAC,EAAU,SAAAC,EAAU,QAAAC,EAAU,QAAS,UAAAC,EAAW,GAAGC,GAAyB,CAC5G,MAAMC,EAAa,EAAQL,GAAcE,IAAY,SAAW,EAAQD,EAExE,OACIK,EAAC,MAAA,CACG,UAAWC,EAAW,sEAAuEJ,CAAS,EACrG,GAAGC,EAEH,SAAA,CAAAC,GACGC,EAAC,MAAA,CAAI,UAAWC,EAAW,uEAAuE,EAC9F,SAAA,CAAAC,EAAC,MAAA,CAAI,UAAU,mCAAoC,SAAAR,EAAS,EAC3DE,IAAY,SAAWD,GACpBO,EAAC,MAAA,CAAI,UAAU,mBACX,SAAAA,EAACC,EAAA,CACG,MAAO,KACP,WAAYR,EACZ,QAAQ,QACR,KAAK,UACL,aAAW,WAAA,CAAA,CACf,CACJ,CAAA,EAER,EAGJK,EAAC,MAAA,CAAI,UAAU,6BACV,SAAA,CAAAJ,IAAY,UAAYD,GACrBO,EAAC,MAAA,CAAI,UAAU,4IACX,SAAAA,EAACC,EAAA,CACG,MAAO,KACP,WAAYR,EACZ,QAAQ,QACR,KAAK,UACL,aAAW,WAAA,CAAA,EAEnB,EAEJO,EAAC,MAAA,CACG,UAAWD,EACP,4CACAL,IAAY,UAAYD,GAAY,OAAA,EAGxC,WAAC,OAAA,CAAK,wBAAyB,CAAE,OAAQF,EAAK,CAAG,CAAA,CAAA,CACrD,CAAA,CACJ,CAAA,CAAA,CAAA,CAGZ"}
|
|
@@ -4,4 +4,4 @@ export type CopyButtonProps = Omit<ButtonProps, 'children' | 'ref' | 'active'> &
|
|
|
4
4
|
label: ReactNode;
|
|
5
5
|
textToCopy: string | number | Record<string, unknown>;
|
|
6
6
|
};
|
|
7
|
-
export declare function CopyButton({ label, textToCopy, ...props }: CopyButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function CopyButton({ label, textToCopy, className, ...props }: CopyButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsxs as p,jsx as
|
|
1
|
+
"use client";import{jsxs as p,jsx as o}from"react/jsx-runtime";import{useState as n}from"react";import{Button as l}from"./button.js";import{IcCheck as f,IcCopy as u}from"./icons.js";import{toast as e}from"./toast.js";import{classNames as d}from"../utilities/theme.js";import"class-variance-authority";import"react-aria-components";import"./loader.js";import"@icons-pack/react-simple-icons";import"react-dom";import"./alert.js";import"clsx";function k({label:i,textToCopy:t,className:s,...a}){const[c,r]=n(!1);return p(l,{...a,onPress:async()=>{if(t)try{const m=typeof t=="object"?JSON.stringify(t):String(t);await navigator.clipboard.writeText(m),e({title:"Copied to clipboard",variant:"success"}),r(!0),setTimeout(()=>{r(!1)},3e3)}catch{e({title:"Failed to copy to clipboard",variant:"destructive"})}},className:d("gap-2",s),children:[c?o(f,{className:"text-success"}):o(u,{}),i]})}export{k as CopyButton};
|
|
2
2
|
//# sourceMappingURL=copy-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-button.js","sources":["../../lib/components/copy-button.tsx"],"sourcesContent":["'use client';\n\nimport { useState, type ReactNode } from 'react';\nimport { Button, type ButtonProps } from './button';\nimport { IcCheck, IcCopy } from './icons';\nimport { toast } from './toast';\n\nexport type CopyButtonProps = Omit<ButtonProps, 'children' | 'ref' | 'active'> & {\n label: ReactNode;\n textToCopy: string | number | Record<string, unknown>;\n};\n\nexport function CopyButton({ label, textToCopy, ...props }: CopyButtonProps) {\n const [isCopied, setIsCopied] = useState(false);\n const handlePress = async () => {\n if (!textToCopy) return;\n try {\n const text = typeof textToCopy === 'object' ? JSON.stringify(textToCopy) : String(textToCopy);\n await navigator.clipboard.writeText(text);\n toast({\n title: 'Copied to clipboard',\n variant: 'success',\n });\n setIsCopied(true);\n setTimeout(() => {\n setIsCopied(false);\n }, 3000);\n } catch {\n toast({\n title: 'Failed to copy to clipboard',\n variant: 'destructive',\n });\n }\n };\n\n return (\n <Button {...props} onPress={handlePress} className
|
|
1
|
+
{"version":3,"file":"copy-button.js","sources":["../../lib/components/copy-button.tsx"],"sourcesContent":["'use client';\n\nimport { useState, type ReactNode } from 'react';\nimport { Button, type ButtonProps } from './button';\nimport { IcCheck, IcCopy } from './icons';\nimport { toast } from './toast';\nimport { classNames } from '../utilities/theme';\n\nexport type CopyButtonProps = Omit<ButtonProps, 'children' | 'ref' | 'active'> & {\n label: ReactNode;\n textToCopy: string | number | Record<string, unknown>;\n};\n\nexport function CopyButton({ label, textToCopy, className, ...props }: CopyButtonProps) {\n const [isCopied, setIsCopied] = useState(false);\n const handlePress = async () => {\n if (!textToCopy) return;\n try {\n const text = typeof textToCopy === 'object' ? JSON.stringify(textToCopy) : String(textToCopy);\n await navigator.clipboard.writeText(text);\n toast({\n title: 'Copied to clipboard',\n variant: 'success',\n });\n setIsCopied(true);\n setTimeout(() => {\n setIsCopied(false);\n }, 3000);\n } catch {\n toast({\n title: 'Failed to copy to clipboard',\n variant: 'destructive',\n });\n }\n };\n\n return (\n <Button {...props} onPress={handlePress} className={classNames('gap-2', className)}>\n {isCopied ? <IcCheck className=\"text-success\" /> : <IcCopy />}\n {label}\n </Button>\n );\n}\n"],"names":["CopyButton","label","textToCopy","className","props","isCopied","setIsCopied","useState","jsxs","Button","text","toast","classNames","IcCheck","IcCopy"],"mappings":"wbAaO,SAASA,EAAW,CAAE,MAAAC,EAAO,WAAAC,EAAY,UAAAC,EAAW,GAAGC,GAA0B,CACpF,KAAM,CAACC,EAAUC,CAAW,EAAIC,EAAS,EAAK,EAsB9C,OACIC,EAACC,EAAA,CAAQ,GAAGL,EAAO,QAtBH,SAAY,CAC5B,GAAKF,EACL,GAAI,CACA,MAAMQ,EAAO,OAAOR,GAAe,SAAW,KAAK,UAAUA,CAAU,EAAI,OAAOA,CAAU,EAC5F,MAAM,UAAU,UAAU,UAAUQ,CAAI,EACxCC,EAAM,CACF,MAAO,sBACP,QAAS,SAAA,CACZ,EACDL,EAAY,EAAI,EAChB,WAAW,IAAM,CACbA,EAAY,EAAK,CACrB,EAAG,GAAI,CACX,MAAQ,CACJK,EAAM,CACF,MAAO,8BACP,QAAS,aAAA,CACZ,CACL,CACJ,EAG6C,UAAWC,EAAW,QAAST,CAAS,EAC5E,SAAA,CAAAE,IAAYQ,EAAA,CAAQ,UAAU,cAAA,CAAe,IAAMC,EAAA,EAAO,EAC1Db,CAAA,EACL,CAER"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{transformerColorizedBrackets as
|
|
1
|
+
import{transformerColorizedBrackets as e}from"@shikijs/colorized-brackets";import{codeToHtml as t}from"shiki";import{shikiTheme as i}from"./shiki.js";async function f({code:r,lang:o}){return t(r,{lang:o,theme:i,structure:"inline",transformers:[e()]})}export{f as highlightCode};
|
|
2
2
|
//# sourceMappingURL=highlight-code.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight-code.js","sources":["../../lib/utilities/highlight-code.ts"],"sourcesContent":["import { transformerColorizedBrackets } from '@shikijs/colorized-brackets';\nimport { codeToHtml, type BundledLanguage } from 'shiki';\nimport { shikiTheme } from './shiki';\n\nexport interface HighlightOptions {\n code: string;\n lang: BundledLanguage;\n}\n\nexport async function highlightCode({ code, lang }: HighlightOptions) {\n
|
|
1
|
+
{"version":3,"file":"highlight-code.js","sources":["../../lib/utilities/highlight-code.ts"],"sourcesContent":["import { transformerColorizedBrackets } from '@shikijs/colorized-brackets';\nimport { codeToHtml, type BundledLanguage } from 'shiki';\nimport { shikiTheme } from './shiki';\n\nexport interface HighlightOptions {\n code: string;\n lang: BundledLanguage;\n}\n\nexport async function highlightCode({ code, lang }: HighlightOptions) {\n // structure: 'inline' emits only the highlighted spans (line breaks as <br>), no\n // wrapping <pre>/<code>. CodeBlock provides its own <pre><code>, so a 'classic'\n // structure here would nest a second <pre> inside it and double up padding.\n return codeToHtml(code, {\n lang,\n theme: shikiTheme,\n structure: 'inline',\n transformers: [transformerColorizedBrackets()],\n });\n}\n\nexport type { BundledLanguage } from 'shiki';\n"],"names":["highlightCode","code","lang","codeToHtml","shikiTheme","transformerColorizedBrackets"],"mappings":"sJASA,eAAsBA,EAAc,CAAE,KAAAC,EAAM,KAAAC,GAA0B,CAIlE,OAAOC,EAAWF,EAAM,CACpB,KAAAC,EACA,MAAOE,EACP,UAAW,SACX,aAAc,CAACC,EAAA,CAA8B,CAAA,CAChD,CACL"}
|