@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) • 2.47 kB
JavaScript
import{isValidElement as t}from"react";import{highlight as e}from"../constants.js";const n=t=>`${t?.firstName||""} ${t?.lastName||""}`.trim(),r=(t,e)=>[t?.trim()||"",e?.trim()||""].map((t=>t.charAt(0))).join("").toUpperCase(),o=t=>r(t.firstName,t.lastName),i=(t,n)=>{const r=Object.keys(e);let o=0;return 1===n.length?o=n.charCodeAt(0)%r.length:2===n.length&&(o=(n.charCodeAt(0)+n.charCodeAt(1))%r.length),e[r[o]]},a=(t,e)=>i(0,o(e)),s=t=>t<1048576?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`;function l(t){if(/^(#|rgb\(|rgba\(|hsl\(|hsla\()/.test(t))return t;if("undefined"==typeof document)return"#000000";const e=document.createElement("canvas").getContext("2d");return e?(e.fillStyle=t,e.fillStyle.toString()):"#000000"}const h=(t,e)=>{const n=e.split(".");return 1===n.length?/^(#|rgb\(|rgba\(|hsl\(|hsla\()/.test(e)?e:l(e):t.palette?.[n[0]]?.[n[1]]},c=(t,e,n)=>n||(e?t.palette.getContrastText(h(t,e)??t.vars.palette.grey[50]):"common.white"),d=(t,e=!1,n=1)=>{const r=e?1e3:1024;if(Math.abs(t)<r)return`${t} B`;const o=e?["kB","MB","GB","TB","PB","EB","ZB","YB"]:["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];let i=-1;const a=10**n;do{t/=r,i+=1}while(Math.round(Math.abs(t)*a)/a>=r&&i<o.length-1);return`${t.toFixed(n)} ${o[i]}`};function g(e){return t(e)||"boolean"==typeof e||null==e||"string"==typeof e||"number"==typeof e}const p=(t,e="_blank")=>{t&&(window.hxgnapi&&window.hxgnapi.openLink?window.hxgnapi.openLink(t):(window.hxgnapi&&console.warn("Please update your CEF browser 'Hexagon.Framework.WebBrowser' to a version after '2023.0.9000.9032'. The version you are currently using does not support opening links in the system default browser. "),window.open(t,e)))},u=(t,e="itemId",n="children")=>{const r=[],o=t=>{t.forEach((t=>{const i=t[e];"string"==typeof i&&r.push(i);const a=t[n];Array.isArray(a)&&o(a)}))};return Array.isArray(t)&&o(t),r},f=t=>{let e="left";if(t&&window){const n=t.getBoundingClientRect().left;window.innerWidth<=600&&(e=n>window.innerWidth/2?"right":"left"),e=window.innerWidth-n<=300?"right":"left"}return{anchorOrigin:{vertical:"bottom",horizontal:e},transformOrigin:{vertical:"top",horizontal:e}}};export{u as flattenTreeIds,c as getContrastTextColor,s as getFileSize,n as getFullName,i as getHighlightColor,a as getHighlightColorByUser,d as getHumanFileSize,r as getInitials,o as getInitialsByUser,f as getMenuOrigin,g as isReactNode,p as openLink,h as standardizeColorToHex,l as standardizeNamedColorToHex};