UNPKG

@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.

3 lines (2 loc) 2.09 kB
"use client"; import{jsxs as o,Fragment as e,jsx as r}from"react/jsx-runtime";import{useState as a}from"react";import t from"@mui/material/IconButton";import i from"@mui/material/Tooltip";import l from"@mui/material/SvgIcon";import m from"@mui/material/Box";import n from"@mui/material/Chip";import c from"@mui/icons-material/OpenInFull";import d from"@mui/icons-material/ContentCopy";import p from"@mui/material/Snackbar";import{styles as s}from"./CodeToolBar.style.js";import{SupportCodeLanguages as u}from"../types.js";const b=o=>r(i,{slotProps:{popper:{sx:{zIndex:o=>o.zIndex.appBar-1}}},...o}),h=i=>{const{codeOpen:h,language:C="tsx",showPreview:x,code:f,onCodeOpenChange:y,onOpenInSandbox:g,t:v}=i,[L,z]=a(!1),[w,B]=a(void 0),I=v(h?"hideFullSource":"showFullSource"),S=u[C];return o(e,{children:[o(m,{className:"NexusCodeToolBar-root",sx:s.root,"aria-label":"codeToolbarLabel","data-testid":"Code-toolbar",children:[r(n,{label:S,color:"primary"}),o(m,{children:[r(b,{title:v("codesandbox"),placement:"bottom",children:r(t,{"aria-label":v("codesandbox"),size:"large",onClick:g,color:"primary","data-testid":"Code-toolbar-codesandbox",children:r(l,{viewBox:"0 0 1024 1024",children:r("path",{d:"M755 140.3l0.5-0.3h0.3L512 0 268.3 140h-0.3l0.8 0.4L68.6 256v512L512 1024l443.4-256V256L755 140.3z m-30 506.4v171.2L548 920.1V534.7L883.4 341v215.7l-158.4 90z m-584.4-90.6V340.8L476 534.4v385.7L300 818.5V646.7l-159.4-90.6zM511.7 280l171.1-98.3 166.3 96-336.9 194.5-337-194.6 165.7-95.7L511.7 280z"})})})}),r(b,{title:v("copySource"),placement:"bottom",children:r(t,{size:"large",color:"primary",onClick:async()=>{try{await navigator.clipboard.writeText(f),B(v("sourceCopied")),z(!0)}catch(o){}},"data-testid":"Code-toolbar-copy","aria-label":"Copy",children:r(d,{})})}),r(b,{title:I,placement:"bottom",children:r("span",{role:"navigation",children:r(t,{size:"large",onClick:()=>{y()},disabled:!x,color:"primary","data-testid":"Code-toolbar-expand","aria-label":I,children:r(c,{})})})})]})]}),r(p,{open:L,autoHideDuration:3e3,onClose:()=>{z(!1)},message:w})]})};export{h as CodeToolBar};