@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) • 753 B
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(require("@mui/material/Box"));exports.ExponentFormatterComponent=n=>{const{number:o,precision:i}=n,[c,u]=t.useState({coefficient:0,exponent:0});return t.useMemo((()=>{try{const e=((e,t)=>e.toExponential(t).split("e").map((e=>Number(e))))(o,i);u({coefficient:e[0],exponent:e[1]})}catch(e){console.error("Error in converting number to scientific notation",e)}}),[o,i]),0===o?e.jsx(r.default,{"data-testid":"numInSciNot",children:"0"}):e.jsxs(r.default,{"data-testid":"numInSciNot",children:[c.coefficient," x 10",e.jsx("sup",{children:c.exponent})]})};