@nexusui/components
Version:
These are custom components specially-developed for NexusUI applications. They will make your life easier by giving you out-of-the-box implementations for various high-level UI elements that you can drop directly into your application.
2 lines (1 loc) • 1.06 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("react"),r=require("@mui/material/Box"),n=require("../locales/index.js"),t=require("./locale.json.js"),s=require("./CodeSnippet.style.js"),a=require("./components/CodeToolBar/CodeToolBar.js"),i=require("./components/CodeViewer/CodeViewer.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=d(r);exports.CodeSnippetComponent=r=>{const{code:d,previewCode:l,language:p="tsx",showLineNumbers:c,showCopyInCode:C=!1,onOpenInSandbox:x,sx:j,...m}=r,[w,b]=o.useState(!1),q=!!l,y=!w&&q?l:d.replace(/\n$/,""),f=n.useTranslate(t.default);return e.jsxs(u.default,{className:"NexusCodeSnippet-root","aria-label":"codeSnippetLabel","data-testid":"Code-snippet-root",sx:[s.styles.root,...Array.isArray(j)?j:[j]],...m,children:[e.jsx(a.CodeToolBar,{code:y,codeOpen:w,onCodeOpenChange:()=>{b((e=>!e))},onOpenInSandbox:x,showPreview:q,language:p,t:f}),e.jsx(i.CodeViewer,{code:y,language:p,copyButtonHidden:!C,showLineNumbers:c})]})};