@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.88 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});const t=/^-?\d+(\s\d+)?\/?\d*\.?\d*|\.\d+|\d+\s?$/,e=t=>{const e=t.split(" "),r=e[e.length-1].split("/");return r.length>1&&r[0].length>0&&r[1].length>0},r=t=>{const r=e(t)?i(t):Number(t);return Math.log2(r)%1==0},s=t=>{const r=e(t)?i(t):Number(t),s=r-Math.floor(r);return Math.log2(s)%1==0},n=t=>{const e=(t,r)=>r?e(r,t%r):t,r=10**(t.toString().length-2),s=t*r,n=e(s,r);return`${s/n}/${r/n}`},i=t=>{const e=t.replace("-","").split(" "),r=e[e.length-1].split("/"),s=(e.length>1?Number(e[0]):0)+Number(r[0])/Number(r[1]);return t.startsWith("-")?-s:s},o=e=>{if(!e)return{value:"",unit:""};const r=String(e),s=r.match(t);if(s){const t=s[0],e=r.replace(t,"").trim();return e&&(e.startsWith("/")||e.startsWith(".")||e.startsWith(" "))?{value:t||"0",unit:String(e).replace("/","").replace(".","").trim()}:{value:t,unit:e}}return{value:"",unit:e.length>0?e.trim():""}},a=t=>{if(t&&t.length>0){const e=t.charAt(0);if(Number.isNaN(Number(e))&&"-"!==e&&"."!==e)return!1}const{value:r,unit:s}=o(t);return e(r)?{value:i(r),unit:s}:!Number.isNaN(Number(r))&&{value:Number(r),unit:s}},u=a,l=r,c=s;exports.NUMBER_REGEX=t,exports.decimalToFraction=n,exports.decimalToMixedNumber=t=>{const e=Math.floor(t),r=n(t-e);return e>0?`${e} ${r}`:r},exports.fractionToDecimal=i,exports.getValidUnit=(t,e)=>!(!t||!e.has(t.toLowerCase()))&&e.get(t.toLowerCase()),exports.handleUnitValue=a,exports.isBaseTwoFraction=l,exports.isBinaryFraction=r,exports.isFraction=e,exports.isMixedNumberBasedOnBinaryFraction=s,exports.isMixedNumberWithBaseTwoFraction=c,exports.isNumber=e=>t.test(e),exports.splitUnitValue=o,exports.stringToUnitValue=u,exports.unitDisplayStringMapGenerator=t=>{const e=new Map;return Object.entries(t).forEach((([,t])=>{const{type:r,secondaryDisplayStrings:s}=t;e.set(r,r),s&&s.forEach((t=>{e.set(t.toLowerCase(),r)}))})),e};