@tuwaio/nova-core 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/chunk-LLVSKNQR.cjs +1 -0
- package/dist/chunk-VLQ5TKDD.js +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +3 -195
- package/dist/index.d.ts +3 -195
- package/dist/index.js +3 -3
- package/dist/utils.cjs +1 -0
- package/dist/utils.d.cts +196 -0
- package/dist/utils.d.ts +196 -0
- package/dist/utils.js +1 -0
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
- **Theme variables:** `dist/index.css` defines the `--tuwa-*` CSS variables (colors, borders, rounded corners, status colors) for the light theme on `:root` and for the dark theme on `.dark`, the Geist Mono font (embedded, no font request), the Tailwind CSS v4 utilities of the package, prefixed with `novacore:`, and a few global rules: `scrollbar-gutter: stable` on `html`, no page scrolling while a Nova dialog is open, and no padding and background on `react-toastify` toasts (`.Toastify__toast`), which the Nova toasts draw themselves. Every Nova component reads these variables, so overriding them restyles the whole kit.
|
|
13
13
|
- **Dialog:** `Dialog`, `DialogTrigger`, `DialogPortal`, `DialogClose` are the Radix UI primitives; `DialogOverlay`, `DialogContent`, `DialogHeader`, `DialogFooter`, `DialogTitle` and `DialogDescription` add the Nova styles and `framer-motion` animations. The connect and transaction modals of the L7 packages use them.
|
|
14
14
|
- **Icons:** `NetworkIcon` and `WalletIcon` render icons from `@web3icons/react`, loaded on demand one icon at a time (only the network and wallet metadata of `@web3icons/common` is bundled, not the token list, and only the about 300 icons that networks and wallets use can be loaded, so the bundler of your app does not build a chunk for each of the 2,000 token icons), fetch missing ones from the web3icons repository on GitHub (`GithubFallbackIcon`) and show `FallbackIcon` otherwise; `NetworkIcon` recolors the icons of testnets and of the Solana devnet and testnet with `--tuwa-testnet-icons`. The icon loader is a separate client module (`'use client'`), so server code (React Server Components, route handlers) that imports `cn`, `getChainName` or other helpers does not compile the icons. `SvgToImg` and `SvgImg` render an SVG as an `<img>`, so identical icons on one page do not share SVG `id`s. `CloseIcon`, `ChevronArrowWithAnim`, `ToastCloseButton` and `StarsBackground` are small shared parts.
|
|
15
|
-
- **Hooks and helpers:** `useCopyToClipboard` and `useMediaQuery`; `cn` (`clsx` + `tailwind-merge`), `deepMerge`, `getChainName`, `isSolanaDev`, `isTouchDevice`, `textCenterEllipsis`, the SVG helpers used by the icons and `standardButtonClasses`.
|
|
15
|
+
- **Hooks and helpers:** `useCopyToClipboard` and `useMediaQuery`; `cn` (`clsx` + `tailwind-merge`), `deepMerge`, `getChainName`, `isSolanaDev`, `isTouchDevice`, `textCenterEllipsis`, the SVG helpers used by the icons and `standardButtonClasses`. The helpers are also exported by `@tuwaio/nova-core/utils`, which imports no React, no component and no icon: use it in code that needs only the helpers (server code, libraries such as a site layout), so its bundler compiles none of the icons.
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),networks=require('@web3icons/common/metadata/networks'),orbitCore=require('@tuwaio/orbit-core');var h="novacore:cursor-pointer novacore:rounded-[var(--tuwa-rounded-corners)] novacore:bg-[var(--tuwa-standart-button-bg)] novacore:px-3 novacore:py-2 novacore:flex novacore:items-center novacore:gap-1 novacore:text-sm novacore:font-mono novacore:font-semibold novacore:text-[var(--tuwa-text-primary)] novacore:transition-colors novacore:hover:bg-[var(--tuwa-standart-button-hover)] novacore:disabled:cursor-not-allowed novacore:disabled:opacity-50 novacore:min-h-[36px]";function T(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var i=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function v(e,r){let t={...e};return i(e)&&i(r)&&Object.keys(r).forEach(n=>{let o=e[n],s=r[n];i(o)&&i(s)?t[n]=v(o,s):t[n]=s;}),t}function c(e){if(typeof e!="string")return;let r=e.indexOf(":");if(r<0||e.slice(0,r).toLowerCase()!=="solana")return;let t=e.slice(r+1),n=orbitCore.getSolanaCluster(t)??orbitCore.getSolanaCluster(t.toLowerCase());return n==="devnet"||n==="testnet"?n:void 0}var l="Unknown";function w(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function V(e){let r={name:l,id:l.toLowerCase(),filePath:l.toLowerCase(),chainId:e};if(typeof e=="number"){let a=networks.networks.find(m=>m.chainId===e);return a?{name:a.name,id:a.id,filePath:a.filePath?.split(":")[1],chainId:e}:r}let[t,n]=e?e.split(":"):[e],o=networks.networks.find(a=>a.id===t);if(!o)return r;let s=n?c(e):void 0;return {name:s?`${o.name} ${w(s)}`:o.name,id:o.id,filePath:o.filePath?.split(":")[1],chainId:e}}function R(e){return c(e)!==void 0}function z(e=1200){if(typeof window>"u")return false;let r="ontouchstart"in window,t=navigator.maxTouchPoints>0,n=false;window.matchMedia&&(n=window.matchMedia("(pointer: coarse)").matches);let o=r||t||n,s=window.innerWidth<=e;return o&&s}function x(e){if(!e.startsWith("var("))return e;let r=e.match(/var\(\s*(--[\w-]+)/);if(!r)return e;let t=r[1];return getComputedStyle(document.documentElement).getPropertyValue(t).trim()||e}function b(e,r){let t=x(r),o=new DOMParser().parseFromString(e,"image/svg+xml");if(o.querySelector("parsererror"))return console.warn("SVG parse error, returning original"),e;let u=o.querySelector("path");return u&&u.setAttribute("fill",t),new XMLSerializer().serializeToString(o.documentElement)}function A(e,r){let t=e;return r&&(t=b(t,r)),`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(t)))}`}var U=e=>`${e.replace(/\s+/g,"-").toLowerCase()}.svg`;function F(e,r,t){if(!e)return "";if(e.length<=r+t)return e;let n=e.slice(0,r),o=e.slice(e.length-t);return `${n}...${o}`}exports.a=h;exports.b=T;exports.c=v;exports.d=V;exports.e=R;exports.f=z;exports.g=x;exports.h=b;exports.i=A;exports.j=U;exports.k=F;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {networks}from'@web3icons/common/metadata/networks';import {getSolanaCluster}from'@tuwaio/orbit-core';var h="novacore:cursor-pointer novacore:rounded-[var(--tuwa-rounded-corners)] novacore:bg-[var(--tuwa-standart-button-bg)] novacore:px-3 novacore:py-2 novacore:flex novacore:items-center novacore:gap-1 novacore:text-sm novacore:font-mono novacore:font-semibold novacore:text-[var(--tuwa-text-primary)] novacore:transition-colors novacore:hover:bg-[var(--tuwa-standart-button-hover)] novacore:disabled:cursor-not-allowed novacore:disabled:opacity-50 novacore:min-h-[36px]";function T(...e){return twMerge(clsx(e))}var i=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function v(e,r){let t={...e};return i(e)&&i(r)&&Object.keys(r).forEach(n=>{let o=e[n],s=r[n];i(o)&&i(s)?t[n]=v(o,s):t[n]=s;}),t}function c(e){if(typeof e!="string")return;let r=e.indexOf(":");if(r<0||e.slice(0,r).toLowerCase()!=="solana")return;let t=e.slice(r+1),n=getSolanaCluster(t)??getSolanaCluster(t.toLowerCase());return n==="devnet"||n==="testnet"?n:void 0}var l="Unknown";function w(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function V(e){let r={name:l,id:l.toLowerCase(),filePath:l.toLowerCase(),chainId:e};if(typeof e=="number"){let a=networks.find(m=>m.chainId===e);return a?{name:a.name,id:a.id,filePath:a.filePath?.split(":")[1],chainId:e}:r}let[t,n]=e?e.split(":"):[e],o=networks.find(a=>a.id===t);if(!o)return r;let s=n?c(e):void 0;return {name:s?`${o.name} ${w(s)}`:o.name,id:o.id,filePath:o.filePath?.split(":")[1],chainId:e}}function R(e){return c(e)!==void 0}function z(e=1200){if(typeof window>"u")return false;let r="ontouchstart"in window,t=navigator.maxTouchPoints>0,n=false;window.matchMedia&&(n=window.matchMedia("(pointer: coarse)").matches);let o=r||t||n,s=window.innerWidth<=e;return o&&s}function x(e){if(!e.startsWith("var("))return e;let r=e.match(/var\(\s*(--[\w-]+)/);if(!r)return e;let t=r[1];return getComputedStyle(document.documentElement).getPropertyValue(t).trim()||e}function b(e,r){let t=x(r),o=new DOMParser().parseFromString(e,"image/svg+xml");if(o.querySelector("parsererror"))return console.warn("SVG parse error, returning original"),e;let u=o.querySelector("path");return u&&u.setAttribute("fill",t),new XMLSerializer().serializeToString(o.documentElement)}function A(e,r){let t=e;return r&&(t=b(t,r)),`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(t)))}`}var U=e=>`${e.replace(/\s+/g,"-").toLowerCase()}.svg`;function F(e,r,t){if(!e)return "";if(e.length<=r+t)return e;let n=e.slice(0,r),o=e.slice(e.length-t);return `${n}...${o}`}export{h as a,T as b,v as c,V as d,R as e,z as f,x as g,b as h,A as i,U as j,F as k};
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var framerMotion=require('framer-motion'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),networks=require('@web3icons/common/metadata/networks'),orbitCore=require('@tuwaio/orbit-core'),jsxRuntime=require('react/jsx-runtime'),d=require('react'),l=require('@radix-ui/react-dialog'),web3Icons_cjs=require('./web3-icons.cjs'),wallets=require('@web3icons/common/metadata/wallets');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var d__namespace=/*#__PURE__*/_interopNamespace(d);var l__namespace=/*#__PURE__*/_interopNamespace(l);var Ue="novacore:cursor-pointer novacore:rounded-[var(--tuwa-rounded-corners)] novacore:bg-[var(--tuwa-standart-button-bg)] novacore:px-3 novacore:py-2 novacore:flex novacore:items-center novacore:gap-1 novacore:text-sm novacore:font-mono novacore:font-semibold novacore:text-[var(--tuwa-text-primary)] novacore:transition-colors novacore:hover:bg-[var(--tuwa-standart-button-hover)] novacore:disabled:cursor-not-allowed novacore:disabled:opacity-50 novacore:min-h-[36px]";function s(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var C=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function ee(e,o){let t={...e};return C(e)&&C(o)&&Object.keys(o).forEach(n=>{let r=e[n],a=o[n];C(r)&&C(a)?t[n]=ee(r,a):t[n]=a;}),t}function S(e){if(typeof e!="string")return;let o=e.indexOf(":");if(o<0||e.slice(0,o).toLowerCase()!=="solana")return;let t=e.slice(o+1),n=orbitCore.getSolanaCluster(t)??orbitCore.getSolanaCluster(t.toLowerCase());return n==="devnet"||n==="testnet"?n:void 0}var M="Unknown";function oe(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function G(e){let o={name:M,id:M.toLowerCase(),filePath:M.toLowerCase(),chainId:e};if(typeof e=="number"){let i=networks.networks.find(c=>c.chainId===e);return i?{name:i.name,id:i.id,filePath:i.filePath?.split(":")[1],chainId:e}:o}let[t,n]=e?e.split(":"):[e],r=networks.networks.find(i=>i.id===t);if(!r)return o;let a=n?S(e):void 0;return {name:a?`${r.name} ${oe(a)}`:r.name,id:r.id,filePath:r.filePath?.split(":")[1],chainId:e}}function $(e){return S(e)!==void 0}function B(e=1200){if(typeof window>"u")return false;let o="ontouchstart"in window,t=navigator.maxTouchPoints>0,n=false;window.matchMedia&&(n=window.matchMedia("(pointer: coarse)").matches);let r=o||t||n,a=window.innerWidth<=e;return r&&a}function te(e){if(!e.startsWith("var("))return e;let o=e.match(/var\(\s*(--[\w-]+)/);if(!o)return e;let t=o[1];return getComputedStyle(document.documentElement).getPropertyValue(t).trim()||e}function re(e,o){let t=te(o),r=new DOMParser().parseFromString(e,"image/svg+xml");if(r.querySelector("parsererror"))return console.warn("SVG parse error, returning original"),e;let m=r.querySelector("path");return m&&m.setAttribute("fill",t),new XMLSerializer().serializeToString(r.documentElement)}function N(e,o){let t=e;return o&&(t=re(t,o)),`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(t)))}`}var P=e=>`${e.replace(/\s+/g,"-").toLowerCase()}.svg`;function ao(e,o,t){if(!e)return "";if(e.length<=o+t)return e;let n=e.slice(0,o),r=e.slice(e.length-t);return `${n}...${r}`}function ho({className:e,strokeWidth:o,isOpen:t}){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:o??2,stroke:"currentColor",className:s("novacore:w-4 novacore:h-4 novacore:text-[var(--tuwa-text-secondary)]",e),children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:t&&jsxRuntime.jsx(framerMotion.motion.path,{strokeLinecap:"round",strokeLinejoin:"round",d:"m4.5 15.75 7.5-7.5 7.5 7.5",variants:{hidden:{translateY:3,scaleY:.8,opacity:0},visible:{translateY:0,scaleY:1,opacity:1}},initial:"hidden",animate:"visible",transition:{duration:.4}})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!t&&jsxRuntime.jsx(framerMotion.motion.path,{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5",className:"novacore:relative",variants:{hidden:{translateY:-3,scaleY:.8,opacity:0},visible:{translateY:0,scaleY:1,opacity:1}},initial:"hidden",animate:"visible",transition:{duration:.4}})})]})}var ae=d__namespace.forwardRef(({className:e,...o},t)=>jsxRuntime.jsxs("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s("novacore:h-5 novacore:w-5 novacore:text-[var(--tuwa-text-primary)] novacore:transition-colors",e),...o,children:[jsxRuntime.jsx("path",{d:"M18 6 6 18"}),jsxRuntime.jsx("path",{d:"m6 6 12 12"})]}));ae.displayName="CloseIcon";var se="novacore:flex novacore:items-center novacore:justify-center novacore:w-full novacore:h-full novacore:rounded-full novacore:text-[var(--tuwa-text-secondary)] novacore:bg-[var(--tuwa-bg-muted)]",f=({animate:e=false,content:o="",className:t})=>jsxRuntime.jsx("div",{className:s(se,"Nova_Web3_Icon",t,{"novacore:animate-pulse":e}),children:o});function T({src:e,alt:o,...t}){return jsxRuntime.jsx("img",{...t,src:e,alt:o??"",draggable:false,onDragStart:n=>n.preventDefault(),style:{outline:"none",pointerEvents:"none"}})}var ue="https://raw.githubusercontent.com/0xa3k5/web3icons/refs/heads/main/raw-svgs",L=new Map;function D({githubSrc:e,className:o,alt:t,firstPathFill:n,...r}){let a=`${e}|${n??""}`,m=L.get(a),[i,c]=d.useState(null),[w,b]=d.useState("idle"),h=m||i,x=m?"success":w;return d.useEffect(()=>{let v=true;return L.has(a)?void 0:((async()=>{b("loading");try{let I=await fetch(`${ue}/${e}`);if(!I.ok)throw new Error(`Failed to load icon: ${I.status}`);let Z=await I.text();if(v){let V=N(Z,n);L.set(a,V),c(V),b("success");}}catch{v&&b("error");}})(),()=>{v=false;})},[e,n,a]),x==="loading"||x==="idle"?jsxRuntime.jsx(f,{animate:true,className:o}):x==="success"&&h?jsxRuntime.jsx(T,{...r,src:h,alt:t,className:o}):jsxRuntime.jsx(f,{content:"?",className:o})}var $o=l__namespace.Root,Bo=l__namespace.Trigger,de=l__namespace.Portal,Oo=l__namespace.Close,pe={initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,transition:{duration:.2}}},fe={initial:{opacity:0,y:"100%"},animate:{opacity:1,y:"0%"},exit:{opacity:0,y:"100%",transition:{duration:.2}}},ve={initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},K=({className:e,backdropAnimation:o})=>(d__namespace.useEffect(()=>(typeof window<"u"&&window.document.body.classList.add("NovaModalOpen"),()=>{typeof window<"u"&&window.document.body.classList.remove("NovaModalOpen");}),[]),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:jsxRuntime.jsx(framerMotion.motion.div,{variants:o??ve,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"novacore:relative novacore:overflow-hidden",children:jsxRuntime.jsx("div",{className:s("novacore:fixed novacore:inset-0 novacore:z-50 novacore:bg-black/55 novacore:backdrop-blur-sm novacore:backdrop-saturate-150",e)})})}));K.displayName=l__namespace.Overlay.displayName;var ge=d__namespace.forwardRef(({className:e,children:o,modalAnimation:t,backdropAnimation:n,...r},a)=>{let[m,i]=d__namespace.useState(false);d__namespace.useEffect(()=>{i(B());},[]);let c=t??(m?fe:pe);return jsxRuntime.jsxs(de,{children:[jsxRuntime.jsx(K,{backdropAnimation:n}),jsxRuntime.jsx(l__namespace.Content,{"aria-describedby":"tuwa:modal-content",ref:a,className:s("NovaNoScrolling novacore:fixed novacore:bottom-0 novacore:left-0 novacore:p-0 novacore:sm:bottom-auto novacore:sm:left-[50%] novacore:sm:top-[50%] novacore:sm:translate-x-[-50%] novacore:sm:translate-y-[-50%] novacore:z-50 novacore:sm:p-4 novacore:outline-none",e),...r,children:jsxRuntime.jsx(framerMotion.motion.div,{layout:true,className:"NovaNoScrolling novacore:relative novacore:overflow-hidden",transition:{layout:{duration:.2,ease:[.1,.1,.2,1]}},children:jsxRuntime.jsx(framerMotion.AnimatePresence,{children:jsxRuntime.jsx(framerMotion.motion.div,{variants:c,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"NovaNoScrolling novacore:relative novacore:overflow-hidden novacore:bg-[var(--tuwa-bg-primary)] novacore:border novacore:border-[var(--tuwa-border-primary)] novacore:rounded-t-[var(--tuwa-rounded-corners)] novacore:sm:rounded-[var(--tuwa-rounded-corners)]",children:jsxRuntime.jsx("div",{className:s("NovaNoScrolling NovaDialogContent__elements novacore:relative novacore:flex novacore:max-h-[100dvh] novacore:w-full novacore:flex-col novacore:overflow-y-auto","novacore:[transform:translateZ(0)] novacore:[backface-visibility:hidden]"),children:o})})})})})]})});ge.displayName=l__namespace.Content.displayName;var we=({className:e,...o})=>jsxRuntime.jsx("div",{"aria-describedby":"tuwa:modal-header",className:s("novacore:sticky novacore:flex novacore:top-0 novacore:z-11 novacore:w-full novacore:flex-row novacore:items-center novacore:justify-between","novacore:border-b novacore:border-[var(--tuwa-border-primary)] novacore:bg-[var(--tuwa-bg-primary)] novacore:p-4",e),...o});we.displayName="DialogHeader";var be=({className:e,...o})=>jsxRuntime.jsx("div",{"aria-describedby":"tuwa:modal-footer",className:s("novacore:flex novacore:flex-col-reverse novacore:sm:flex-row novacore:sm:justify-end novacore:sm:space-x-2",e),...o});be.displayName="DialogFooter";var he=d__namespace.forwardRef(({className:e,...o},t)=>jsxRuntime.jsx(l__namespace.Title,{ref:t,"aria-describedby":"tuwa:modal-title",className:s("novacore:text-lg novacore:font-bold novacore:leading-none novacore:tracking-tight novacore:text-[var(--tuwa-text-primary)] novacore:m-0 novacore:font-mono",e),...o}));he.displayName=l__namespace.Title.displayName;var ye=d__namespace.forwardRef(({className:e,...o},t)=>jsxRuntime.jsx(l__namespace.Description,{"aria-describedby":"tuwa:modal-description",ref:t,className:s("novacore:text-sm novacore:text-[var(--tuwa-text-secondary)]",e),...o}));ye.displayName=l__namespace.Description.displayName;function y({children:e,iconId:o,alt:t,firstPathFill:n,...r}){let[a,m]=d.useState(null),i=d.useCallback(c=>{if(c){let w=N(c.outerHTML,n);m({id:o,src:w});}},[o,n]);return a&&a.id===o?jsxRuntime.jsx(T,{...r,src:a.src,alt:t}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:e(i)})}var De="var(--tuwa-testnet-icons)";function at({chainId:e,variant:o="background",className:t}){let n=G(e),r=typeof e=="string",a=r?e.split(":")[0].toLowerCase():e,i=r&&$(e)||n.name.toLowerCase().includes("testnet")?De:void 0,c=s("novacore:w-full novacore:h-full novacore:rounded-full",t),w=typeof a=="string"?a:n.filePath,b=`networks/${o}/${P(w)}`,h=networks.networks.find(v=>v.id===n.id)?.filePath;return n.name==="Unknown"||!h?typeof e=="number"?jsxRuntime.jsx(f,{content:"?",className:t}):jsxRuntime.jsx(D,{githubSrc:b,className:c,firstPathFill:i}):jsxRuntime.jsx(d.Suspense,{fallback:jsxRuntime.jsx(f,{animate:true,className:t}),children:jsxRuntime.jsx(y,{iconId:`${e}-${o}`,className:c,firstPathFill:i,children:v=>jsxRuntime.jsx(web3Icons_cjs.Web3IconLazy,{ref:v,filePath:h,variant:o})})})}function lt({starsCount:e}){let[o,t]=d.useState(false);d.useEffect(()=>t(true),[]);let n=d.useMemo(()=>o?Array.from({length:e??200}).map(()=>({x:Math.random()*window.innerWidth,y:Math.random()*window.innerHeight,r:Math.random()*1+.5,isSupernova:Math.random()<.1,delay:Math.random()*10,duration:5+Math.random()*5})):[],[o]);return jsxRuntime.jsx("div",{className:"novacore:absolute novacore:inset-0 novacore:z-1 novacore:h-full novacore:w-full novacore:overflow-hidden",children:jsxRuntime.jsxs("svg",{width:"100%",height:"100%",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("style",{children:`
|
|
1
|
+
'use strict';var chunkLLVSKNQR_cjs=require('./chunk-LLVSKNQR.cjs'),framerMotion=require('framer-motion'),jsxRuntime=require('react/jsx-runtime'),v=require('react'),s=require('@radix-ui/react-dialog'),networks=require('@web3icons/common/metadata/networks'),web3Icons_cjs=require('./web3-icons.cjs'),wallets=require('@web3icons/common/metadata/wallets');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var v__namespace=/*#__PURE__*/_interopNamespace(v);var s__namespace=/*#__PURE__*/_interopNamespace(s);function Bo({className:o,strokeWidth:e,isOpen:t}){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:e??2,stroke:"currentColor",className:chunkLLVSKNQR_cjs.b("novacore:w-4 novacore:h-4 novacore:text-[var(--tuwa-text-secondary)]",o),children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:t&&jsxRuntime.jsx(framerMotion.motion.path,{strokeLinecap:"round",strokeLinejoin:"round",d:"m4.5 15.75 7.5-7.5 7.5 7.5",variants:{hidden:{translateY:3,scaleY:.8,opacity:0},visible:{translateY:0,scaleY:1,opacity:1}},initial:"hidden",animate:"visible",transition:{duration:.4}})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!t&&jsxRuntime.jsx(framerMotion.motion.path,{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5",className:"novacore:relative",variants:{hidden:{translateY:-3,scaleY:.8,opacity:0},visible:{translateY:0,scaleY:1,opacity:1}},initial:"hidden",animate:"visible",transition:{duration:.4}})})]})}var K=v__namespace.forwardRef(({className:o,...e},t)=>jsxRuntime.jsxs("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:chunkLLVSKNQR_cjs.b("novacore:h-5 novacore:w-5 novacore:text-[var(--tuwa-text-primary)] novacore:transition-colors",o),...e,children:[jsxRuntime.jsx("path",{d:"M18 6 6 18"}),jsxRuntime.jsx("path",{d:"m6 6 12 12"})]}));K.displayName="CloseIcon";var Z="novacore:flex novacore:items-center novacore:justify-center novacore:w-full novacore:h-full novacore:rounded-full novacore:text-[var(--tuwa-text-secondary)] novacore:bg-[var(--tuwa-bg-muted)]",u=({animate:o=false,content:e="",className:t})=>jsxRuntime.jsx("div",{className:chunkLLVSKNQR_cjs.b(Z,"Nova_Web3_Icon",t,{"novacore:animate-pulse":o}),children:e});function P({src:o,alt:e,...t}){return jsxRuntime.jsx("img",{...t,src:o,alt:e??"",draggable:false,onDragStart:r=>r.preventDefault(),style:{outline:"none",pointerEvents:"none"}})}var oo="https://raw.githubusercontent.com/0xa3k5/web3icons/refs/heads/main/raw-svgs",R=new Map;function C({githubSrc:o,className:e,alt:t,firstPathFill:r,...a}){let n=`${o}|${r??""}`,d=R.get(n),[l,c]=v.useState(null),[w,b]=v.useState("idle"),y=d||l,x=d?"success":w;return v.useEffect(()=>{let f=true;return R.has(n)?void 0:((async()=>{b("loading");try{let D=await fetch(`${oo}/${o}`);if(!D.ok)throw new Error(`Failed to load icon: ${D.status}`);let U=await D.text();if(f){let E=chunkLLVSKNQR_cjs.i(U,r);R.set(n,E),c(E),b("success");}}catch{f&&b("error");}})(),()=>{f=false;})},[o,r,n]),x==="loading"||x==="idle"?jsxRuntime.jsx(u,{animate:true,className:e}):x==="success"&&y?jsxRuntime.jsx(P,{...a,src:y,alt:t,className:e}):jsxRuntime.jsx(u,{content:"?",className:e})}var ce=s__namespace.Root,le=s__namespace.Trigger,eo=s__namespace.Portal,me=s__namespace.Close,to={initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,transition:{duration:.2}}},ao={initial:{opacity:0,y:"100%"},animate:{opacity:1,y:"0%"},exit:{opacity:0,y:"100%",transition:{duration:.2}}},ro={initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},_=({className:o,backdropAnimation:e})=>(v__namespace.useEffect(()=>(typeof window<"u"&&window.document.body.classList.add("NovaModalOpen"),()=>{typeof window<"u"&&window.document.body.classList.remove("NovaModalOpen");}),[]),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:jsxRuntime.jsx(framerMotion.motion.div,{variants:e??ro,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"novacore:relative novacore:overflow-hidden",children:jsxRuntime.jsx("div",{className:chunkLLVSKNQR_cjs.b("novacore:fixed novacore:inset-0 novacore:z-50 novacore:bg-black/55 novacore:backdrop-blur-sm novacore:backdrop-saturate-150",o)})})}));_.displayName=s__namespace.Overlay.displayName;var no=v__namespace.forwardRef(({className:o,children:e,modalAnimation:t,backdropAnimation:r,...a},n)=>{let[d,l]=v__namespace.useState(false);v__namespace.useEffect(()=>{l(chunkLLVSKNQR_cjs.f());},[]);let c=t??(d?ao:to);return jsxRuntime.jsxs(eo,{children:[jsxRuntime.jsx(_,{backdropAnimation:r}),jsxRuntime.jsx(s__namespace.Content,{"aria-describedby":"tuwa:modal-content",ref:n,className:chunkLLVSKNQR_cjs.b("NovaNoScrolling novacore:fixed novacore:bottom-0 novacore:left-0 novacore:p-0 novacore:sm:bottom-auto novacore:sm:left-[50%] novacore:sm:top-[50%] novacore:sm:translate-x-[-50%] novacore:sm:translate-y-[-50%] novacore:z-50 novacore:sm:p-4 novacore:outline-none",o),...a,children:jsxRuntime.jsx(framerMotion.motion.div,{layout:true,className:"NovaNoScrolling novacore:relative novacore:overflow-hidden",transition:{layout:{duration:.2,ease:[.1,.1,.2,1]}},children:jsxRuntime.jsx(framerMotion.AnimatePresence,{children:jsxRuntime.jsx(framerMotion.motion.div,{variants:c,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"NovaNoScrolling novacore:relative novacore:overflow-hidden novacore:bg-[var(--tuwa-bg-primary)] novacore:border novacore:border-[var(--tuwa-border-primary)] novacore:rounded-t-[var(--tuwa-rounded-corners)] novacore:sm:rounded-[var(--tuwa-rounded-corners)]",children:jsxRuntime.jsx("div",{className:chunkLLVSKNQR_cjs.b("NovaNoScrolling NovaDialogContent__elements novacore:relative novacore:flex novacore:max-h-[100dvh] novacore:w-full novacore:flex-col novacore:overflow-y-auto","novacore:[transform:translateZ(0)] novacore:[backface-visibility:hidden]"),children:e})})})})})]})});no.displayName=s__namespace.Content.displayName;var io=({className:o,...e})=>jsxRuntime.jsx("div",{"aria-describedby":"tuwa:modal-header",className:chunkLLVSKNQR_cjs.b("novacore:sticky novacore:flex novacore:top-0 novacore:z-11 novacore:w-full novacore:flex-row novacore:items-center novacore:justify-between","novacore:border-b novacore:border-[var(--tuwa-border-primary)] novacore:bg-[var(--tuwa-bg-primary)] novacore:p-4",o),...e});io.displayName="DialogHeader";var so=({className:o,...e})=>jsxRuntime.jsx("div",{"aria-describedby":"tuwa:modal-footer",className:chunkLLVSKNQR_cjs.b("novacore:flex novacore:flex-col-reverse novacore:sm:flex-row novacore:sm:justify-end novacore:sm:space-x-2",o),...e});so.displayName="DialogFooter";var co=v__namespace.forwardRef(({className:o,...e},t)=>jsxRuntime.jsx(s__namespace.Title,{ref:t,"aria-describedby":"tuwa:modal-title",className:chunkLLVSKNQR_cjs.b("novacore:text-lg novacore:font-bold novacore:leading-none novacore:tracking-tight novacore:text-[var(--tuwa-text-primary)] novacore:m-0 novacore:font-mono",o),...e}));co.displayName=s__namespace.Title.displayName;var lo=v__namespace.forwardRef(({className:o,...e},t)=>jsxRuntime.jsx(s__namespace.Description,{"aria-describedby":"tuwa:modal-description",ref:t,className:chunkLLVSKNQR_cjs.b("novacore:text-sm novacore:text-[var(--tuwa-text-secondary)]",o),...e}));lo.displayName=s__namespace.Description.displayName;function h({children:o,iconId:e,alt:t,firstPathFill:r,...a}){let[n,d]=v.useState(null),l=v.useCallback(c=>{if(c){let w=chunkLLVSKNQR_cjs.i(c.outerHTML,r);d({id:e,src:w});}},[e,r]);return n&&n.id===e?jsxRuntime.jsx(P,{...a,src:n.src,alt:t}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:o(l)})}var bo="var(--tuwa-testnet-icons)";function Ie({chainId:o,variant:e="background",className:t}){let r=chunkLLVSKNQR_cjs.d(o),a=typeof o=="string",n=a?o.split(":")[0].toLowerCase():o,l=a&&chunkLLVSKNQR_cjs.e(o)||r.name.toLowerCase().includes("testnet")?bo:void 0,c=chunkLLVSKNQR_cjs.b("novacore:w-full novacore:h-full novacore:rounded-full",t),w=typeof n=="string"?n:r.filePath,b=`networks/${e}/${chunkLLVSKNQR_cjs.j(w)}`,y=networks.networks.find(f=>f.id===r.id)?.filePath;return r.name==="Unknown"||!y?typeof o=="number"?jsxRuntime.jsx(u,{content:"?",className:t}):jsxRuntime.jsx(C,{githubSrc:b,className:c,firstPathFill:l}):jsxRuntime.jsx(v.Suspense,{fallback:jsxRuntime.jsx(u,{animate:true,className:t}),children:jsxRuntime.jsx(h,{iconId:`${o}-${e}`,className:c,firstPathFill:l,children:f=>jsxRuntime.jsx(web3Icons_cjs.Web3IconLazy,{ref:f,filePath:y,variant:e})})})}function Me({starsCount:o}){let[e,t]=v.useState(false);v.useEffect(()=>t(true),[]);let r=v.useMemo(()=>e?Array.from({length:o??200}).map(()=>({x:Math.random()*window.innerWidth,y:Math.random()*window.innerHeight,r:Math.random()*1+.5,isSupernova:Math.random()<.1,delay:Math.random()*10,duration:5+Math.random()*5})):[],[e]);return jsxRuntime.jsx("div",{className:"novacore:absolute novacore:inset-0 novacore:z-1 novacore:h-full novacore:w-full novacore:overflow-hidden",children:jsxRuntime.jsxs("svg",{width:"100%",height:"100%",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("style",{children:`
|
|
2
2
|
/* Pulse animation now includes scale for a more organic feel. */
|
|
3
3
|
@keyframes pulse {
|
|
4
4
|
0%, 100% {
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
transform-origin: center;
|
|
45
45
|
stroke-width: 2;
|
|
46
46
|
}
|
|
47
|
-
`})}),
|
|
48
|
-
exports.
|
|
47
|
+
`})}),r.map((a,n)=>jsxRuntime.jsx("circle",{cx:a.x,cy:a.y,r:a.r,fill:"rgba(var(--tuwa-bg-primary), 0.7)",className:a.isSupernova?"supernova":"pulsar",style:{animationDelay:`${a.delay}s`,animationDuration:`${a.duration}s`}},n))]})})}function Fe({closeToast:o,ariaLabel:e="Close toast notification",title:t="Close toast notification",className:r,iconClassName:a}){return jsxRuntime.jsx("button",{type:"button",onClick:o,"aria-label":e,title:t,className:chunkLLVSKNQR_cjs.b("novacore:absolute novacore:top-2 novacore:right-2 novacore:cursor-pointer novacore:rounded-[var(--tuwa-rounded-corners)] novacore:p-1","novacore:text-[var(--tuwa-text-tertiary)] novacore:transition-colors","novacore:hover:bg-[var(--tuwa-bg-muted)] novacore:hover:text-[var(--tuwa-text-primary)]",r),children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:chunkLLVSKNQR_cjs.b("novacore:h-5 novacore:w-5",a),children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})})})}var Co={walletconnect:"wallet-connect"};function Io(o){return wallets.wallets.find(e=>e.id===o||e.name?.toLowerCase()===o)?.filePath}var Do=({className:o,ref:e})=>jsxRuntime.jsxs("svg",{ref:e,className:o,fill:"none",viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{fill:"#fff",fillRule:"evenodd",d:"M16 0c8.84 0 16 7.16 16 16s-7.16 16-16 16S0 24.84 0 16 7.16 0 16 0",clipRule:"evenodd"}),jsxRuntime.jsx("path",{fill:"#000",fillRule:"evenodd",d:"M16.54 2.01h1.53c.5.09.99.23 1.48.42.21.25.19.48-.05.69q-.195.045-.39 0c-1.86-.65-3.55-.35-5.07.89 2.39.7 3.84 2.27 4.36 4.7.12.85.08 1.68-.12 2.51.87 0 1.74 0 2.61-.02.39-.4.7-.85.94-1.35-.45-.45-.65-.99-.59-1.63-1.15.08-1.79-.44-1.92-1.58.14-1.12.78-1.67 1.92-1.63a.7.7 0 0 0-.12-.49l-.89-.89c-.02-.45.19-.6.62-.47.24.19.46.39.66.62.71-.79 1.5-.89 2.39-.32.44.42.62.94.54 1.55 1.49.02 2.11.76 1.85 2.22-.08.17-.17.34-.27.49.53.59.87 1.28 1.01 2.07.08 4.6.1 9.19.05 13.79-.19 1.58-1 2.71-2.44 3.37-.29.1-.59.2-.89.27H7.2c-1.31-.33-2.05-1.17-2.24-2.51-.03-5.24-.03-10.47 0-15.71.3-1.62 1.28-2.46 2.93-2.54 1.26-1.77 2.98-2.64 5.17-2.61.96-1.01 2.13-1.62 3.5-1.85zm6.11 1.87c.39-.03.7.12.91.44.06.39.09.79.1 1.18.02.12.07.21.17.27.41 0 .82.04 1.23.1.49.26.63.65.42 1.16-.07.14-.18.25-.32.32-.39.06-.79.09-1.18.1-.12.02-.21.07-.27.17l-.15 1.33c-.32.46-.72.55-1.21.27a.76.76 0 0 1-.27-.37c-.06-.41-.09-.82-.1-1.23a.35.35 0 0 0-.27-.17l-1.08-.05c-.46-.24-.62-.61-.47-1.11.14-.27.36-.43.66-.47l.99-.05s.09-.04.12-.07l.15-1.28q.18-.39.57-.54m-10.49.79c2.41-.09 4.12.94 5.15 3.1.44 1.12.48 2.25.12 3.4-.84.06-1.67.07-2.51.02.56-.68.52-1.32-.1-1.92-.26-.13-.54-.19-.84-.17.02-.95 0-1.91-.07-2.86-.21-.41-.55-.58-1.01-.52-.17.03-.31.09-.44.2-.72.92-1.43 1.85-2.14 2.78-.28.45-.29.91-.05 1.38q.225.3.57.42c.34.02.69.03 1.03.02v.69c-1.3.02-2.59 0-3.89-.05-.58-2.1-.08-3.88 1.53-5.34.79-.62 1.68-1 2.66-1.16zm.83 1.82c.07 0 .13.03.17.1l.05 3.05c.04.09.1.16.17.22l.89.05c.22.08.3.24.22.47q-.27.42-.57.81c-.43.02-.85.03-1.28.02 0-.41 0-.82-.02-1.23a.46.46 0 0 0-.17-.17l-1.28-.05c-.3-.1-.37-.29-.22-.57.7-.89 1.39-1.79 2.04-2.71zm-5.81.84h.2a6.1 6.1 0 0 0-.25 3.77c-.59-.13-1.01-.49-1.26-1.06-.36-1.29.08-2.19 1.31-2.71m17.98.83c.05 0 .1 0 .15.02q.825.855.96 2.04.045 1.305 0 2.61a3.76 3.76 0 0 0-2.54-1.55c-.61-.05-1.21-.08-1.82-.1.26-.31.48-.66.64-1.03 1.31.02 1.94-.62 1.87-1.95.26.02.5 0 .74-.05zM5.7 11.22c.41.4.91.65 1.48.76l16.06.05c1.42.13 2.38.87 2.88 2.19.07.24.12.49.15.74.03 2.86.03 5.71 0 8.57-.21 1.44-1 2.38-2.39 2.83-.24.05-.49.08-.74.1-1.26.02-2.53.03-3.79.02 0-1.33 0-2.66.02-3.99l1.55-1.55c1.42-.04 2.09-.78 1.99-2.19-.24-.88-.81-1.34-1.72-1.38-1.2.12-1.81.8-1.82 2.02l-1.92 1.92c-.08.11-.14.22-.2.34-.07 1.61-.1 3.22-.07 4.83h-.44c0-2.28 0-4.56-.02-6.85a1.8 1.8 0 0 0-.15-.34l-1.13-1.13c0-1.23-.61-1.92-1.82-2.07-1.29.17-1.87.91-1.72 2.22q.465 1.395 1.95 1.35l.71.71c0 .3.04.6.1.89.25.21.48.19.69-.05.03-.39.03-.79 0-1.18-.2-.25-.43-.49-.66-.71.15-.1.29-.22.39-.37.3.27.58.55.86.84.02 2.23.03 4.47.02 6.7h-.59c0-1.38 0-2.76-.02-4.14-.15-.25-.35-.31-.62-.17a1 1 0 0 0-.12.22c-.02 1.36-.03 2.73-.02 4.09h-.44c0-.99 0-1.97-.02-2.96-.02-.09-.06-.17-.1-.25-.67-.72-1.36-1.43-2.07-2.12-.06-1.48-.82-2.13-2.29-1.95-1.02.41-1.42 1.16-1.21 2.24q.51 1.32 1.95 1.26l1.55 1.55c.02.74.03 1.48.02 2.22-1.56.02-3.12 0-4.68-.07-.9-.24-1.42-.83-1.55-1.75-.02-4.48-.03-8.96-.02-13.45zm7.79 5.66c.84.06 1.19.5 1.06 1.33-.32.62-.8.79-1.45.52-.46-.37-.56-.82-.32-1.35.18-.26.42-.42.71-.49zm7.43 1.28c.89-.03 1.29.4 1.21 1.28-.33.67-.83.85-1.5.52-.54-.49-.58-1-.1-1.55.12-.11.25-.19.39-.25M9.94 19.94c.84 0 1.22.4 1.16 1.23-.28.68-.76.89-1.45.62-.63-.54-.65-1.09-.05-1.67l.34-.17zm9.75.24c.16.13.3.27.44.42-.53.52-1.05 1.05-1.55 1.6-.02 1.43-.03 2.86-.02 4.28h-.59c0-1.51 0-3.02.02-4.53a71 71 0 0 1 1.7-1.77M11.56 22c.62.53 1.21 1.11 1.75 1.72.02.92.03 1.84.02 2.76h-.59c0-.85 0-1.71-.02-2.56l-1.48-1.48s-.03-.07 0-.1c.12-.11.22-.22.32-.34",clipRule:"evenodd"})]});function Ye({walletName:o,variant:e="background",className:t}){let r=chunkLLVSKNQR_cjs.b("novacore:w-full novacore:h-full novacore:rounded-full",t),a=o.toLowerCase();if(a==="impersonatedwallet")return jsxRuntime.jsx(h,{iconId:"impersonatedwallet",className:r,children:c=>jsxRuntime.jsx(Do,{ref:c})});let n=Co[a]??a,d=`wallets/${e}/${chunkLLVSKNQR_cjs.j(n)}`,l=Io(n);return l?jsxRuntime.jsx(v.Suspense,{fallback:jsxRuntime.jsx(u,{animate:true,className:t}),children:jsxRuntime.jsx(h,{iconId:`${n}-${e}`,className:r,children:c=>jsxRuntime.jsx(web3Icons_cjs.Web3IconLazy,{ref:c,filePath:l,variant:e})})}):jsxRuntime.jsx(C,{githubSrc:d,className:r})}function Qe(o=2e3){let[e,t]=v.useState(false),[r,a]=v.useState(null),n=v.useCallback(async d=>{if(!d)return {copied:false,error:new Error("There is no text to copy.")};try{return await navigator.clipboard.writeText(d),t(!0),a(null),setTimeout(()=>t(!1),o),{copied:!0}}catch(l){let c=l instanceof Error?l:new Error("Failed to copy text.");return console.error(c),a(c),setTimeout(()=>a(null),o),{copied:false,error:c}}},[o]);return {isCopied:e,copy:n,error:r}}function Xe(o){let e=a=>typeof window<"u"?window.matchMedia(a).matches:false,[t,r]=v.useState(e(o));return v.useEffect(()=>{let a=window.matchMedia(o),n=()=>r(a.matches);return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[o]),t}
|
|
48
|
+
Object.defineProperty(exports,"applyFirstPathFill",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.h}});Object.defineProperty(exports,"cn",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.b}});Object.defineProperty(exports,"deepMerge",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.c}});Object.defineProperty(exports,"formatIconNameForGithub",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.j}});Object.defineProperty(exports,"getChainName",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.d}});Object.defineProperty(exports,"isSolanaDev",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.e}});Object.defineProperty(exports,"isTouchDevice",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.f}});Object.defineProperty(exports,"resolveCssVariable",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.g}});Object.defineProperty(exports,"standardButtonClasses",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.a}});Object.defineProperty(exports,"svgToBase64",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.i}});Object.defineProperty(exports,"textCenterEllipsis",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.k}});exports.ChevronArrowWithAnim=Bo;exports.CloseIcon=K;exports.Dialog=ce;exports.DialogClose=me;exports.DialogContent=no;exports.DialogDescription=lo;exports.DialogFooter=so;exports.DialogHeader=io;exports.DialogOverlay=_;exports.DialogPortal=eo;exports.DialogTitle=co;exports.DialogTrigger=le;exports.FallbackIcon=u;exports.GithubFallbackIcon=C;exports.NetworkIcon=Ie;exports.StarsBackground=Me;exports.SvgImg=P;exports.SvgToImg=h;exports.ToastCloseButton=Fe;exports.WalletIcon=Ye;exports.useCopyToClipboard=Qe;exports.useMediaQuery=Xe;
|
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,8 @@ import * as React$1 from 'react';
|
|
|
2
2
|
import { ComponentProps, ReactNode } from 'react';
|
|
3
3
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
4
4
|
import { Variants } from 'framer-motion';
|
|
5
|
-
|
|
5
|
+
export { ChainInfo, applyFirstPathFill, cn, deepMerge, formatIconNameForGithub, getChainName, isSolanaDev, isTouchDevice, resolveCssVariable, standardButtonClasses, svgToBase64, textCenterEllipsis } from './utils.cjs';
|
|
6
|
+
import 'clsx';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* A chevron that points up when `isOpen` is `true` and down otherwise, animated with `framer-motion` when it flips.
|
|
@@ -386,197 +387,4 @@ declare function useCopyToClipboard(timeout?: number): UseCopyToClipboardResult;
|
|
|
386
387
|
*/
|
|
387
388
|
declare function useMediaQuery(query: string): boolean;
|
|
388
389
|
|
|
389
|
-
|
|
390
|
-
* Classes of the standard secondary button of Nova (Tailwind utilities with the `novacore:` prefix, styled with the
|
|
391
|
-
* `--tuwa-standart-button-*` variables). The connect modal uses them for its buttons.
|
|
392
|
-
*/
|
|
393
|
-
declare const standardButtonClasses = "novacore:cursor-pointer novacore:rounded-[var(--tuwa-rounded-corners)] novacore:bg-[var(--tuwa-standart-button-bg)] novacore:px-3 novacore:py-2 novacore:flex novacore:items-center novacore:gap-1 novacore:text-sm novacore:font-mono novacore:font-semibold novacore:text-[var(--tuwa-text-primary)] novacore:transition-colors novacore:hover:bg-[var(--tuwa-standart-button-hover)] novacore:disabled:cursor-not-allowed novacore:disabled:opacity-50 novacore:min-h-[36px]";
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* @file This file contains a utility function for conditionally merging Tailwind CSS classes.
|
|
397
|
-
*/
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* A utility function to conditionally join class names together and resolve
|
|
401
|
-
* conflicting Tailwind CSS classes.
|
|
402
|
-
*
|
|
403
|
-
* It combines the functionality of `clsx` and `tailwind-merge`.
|
|
404
|
-
*
|
|
405
|
-
* @param {...ClassValue[]} inputs - A list of class values to be combined.
|
|
406
|
-
* This can include strings, numbers, objects, arrays, and booleans.
|
|
407
|
-
* @returns {string} The final, merged class name string.
|
|
408
|
-
*
|
|
409
|
-
* @example
|
|
410
|
-
* cn('p-4', 'bg-red-500', { 'font-bold': true }); // => 'p-4 bg-red-500 font-bold'
|
|
411
|
-
* cn('p-2', 'p-4'); // => 'p-4' (tailwind-merge resolves the conflict)
|
|
412
|
-
*
|
|
413
|
-
* @see https://github.com/dcastil/tailwind-merge
|
|
414
|
-
* @see https://github.com/lukeed/clsx
|
|
415
|
-
*/
|
|
416
|
-
declare function cn(...inputs: ClassValue[]): string;
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* @file This file contains a utility for performing a deep (recursive) merge of two objects.
|
|
420
|
-
*/
|
|
421
|
-
/**
|
|
422
|
-
* Recursively merges the properties of a source object into a target object.
|
|
423
|
-
* This function creates a new object and does not mutate the original target.
|
|
424
|
-
*
|
|
425
|
-
* @template T - The type of the objects being merged.
|
|
426
|
-
* @param {T} target - The base object.
|
|
427
|
-
* @param {Partial<T>} source - The object with properties to merge into the target.
|
|
428
|
-
* @returns {T} A new object representing the merged result.
|
|
429
|
-
*
|
|
430
|
-
* @example
|
|
431
|
-
* const defaults = { a: 1, b: { c: 2, d: 3 } };
|
|
432
|
-
* const custom = { b: { c: 99 } };
|
|
433
|
-
* const result = deepMerge(defaults, custom);
|
|
434
|
-
* // result will be { a: 1, b: { c: 99, d: 3 } }
|
|
435
|
-
*/
|
|
436
|
-
declare function deepMerge<T extends object>(target: T, source: Partial<T>): T;
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* Result of chain name resolution.
|
|
440
|
-
*/
|
|
441
|
-
interface ChainInfo {
|
|
442
|
-
/** Human-readable network name (e.g., "Ethereum", "Solana Devnet") */
|
|
443
|
-
name: string;
|
|
444
|
-
/** Normalized network identifier for icon libraries (e.g., "ethereum", "solana") */
|
|
445
|
-
id: string;
|
|
446
|
-
/** Original chain ID as provided */
|
|
447
|
-
chainId: number | string;
|
|
448
|
-
/** File path for icon resolution */
|
|
449
|
-
filePath: string;
|
|
450
|
-
}
|
|
451
|
-
/**
|
|
452
|
-
* Retrieves blockchain network information based on its chain ID.
|
|
453
|
-
*
|
|
454
|
-
* Supports both EVM and non-EVM chain identifiers:
|
|
455
|
-
* - **Numeric IDs (EVM):** e.g., `1` → "Ethereum", `137` → "Polygon"
|
|
456
|
-
* - **String IDs (Non-EVM):** e.g., `"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"` or `"solana:devnet"` → "Solana Devnet"
|
|
457
|
-
*
|
|
458
|
-
* For Solana dev and test clusters, given as the genesis-hash chain ID of CAIP-30 or as the cluster name
|
|
459
|
-
* (`solana:devnet`), the cluster is appended to the name. Mainnet (`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`) is
|
|
460
|
-
* "Solana".
|
|
461
|
-
*
|
|
462
|
-
* The networks are looked up in the metadata of `@web3icons/common`.
|
|
463
|
-
*
|
|
464
|
-
* @param chainId - Chain identifier (number for EVM, string for non-EVM)
|
|
465
|
-
* @returns The network name, id and icon file path, and the original `chainId`; `'Unknown'`/`'unknown'` when the
|
|
466
|
-
* network is not listed.
|
|
467
|
-
*
|
|
468
|
-
* @example
|
|
469
|
-
* ```ts
|
|
470
|
-
* import { getChainName } from '@tuwaio/nova-core';
|
|
471
|
-
*
|
|
472
|
-
* getChainName(1);
|
|
473
|
-
* // → { name: 'Ethereum', id: 'ethereum', filePath: 'ethereum', chainId: 1 }
|
|
474
|
-
*
|
|
475
|
-
* getChainName('solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1');
|
|
476
|
-
* // → { name: 'Solana Devnet', id: 'solana', filePath: 'solana', chainId: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1' }
|
|
477
|
-
*
|
|
478
|
-
* getChainName(999999);
|
|
479
|
-
* // → { name: 'Unknown', id: 'unknown', filePath: 'unknown', chainId: 999999 }
|
|
480
|
-
* ```
|
|
481
|
-
*/
|
|
482
|
-
declare function getChainName(chainId: number | string): ChainInfo;
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Determines if the current chain is a Solana development or test network.
|
|
486
|
-
*
|
|
487
|
-
* It checks that the ID is a Solana chain ID (or a string containing 'solana') that names a non-production cluster:
|
|
488
|
-
* the genesis-hash chain ID of devnet or testnet (CAIP-30, e.g. `solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1`), or
|
|
489
|
-
* 'devnet' / 'testnet' in any letter case (e.g. `solana:devnet`).
|
|
490
|
-
*
|
|
491
|
-
* @param chainId - The chain identifier (e.g., "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", "solana:devnet", 1).
|
|
492
|
-
* @returns {boolean} True only if it is a Solana dev/test chain.
|
|
493
|
-
*/
|
|
494
|
-
declare function isSolanaDev(chainId: number | string): boolean;
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* @file Utility function to determine if the current environment supports touch input.
|
|
498
|
-
* This is safe to use in Next.js applications as it checks for the `window` object existence.
|
|
499
|
-
*/
|
|
500
|
-
/**
|
|
501
|
-
* Determines if the current browsing device supports touch input,
|
|
502
|
-
* while also excluding large screens (typically desktop-sized touch monitors).
|
|
503
|
-
*
|
|
504
|
-
* It checks for:
|
|
505
|
-
* 1. The presence of 'ontouchstart' or navigator.maxTouchPoints > 0 or '(pointer: coarse)'.
|
|
506
|
-
* 2. ONLY returns true if the screen width is less than or equal to the specified threshold (e.g., 1200px).
|
|
507
|
-
*
|
|
508
|
-
* This function is safe for server-side rendering (SSR) environments like Next.js.
|
|
509
|
-
*
|
|
510
|
-
* @param {number} [maxWidth=1200] The maximum screen width (in pixels) for a device to be considered 'touch' (default
|
|
511
|
-
* is 1200).
|
|
512
|
-
* @returns {boolean} Returns true if the environment is determined to support touch input AND is within the width
|
|
513
|
-
* limit, otherwise false.
|
|
514
|
-
*/
|
|
515
|
-
declare function isTouchDevice(maxWidth?: number): boolean;
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* Resolves a CSS variable to its computed value on `document.documentElement`.
|
|
519
|
-
* Returns the original value if it's not a CSS variable. Call it in the browser: it reads `getComputedStyle`.
|
|
520
|
-
*
|
|
521
|
-
* @param value - Color value, potentially a CSS variable like `var(--my-color)`
|
|
522
|
-
* @returns Resolved color value (e.g., `#ff0000`) or original if not a variable
|
|
523
|
-
*/
|
|
524
|
-
declare function resolveCssVariable(value: string): string;
|
|
525
|
-
/**
|
|
526
|
-
* Modifies the fill attribute of the first `<path>` element in an SVG string.
|
|
527
|
-
* Uses DOMParser for safe XML manipulation, so call it in the browser.
|
|
528
|
-
* Automatically resolves CSS variables (e.g., `var(--color)`) to their computed values with {@link resolveCssVariable}.
|
|
529
|
-
*
|
|
530
|
-
* @param svgString - The original SVG markup
|
|
531
|
-
* @param fillColor - The color to apply (supports CSS variables)
|
|
532
|
-
* @returns Modified SVG string, or the original string (with a console warning) when it cannot be parsed
|
|
533
|
-
*/
|
|
534
|
-
declare function applyFirstPathFill(svgString: string, fillColor: string): string;
|
|
535
|
-
/**
|
|
536
|
-
* Encodes an SVG string to a base64 data URL.
|
|
537
|
-
*
|
|
538
|
-
* @param svgString - The SVG markup
|
|
539
|
-
* @param firstPathFill - Optional fill color to apply to the first path, with {@link applyFirstPathFill} (browser only)
|
|
540
|
-
* @returns Base64-encoded data URL (`data:image/svg+xml;base64,…`)
|
|
541
|
-
*/
|
|
542
|
-
declare function svgToBase64(svgString: string, firstPathFill?: string): string;
|
|
543
|
-
/**
|
|
544
|
-
* Formats a name string into a GitHub-compatible SVG filename.
|
|
545
|
-
*
|
|
546
|
-
* Converts spaces to hyphens and lowercases the string,
|
|
547
|
-
* then appends the `.svg` extension.
|
|
548
|
-
*
|
|
549
|
-
* @param name - The name to format (e.g., "Wallet Connect", "MetaMask")
|
|
550
|
-
* @returns Formatted filename (e.g., "wallet-connect.svg", "metamask.svg")
|
|
551
|
-
*
|
|
552
|
-
* @example
|
|
553
|
-
* ```ts
|
|
554
|
-
* import { formatIconNameForGithub } from '@tuwaio/nova-core';
|
|
555
|
-
*
|
|
556
|
-
* formatIconNameForGithub('Wallet Connect'); // → 'wallet-connect.svg'
|
|
557
|
-
* formatIconNameForGithub('MetaMask'); // → 'metamask.svg'
|
|
558
|
-
* ```
|
|
559
|
-
*/
|
|
560
|
-
declare const formatIconNameForGithub: (name: string) => string;
|
|
561
|
-
|
|
562
|
-
/**
|
|
563
|
-
* @file This file contains a utility function for truncating a string with a center ellipsis.
|
|
564
|
-
*/
|
|
565
|
-
/**
|
|
566
|
-
* Truncates a string by showing a specified number of characters from the start and end,
|
|
567
|
-
* with an ellipsis in the middle. If the string is too short to be truncated, it's returned as is.
|
|
568
|
-
*
|
|
569
|
-
* @param {string} str - The string to truncate.
|
|
570
|
-
* @param {number} from - The number of characters to show from the beginning of the string.
|
|
571
|
-
* @param {number} to - The number of characters to show from the end of the string.
|
|
572
|
-
* @returns {string} The truncated string, or the original string if it's too short.
|
|
573
|
-
*
|
|
574
|
-
* @example
|
|
575
|
-
* const hash = '0x1234567890abcdef1234567890abcdef';
|
|
576
|
-
* textCenterEllipsis(hash, 6, 4); // => "0x1234...cdef"
|
|
577
|
-
*
|
|
578
|
-
* textCenterEllipsis('short', 6, 4); // => "short"
|
|
579
|
-
*/
|
|
580
|
-
declare function textCenterEllipsis(str: string | undefined | null, from: number, to: number): string;
|
|
581
|
-
|
|
582
|
-
export { type ChainInfo, ChevronArrowWithAnim, CloseIcon, type CopyToClipboardResult, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, FallbackIcon, type FallbackIconProps, GithubFallbackIcon, type GithubFallbackIconProps, NetworkIcon, type NetworkIconProps, StarsBackground, SvgImg, type SvgImgProps, SvgToImg, type SvgToImgProps, ToastCloseButton, type ToastCloseButtonProps, type UseCopyToClipboardResult, WalletIcon, type WalletIconProps, applyFirstPathFill, cn, deepMerge, formatIconNameForGithub, getChainName, isSolanaDev, isTouchDevice, resolveCssVariable, standardButtonClasses, svgToBase64, textCenterEllipsis, useCopyToClipboard, useMediaQuery };
|
|
390
|
+
export { ChevronArrowWithAnim, CloseIcon, type CopyToClipboardResult, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, FallbackIcon, type FallbackIconProps, GithubFallbackIcon, type GithubFallbackIconProps, NetworkIcon, type NetworkIconProps, StarsBackground, SvgImg, type SvgImgProps, SvgToImg, type SvgToImgProps, ToastCloseButton, type ToastCloseButtonProps, type UseCopyToClipboardResult, WalletIcon, type WalletIconProps, useCopyToClipboard, useMediaQuery };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import * as React$1 from 'react';
|
|
|
2
2
|
import { ComponentProps, ReactNode } from 'react';
|
|
3
3
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
4
4
|
import { Variants } from 'framer-motion';
|
|
5
|
-
|
|
5
|
+
export { ChainInfo, applyFirstPathFill, cn, deepMerge, formatIconNameForGithub, getChainName, isSolanaDev, isTouchDevice, resolveCssVariable, standardButtonClasses, svgToBase64, textCenterEllipsis } from './utils.js';
|
|
6
|
+
import 'clsx';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* A chevron that points up when `isOpen` is `true` and down otherwise, animated with `framer-motion` when it flips.
|
|
@@ -386,197 +387,4 @@ declare function useCopyToClipboard(timeout?: number): UseCopyToClipboardResult;
|
|
|
386
387
|
*/
|
|
387
388
|
declare function useMediaQuery(query: string): boolean;
|
|
388
389
|
|
|
389
|
-
|
|
390
|
-
* Classes of the standard secondary button of Nova (Tailwind utilities with the `novacore:` prefix, styled with the
|
|
391
|
-
* `--tuwa-standart-button-*` variables). The connect modal uses them for its buttons.
|
|
392
|
-
*/
|
|
393
|
-
declare const standardButtonClasses = "novacore:cursor-pointer novacore:rounded-[var(--tuwa-rounded-corners)] novacore:bg-[var(--tuwa-standart-button-bg)] novacore:px-3 novacore:py-2 novacore:flex novacore:items-center novacore:gap-1 novacore:text-sm novacore:font-mono novacore:font-semibold novacore:text-[var(--tuwa-text-primary)] novacore:transition-colors novacore:hover:bg-[var(--tuwa-standart-button-hover)] novacore:disabled:cursor-not-allowed novacore:disabled:opacity-50 novacore:min-h-[36px]";
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* @file This file contains a utility function for conditionally merging Tailwind CSS classes.
|
|
397
|
-
*/
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* A utility function to conditionally join class names together and resolve
|
|
401
|
-
* conflicting Tailwind CSS classes.
|
|
402
|
-
*
|
|
403
|
-
* It combines the functionality of `clsx` and `tailwind-merge`.
|
|
404
|
-
*
|
|
405
|
-
* @param {...ClassValue[]} inputs - A list of class values to be combined.
|
|
406
|
-
* This can include strings, numbers, objects, arrays, and booleans.
|
|
407
|
-
* @returns {string} The final, merged class name string.
|
|
408
|
-
*
|
|
409
|
-
* @example
|
|
410
|
-
* cn('p-4', 'bg-red-500', { 'font-bold': true }); // => 'p-4 bg-red-500 font-bold'
|
|
411
|
-
* cn('p-2', 'p-4'); // => 'p-4' (tailwind-merge resolves the conflict)
|
|
412
|
-
*
|
|
413
|
-
* @see https://github.com/dcastil/tailwind-merge
|
|
414
|
-
* @see https://github.com/lukeed/clsx
|
|
415
|
-
*/
|
|
416
|
-
declare function cn(...inputs: ClassValue[]): string;
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* @file This file contains a utility for performing a deep (recursive) merge of two objects.
|
|
420
|
-
*/
|
|
421
|
-
/**
|
|
422
|
-
* Recursively merges the properties of a source object into a target object.
|
|
423
|
-
* This function creates a new object and does not mutate the original target.
|
|
424
|
-
*
|
|
425
|
-
* @template T - The type of the objects being merged.
|
|
426
|
-
* @param {T} target - The base object.
|
|
427
|
-
* @param {Partial<T>} source - The object with properties to merge into the target.
|
|
428
|
-
* @returns {T} A new object representing the merged result.
|
|
429
|
-
*
|
|
430
|
-
* @example
|
|
431
|
-
* const defaults = { a: 1, b: { c: 2, d: 3 } };
|
|
432
|
-
* const custom = { b: { c: 99 } };
|
|
433
|
-
* const result = deepMerge(defaults, custom);
|
|
434
|
-
* // result will be { a: 1, b: { c: 99, d: 3 } }
|
|
435
|
-
*/
|
|
436
|
-
declare function deepMerge<T extends object>(target: T, source: Partial<T>): T;
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* Result of chain name resolution.
|
|
440
|
-
*/
|
|
441
|
-
interface ChainInfo {
|
|
442
|
-
/** Human-readable network name (e.g., "Ethereum", "Solana Devnet") */
|
|
443
|
-
name: string;
|
|
444
|
-
/** Normalized network identifier for icon libraries (e.g., "ethereum", "solana") */
|
|
445
|
-
id: string;
|
|
446
|
-
/** Original chain ID as provided */
|
|
447
|
-
chainId: number | string;
|
|
448
|
-
/** File path for icon resolution */
|
|
449
|
-
filePath: string;
|
|
450
|
-
}
|
|
451
|
-
/**
|
|
452
|
-
* Retrieves blockchain network information based on its chain ID.
|
|
453
|
-
*
|
|
454
|
-
* Supports both EVM and non-EVM chain identifiers:
|
|
455
|
-
* - **Numeric IDs (EVM):** e.g., `1` → "Ethereum", `137` → "Polygon"
|
|
456
|
-
* - **String IDs (Non-EVM):** e.g., `"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"` or `"solana:devnet"` → "Solana Devnet"
|
|
457
|
-
*
|
|
458
|
-
* For Solana dev and test clusters, given as the genesis-hash chain ID of CAIP-30 or as the cluster name
|
|
459
|
-
* (`solana:devnet`), the cluster is appended to the name. Mainnet (`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`) is
|
|
460
|
-
* "Solana".
|
|
461
|
-
*
|
|
462
|
-
* The networks are looked up in the metadata of `@web3icons/common`.
|
|
463
|
-
*
|
|
464
|
-
* @param chainId - Chain identifier (number for EVM, string for non-EVM)
|
|
465
|
-
* @returns The network name, id and icon file path, and the original `chainId`; `'Unknown'`/`'unknown'` when the
|
|
466
|
-
* network is not listed.
|
|
467
|
-
*
|
|
468
|
-
* @example
|
|
469
|
-
* ```ts
|
|
470
|
-
* import { getChainName } from '@tuwaio/nova-core';
|
|
471
|
-
*
|
|
472
|
-
* getChainName(1);
|
|
473
|
-
* // → { name: 'Ethereum', id: 'ethereum', filePath: 'ethereum', chainId: 1 }
|
|
474
|
-
*
|
|
475
|
-
* getChainName('solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1');
|
|
476
|
-
* // → { name: 'Solana Devnet', id: 'solana', filePath: 'solana', chainId: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1' }
|
|
477
|
-
*
|
|
478
|
-
* getChainName(999999);
|
|
479
|
-
* // → { name: 'Unknown', id: 'unknown', filePath: 'unknown', chainId: 999999 }
|
|
480
|
-
* ```
|
|
481
|
-
*/
|
|
482
|
-
declare function getChainName(chainId: number | string): ChainInfo;
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Determines if the current chain is a Solana development or test network.
|
|
486
|
-
*
|
|
487
|
-
* It checks that the ID is a Solana chain ID (or a string containing 'solana') that names a non-production cluster:
|
|
488
|
-
* the genesis-hash chain ID of devnet or testnet (CAIP-30, e.g. `solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1`), or
|
|
489
|
-
* 'devnet' / 'testnet' in any letter case (e.g. `solana:devnet`).
|
|
490
|
-
*
|
|
491
|
-
* @param chainId - The chain identifier (e.g., "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", "solana:devnet", 1).
|
|
492
|
-
* @returns {boolean} True only if it is a Solana dev/test chain.
|
|
493
|
-
*/
|
|
494
|
-
declare function isSolanaDev(chainId: number | string): boolean;
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* @file Utility function to determine if the current environment supports touch input.
|
|
498
|
-
* This is safe to use in Next.js applications as it checks for the `window` object existence.
|
|
499
|
-
*/
|
|
500
|
-
/**
|
|
501
|
-
* Determines if the current browsing device supports touch input,
|
|
502
|
-
* while also excluding large screens (typically desktop-sized touch monitors).
|
|
503
|
-
*
|
|
504
|
-
* It checks for:
|
|
505
|
-
* 1. The presence of 'ontouchstart' or navigator.maxTouchPoints > 0 or '(pointer: coarse)'.
|
|
506
|
-
* 2. ONLY returns true if the screen width is less than or equal to the specified threshold (e.g., 1200px).
|
|
507
|
-
*
|
|
508
|
-
* This function is safe for server-side rendering (SSR) environments like Next.js.
|
|
509
|
-
*
|
|
510
|
-
* @param {number} [maxWidth=1200] The maximum screen width (in pixels) for a device to be considered 'touch' (default
|
|
511
|
-
* is 1200).
|
|
512
|
-
* @returns {boolean} Returns true if the environment is determined to support touch input AND is within the width
|
|
513
|
-
* limit, otherwise false.
|
|
514
|
-
*/
|
|
515
|
-
declare function isTouchDevice(maxWidth?: number): boolean;
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* Resolves a CSS variable to its computed value on `document.documentElement`.
|
|
519
|
-
* Returns the original value if it's not a CSS variable. Call it in the browser: it reads `getComputedStyle`.
|
|
520
|
-
*
|
|
521
|
-
* @param value - Color value, potentially a CSS variable like `var(--my-color)`
|
|
522
|
-
* @returns Resolved color value (e.g., `#ff0000`) or original if not a variable
|
|
523
|
-
*/
|
|
524
|
-
declare function resolveCssVariable(value: string): string;
|
|
525
|
-
/**
|
|
526
|
-
* Modifies the fill attribute of the first `<path>` element in an SVG string.
|
|
527
|
-
* Uses DOMParser for safe XML manipulation, so call it in the browser.
|
|
528
|
-
* Automatically resolves CSS variables (e.g., `var(--color)`) to their computed values with {@link resolveCssVariable}.
|
|
529
|
-
*
|
|
530
|
-
* @param svgString - The original SVG markup
|
|
531
|
-
* @param fillColor - The color to apply (supports CSS variables)
|
|
532
|
-
* @returns Modified SVG string, or the original string (with a console warning) when it cannot be parsed
|
|
533
|
-
*/
|
|
534
|
-
declare function applyFirstPathFill(svgString: string, fillColor: string): string;
|
|
535
|
-
/**
|
|
536
|
-
* Encodes an SVG string to a base64 data URL.
|
|
537
|
-
*
|
|
538
|
-
* @param svgString - The SVG markup
|
|
539
|
-
* @param firstPathFill - Optional fill color to apply to the first path, with {@link applyFirstPathFill} (browser only)
|
|
540
|
-
* @returns Base64-encoded data URL (`data:image/svg+xml;base64,…`)
|
|
541
|
-
*/
|
|
542
|
-
declare function svgToBase64(svgString: string, firstPathFill?: string): string;
|
|
543
|
-
/**
|
|
544
|
-
* Formats a name string into a GitHub-compatible SVG filename.
|
|
545
|
-
*
|
|
546
|
-
* Converts spaces to hyphens and lowercases the string,
|
|
547
|
-
* then appends the `.svg` extension.
|
|
548
|
-
*
|
|
549
|
-
* @param name - The name to format (e.g., "Wallet Connect", "MetaMask")
|
|
550
|
-
* @returns Formatted filename (e.g., "wallet-connect.svg", "metamask.svg")
|
|
551
|
-
*
|
|
552
|
-
* @example
|
|
553
|
-
* ```ts
|
|
554
|
-
* import { formatIconNameForGithub } from '@tuwaio/nova-core';
|
|
555
|
-
*
|
|
556
|
-
* formatIconNameForGithub('Wallet Connect'); // → 'wallet-connect.svg'
|
|
557
|
-
* formatIconNameForGithub('MetaMask'); // → 'metamask.svg'
|
|
558
|
-
* ```
|
|
559
|
-
*/
|
|
560
|
-
declare const formatIconNameForGithub: (name: string) => string;
|
|
561
|
-
|
|
562
|
-
/**
|
|
563
|
-
* @file This file contains a utility function for truncating a string with a center ellipsis.
|
|
564
|
-
*/
|
|
565
|
-
/**
|
|
566
|
-
* Truncates a string by showing a specified number of characters from the start and end,
|
|
567
|
-
* with an ellipsis in the middle. If the string is too short to be truncated, it's returned as is.
|
|
568
|
-
*
|
|
569
|
-
* @param {string} str - The string to truncate.
|
|
570
|
-
* @param {number} from - The number of characters to show from the beginning of the string.
|
|
571
|
-
* @param {number} to - The number of characters to show from the end of the string.
|
|
572
|
-
* @returns {string} The truncated string, or the original string if it's too short.
|
|
573
|
-
*
|
|
574
|
-
* @example
|
|
575
|
-
* const hash = '0x1234567890abcdef1234567890abcdef';
|
|
576
|
-
* textCenterEllipsis(hash, 6, 4); // => "0x1234...cdef"
|
|
577
|
-
*
|
|
578
|
-
* textCenterEllipsis('short', 6, 4); // => "short"
|
|
579
|
-
*/
|
|
580
|
-
declare function textCenterEllipsis(str: string | undefined | null, from: number, to: number): string;
|
|
581
|
-
|
|
582
|
-
export { type ChainInfo, ChevronArrowWithAnim, CloseIcon, type CopyToClipboardResult, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, FallbackIcon, type FallbackIconProps, GithubFallbackIcon, type GithubFallbackIconProps, NetworkIcon, type NetworkIconProps, StarsBackground, SvgImg, type SvgImgProps, SvgToImg, type SvgToImgProps, ToastCloseButton, type ToastCloseButtonProps, type UseCopyToClipboardResult, WalletIcon, type WalletIconProps, applyFirstPathFill, cn, deepMerge, formatIconNameForGithub, getChainName, isSolanaDev, isTouchDevice, resolveCssVariable, standardButtonClasses, svgToBase64, textCenterEllipsis, useCopyToClipboard, useMediaQuery };
|
|
390
|
+
export { ChevronArrowWithAnim, CloseIcon, type CopyToClipboardResult, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, FallbackIcon, type FallbackIconProps, GithubFallbackIcon, type GithubFallbackIconProps, NetworkIcon, type NetworkIconProps, StarsBackground, SvgImg, type SvgImgProps, SvgToImg, type SvgToImgProps, ToastCloseButton, type ToastCloseButtonProps, type UseCopyToClipboardResult, WalletIcon, type WalletIconProps, useCopyToClipboard, useMediaQuery };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {motion,AnimatePresence}from'framer-motion';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {networks}from'@web3icons/common/metadata/networks';import {getSolanaCluster}from'@tuwaio/orbit-core';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import*as d from'react';import {useState,useEffect,useCallback,Suspense,useMemo}from'react';import*as l from'@radix-ui/react-dialog';import {Web3IconLazy}from'./web3-icons.js';import {wallets}from'@web3icons/common/metadata/wallets';var Ue="novacore:cursor-pointer novacore:rounded-[var(--tuwa-rounded-corners)] novacore:bg-[var(--tuwa-standart-button-bg)] novacore:px-3 novacore:py-2 novacore:flex novacore:items-center novacore:gap-1 novacore:text-sm novacore:font-mono novacore:font-semibold novacore:text-[var(--tuwa-text-primary)] novacore:transition-colors novacore:hover:bg-[var(--tuwa-standart-button-hover)] novacore:disabled:cursor-not-allowed novacore:disabled:opacity-50 novacore:min-h-[36px]";function s(...e){return twMerge(clsx(e))}var C=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function ee(e,o){let t={...e};return C(e)&&C(o)&&Object.keys(o).forEach(n=>{let r=e[n],a=o[n];C(r)&&C(a)?t[n]=ee(r,a):t[n]=a;}),t}function S(e){if(typeof e!="string")return;let o=e.indexOf(":");if(o<0||e.slice(0,o).toLowerCase()!=="solana")return;let t=e.slice(o+1),n=getSolanaCluster(t)??getSolanaCluster(t.toLowerCase());return n==="devnet"||n==="testnet"?n:void 0}var M="Unknown";function oe(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function G(e){let o={name:M,id:M.toLowerCase(),filePath:M.toLowerCase(),chainId:e};if(typeof e=="number"){let i=networks.find(c=>c.chainId===e);return i?{name:i.name,id:i.id,filePath:i.filePath?.split(":")[1],chainId:e}:o}let[t,n]=e?e.split(":"):[e],r=networks.find(i=>i.id===t);if(!r)return o;let a=n?S(e):void 0;return {name:a?`${r.name} ${oe(a)}`:r.name,id:r.id,filePath:r.filePath?.split(":")[1],chainId:e}}function $(e){return S(e)!==void 0}function B(e=1200){if(typeof window>"u")return false;let o="ontouchstart"in window,t=navigator.maxTouchPoints>0,n=false;window.matchMedia&&(n=window.matchMedia("(pointer: coarse)").matches);let r=o||t||n,a=window.innerWidth<=e;return r&&a}function te(e){if(!e.startsWith("var("))return e;let o=e.match(/var\(\s*(--[\w-]+)/);if(!o)return e;let t=o[1];return getComputedStyle(document.documentElement).getPropertyValue(t).trim()||e}function re(e,o){let t=te(o),r=new DOMParser().parseFromString(e,"image/svg+xml");if(r.querySelector("parsererror"))return console.warn("SVG parse error, returning original"),e;let m=r.querySelector("path");return m&&m.setAttribute("fill",t),new XMLSerializer().serializeToString(r.documentElement)}function N(e,o){let t=e;return o&&(t=re(t,o)),`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(t)))}`}var P=e=>`${e.replace(/\s+/g,"-").toLowerCase()}.svg`;function ao(e,o,t){if(!e)return "";if(e.length<=o+t)return e;let n=e.slice(0,o),r=e.slice(e.length-t);return `${n}...${r}`}function ho({className:e,strokeWidth:o,isOpen:t}){return jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:o??2,stroke:"currentColor",className:s("novacore:w-4 novacore:h-4 novacore:text-[var(--tuwa-text-secondary)]",e),children:[jsx(AnimatePresence,{children:t&&jsx(motion.path,{strokeLinecap:"round",strokeLinejoin:"round",d:"m4.5 15.75 7.5-7.5 7.5 7.5",variants:{hidden:{translateY:3,scaleY:.8,opacity:0},visible:{translateY:0,scaleY:1,opacity:1}},initial:"hidden",animate:"visible",transition:{duration:.4}})}),jsx(AnimatePresence,{children:!t&&jsx(motion.path,{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5",className:"novacore:relative",variants:{hidden:{translateY:-3,scaleY:.8,opacity:0},visible:{translateY:0,scaleY:1,opacity:1}},initial:"hidden",animate:"visible",transition:{duration:.4}})})]})}var ae=d.forwardRef(({className:e,...o},t)=>jsxs("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s("novacore:h-5 novacore:w-5 novacore:text-[var(--tuwa-text-primary)] novacore:transition-colors",e),...o,children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]}));ae.displayName="CloseIcon";var se="novacore:flex novacore:items-center novacore:justify-center novacore:w-full novacore:h-full novacore:rounded-full novacore:text-[var(--tuwa-text-secondary)] novacore:bg-[var(--tuwa-bg-muted)]",f=({animate:e=false,content:o="",className:t})=>jsx("div",{className:s(se,"Nova_Web3_Icon",t,{"novacore:animate-pulse":e}),children:o});function T({src:e,alt:o,...t}){return jsx("img",{...t,src:e,alt:o??"",draggable:false,onDragStart:n=>n.preventDefault(),style:{outline:"none",pointerEvents:"none"}})}var ue="https://raw.githubusercontent.com/0xa3k5/web3icons/refs/heads/main/raw-svgs",L=new Map;function D({githubSrc:e,className:o,alt:t,firstPathFill:n,...r}){let a=`${e}|${n??""}`,m=L.get(a),[i,c]=useState(null),[w,b]=useState("idle"),h=m||i,x=m?"success":w;return useEffect(()=>{let v=true;return L.has(a)?void 0:((async()=>{b("loading");try{let I=await fetch(`${ue}/${e}`);if(!I.ok)throw new Error(`Failed to load icon: ${I.status}`);let Z=await I.text();if(v){let V=N(Z,n);L.set(a,V),c(V),b("success");}}catch{v&&b("error");}})(),()=>{v=false;})},[e,n,a]),x==="loading"||x==="idle"?jsx(f,{animate:true,className:o}):x==="success"&&h?jsx(T,{...r,src:h,alt:t,className:o}):jsx(f,{content:"?",className:o})}var $o=l.Root,Bo=l.Trigger,de=l.Portal,Oo=l.Close,pe={initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,transition:{duration:.2}}},fe={initial:{opacity:0,y:"100%"},animate:{opacity:1,y:"0%"},exit:{opacity:0,y:"100%",transition:{duration:.2}}},ve={initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},K=({className:e,backdropAnimation:o})=>(d.useEffect(()=>(typeof window<"u"&&window.document.body.classList.add("NovaModalOpen"),()=>{typeof window<"u"&&window.document.body.classList.remove("NovaModalOpen");}),[]),jsx(AnimatePresence,{children:jsx(motion.div,{variants:o??ve,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"novacore:relative novacore:overflow-hidden",children:jsx("div",{className:s("novacore:fixed novacore:inset-0 novacore:z-50 novacore:bg-black/55 novacore:backdrop-blur-sm novacore:backdrop-saturate-150",e)})})}));K.displayName=l.Overlay.displayName;var ge=d.forwardRef(({className:e,children:o,modalAnimation:t,backdropAnimation:n,...r},a)=>{let[m,i]=d.useState(false);d.useEffect(()=>{i(B());},[]);let c=t??(m?fe:pe);return jsxs(de,{children:[jsx(K,{backdropAnimation:n}),jsx(l.Content,{"aria-describedby":"tuwa:modal-content",ref:a,className:s("NovaNoScrolling novacore:fixed novacore:bottom-0 novacore:left-0 novacore:p-0 novacore:sm:bottom-auto novacore:sm:left-[50%] novacore:sm:top-[50%] novacore:sm:translate-x-[-50%] novacore:sm:translate-y-[-50%] novacore:z-50 novacore:sm:p-4 novacore:outline-none",e),...r,children:jsx(motion.div,{layout:true,className:"NovaNoScrolling novacore:relative novacore:overflow-hidden",transition:{layout:{duration:.2,ease:[.1,.1,.2,1]}},children:jsx(AnimatePresence,{children:jsx(motion.div,{variants:c,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"NovaNoScrolling novacore:relative novacore:overflow-hidden novacore:bg-[var(--tuwa-bg-primary)] novacore:border novacore:border-[var(--tuwa-border-primary)] novacore:rounded-t-[var(--tuwa-rounded-corners)] novacore:sm:rounded-[var(--tuwa-rounded-corners)]",children:jsx("div",{className:s("NovaNoScrolling NovaDialogContent__elements novacore:relative novacore:flex novacore:max-h-[100dvh] novacore:w-full novacore:flex-col novacore:overflow-y-auto","novacore:[transform:translateZ(0)] novacore:[backface-visibility:hidden]"),children:o})})})})})]})});ge.displayName=l.Content.displayName;var we=({className:e,...o})=>jsx("div",{"aria-describedby":"tuwa:modal-header",className:s("novacore:sticky novacore:flex novacore:top-0 novacore:z-11 novacore:w-full novacore:flex-row novacore:items-center novacore:justify-between","novacore:border-b novacore:border-[var(--tuwa-border-primary)] novacore:bg-[var(--tuwa-bg-primary)] novacore:p-4",e),...o});we.displayName="DialogHeader";var be=({className:e,...o})=>jsx("div",{"aria-describedby":"tuwa:modal-footer",className:s("novacore:flex novacore:flex-col-reverse novacore:sm:flex-row novacore:sm:justify-end novacore:sm:space-x-2",e),...o});be.displayName="DialogFooter";var he=d.forwardRef(({className:e,...o},t)=>jsx(l.Title,{ref:t,"aria-describedby":"tuwa:modal-title",className:s("novacore:text-lg novacore:font-bold novacore:leading-none novacore:tracking-tight novacore:text-[var(--tuwa-text-primary)] novacore:m-0 novacore:font-mono",e),...o}));he.displayName=l.Title.displayName;var ye=d.forwardRef(({className:e,...o},t)=>jsx(l.Description,{"aria-describedby":"tuwa:modal-description",ref:t,className:s("novacore:text-sm novacore:text-[var(--tuwa-text-secondary)]",e),...o}));ye.displayName=l.Description.displayName;function y({children:e,iconId:o,alt:t,firstPathFill:n,...r}){let[a,m]=useState(null),i=useCallback(c=>{if(c){let w=N(c.outerHTML,n);m({id:o,src:w});}},[o,n]);return a&&a.id===o?jsx(T,{...r,src:a.src,alt:t}):jsx(Fragment,{children:e(i)})}var De="var(--tuwa-testnet-icons)";function at({chainId:e,variant:o="background",className:t}){let n=G(e),r=typeof e=="string",a=r?e.split(":")[0].toLowerCase():e,i=r&&$(e)||n.name.toLowerCase().includes("testnet")?De:void 0,c=s("novacore:w-full novacore:h-full novacore:rounded-full",t),w=typeof a=="string"?a:n.filePath,b=`networks/${o}/${P(w)}`,h=networks.find(v=>v.id===n.id)?.filePath;return n.name==="Unknown"||!h?typeof e=="number"?jsx(f,{content:"?",className:t}):jsx(D,{githubSrc:b,className:c,firstPathFill:i}):jsx(Suspense,{fallback:jsx(f,{animate:true,className:t}),children:jsx(y,{iconId:`${e}-${o}`,className:c,firstPathFill:i,children:v=>jsx(Web3IconLazy,{ref:v,filePath:h,variant:o})})})}function lt({starsCount:e}){let[o,t]=useState(false);useEffect(()=>t(true),[]);let n=useMemo(()=>o?Array.from({length:e??200}).map(()=>({x:Math.random()*window.innerWidth,y:Math.random()*window.innerHeight,r:Math.random()*1+.5,isSupernova:Math.random()<.1,delay:Math.random()*10,duration:5+Math.random()*5})):[],[o]);return jsx("div",{className:"novacore:absolute novacore:inset-0 novacore:z-1 novacore:h-full novacore:w-full novacore:overflow-hidden",children:jsxs("svg",{width:"100%",height:"100%",xmlns:"http://www.w3.org/2000/svg",children:[jsx("defs",{children:jsx("style",{children:`
|
|
1
|
+
import {b,f,i,d,e,j}from'./chunk-VLQ5TKDD.js';export{h as applyFirstPathFill,b as cn,c as deepMerge,j as formatIconNameForGithub,d as getChainName,e as isSolanaDev,f as isTouchDevice,g as resolveCssVariable,a as standardButtonClasses,i as svgToBase64,k as textCenterEllipsis}from'./chunk-VLQ5TKDD.js';import {motion,AnimatePresence}from'framer-motion';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import*as v from'react';import {useState,useEffect,useCallback,Suspense,useMemo}from'react';import*as s from'@radix-ui/react-dialog';import {networks}from'@web3icons/common/metadata/networks';import {Web3IconLazy}from'./web3-icons.js';import {wallets}from'@web3icons/common/metadata/wallets';function Bo({className:o,strokeWidth:e,isOpen:t}){return jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:e??2,stroke:"currentColor",className:b("novacore:w-4 novacore:h-4 novacore:text-[var(--tuwa-text-secondary)]",o),children:[jsx(AnimatePresence,{children:t&&jsx(motion.path,{strokeLinecap:"round",strokeLinejoin:"round",d:"m4.5 15.75 7.5-7.5 7.5 7.5",variants:{hidden:{translateY:3,scaleY:.8,opacity:0},visible:{translateY:0,scaleY:1,opacity:1}},initial:"hidden",animate:"visible",transition:{duration:.4}})}),jsx(AnimatePresence,{children:!t&&jsx(motion.path,{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5",className:"novacore:relative",variants:{hidden:{translateY:-3,scaleY:.8,opacity:0},visible:{translateY:0,scaleY:1,opacity:1}},initial:"hidden",animate:"visible",transition:{duration:.4}})})]})}var K=v.forwardRef(({className:o,...e},t)=>jsxs("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b("novacore:h-5 novacore:w-5 novacore:text-[var(--tuwa-text-primary)] novacore:transition-colors",o),...e,children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]}));K.displayName="CloseIcon";var Z="novacore:flex novacore:items-center novacore:justify-center novacore:w-full novacore:h-full novacore:rounded-full novacore:text-[var(--tuwa-text-secondary)] novacore:bg-[var(--tuwa-bg-muted)]",u=({animate:o=false,content:e="",className:t})=>jsx("div",{className:b(Z,"Nova_Web3_Icon",t,{"novacore:animate-pulse":o}),children:e});function P({src:o,alt:e,...t}){return jsx("img",{...t,src:o,alt:e??"",draggable:false,onDragStart:r=>r.preventDefault(),style:{outline:"none",pointerEvents:"none"}})}var oo="https://raw.githubusercontent.com/0xa3k5/web3icons/refs/heads/main/raw-svgs",R=new Map;function C({githubSrc:o,className:e,alt:t,firstPathFill:r,...a}){let n=`${o}|${r??""}`,d=R.get(n),[l,c]=useState(null),[w,b]=useState("idle"),y=d||l,x=d?"success":w;return useEffect(()=>{let f=true;return R.has(n)?void 0:((async()=>{b("loading");try{let D=await fetch(`${oo}/${o}`);if(!D.ok)throw new Error(`Failed to load icon: ${D.status}`);let U=await D.text();if(f){let E=i(U,r);R.set(n,E),c(E),b("success");}}catch{f&&b("error");}})(),()=>{f=false;})},[o,r,n]),x==="loading"||x==="idle"?jsx(u,{animate:true,className:e}):x==="success"&&y?jsx(P,{...a,src:y,alt:t,className:e}):jsx(u,{content:"?",className:e})}var ce=s.Root,le=s.Trigger,eo=s.Portal,me=s.Close,to={initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,transition:{duration:.2}}},ao={initial:{opacity:0,y:"100%"},animate:{opacity:1,y:"0%"},exit:{opacity:0,y:"100%",transition:{duration:.2}}},ro={initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},_=({className:o,backdropAnimation:e})=>(v.useEffect(()=>(typeof window<"u"&&window.document.body.classList.add("NovaModalOpen"),()=>{typeof window<"u"&&window.document.body.classList.remove("NovaModalOpen");}),[]),jsx(AnimatePresence,{children:jsx(motion.div,{variants:e??ro,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"novacore:relative novacore:overflow-hidden",children:jsx("div",{className:b("novacore:fixed novacore:inset-0 novacore:z-50 novacore:bg-black/55 novacore:backdrop-blur-sm novacore:backdrop-saturate-150",o)})})}));_.displayName=s.Overlay.displayName;var no=v.forwardRef(({className:o,children:e,modalAnimation:t,backdropAnimation:r,...a},n)=>{let[d,l]=v.useState(false);v.useEffect(()=>{l(f());},[]);let c=t??(d?ao:to);return jsxs(eo,{children:[jsx(_,{backdropAnimation:r}),jsx(s.Content,{"aria-describedby":"tuwa:modal-content",ref:n,className:b("NovaNoScrolling novacore:fixed novacore:bottom-0 novacore:left-0 novacore:p-0 novacore:sm:bottom-auto novacore:sm:left-[50%] novacore:sm:top-[50%] novacore:sm:translate-x-[-50%] novacore:sm:translate-y-[-50%] novacore:z-50 novacore:sm:p-4 novacore:outline-none",o),...a,children:jsx(motion.div,{layout:true,className:"NovaNoScrolling novacore:relative novacore:overflow-hidden",transition:{layout:{duration:.2,ease:[.1,.1,.2,1]}},children:jsx(AnimatePresence,{children:jsx(motion.div,{variants:c,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"NovaNoScrolling novacore:relative novacore:overflow-hidden novacore:bg-[var(--tuwa-bg-primary)] novacore:border novacore:border-[var(--tuwa-border-primary)] novacore:rounded-t-[var(--tuwa-rounded-corners)] novacore:sm:rounded-[var(--tuwa-rounded-corners)]",children:jsx("div",{className:b("NovaNoScrolling NovaDialogContent__elements novacore:relative novacore:flex novacore:max-h-[100dvh] novacore:w-full novacore:flex-col novacore:overflow-y-auto","novacore:[transform:translateZ(0)] novacore:[backface-visibility:hidden]"),children:e})})})})})]})});no.displayName=s.Content.displayName;var io=({className:o,...e})=>jsx("div",{"aria-describedby":"tuwa:modal-header",className:b("novacore:sticky novacore:flex novacore:top-0 novacore:z-11 novacore:w-full novacore:flex-row novacore:items-center novacore:justify-between","novacore:border-b novacore:border-[var(--tuwa-border-primary)] novacore:bg-[var(--tuwa-bg-primary)] novacore:p-4",o),...e});io.displayName="DialogHeader";var so=({className:o,...e})=>jsx("div",{"aria-describedby":"tuwa:modal-footer",className:b("novacore:flex novacore:flex-col-reverse novacore:sm:flex-row novacore:sm:justify-end novacore:sm:space-x-2",o),...e});so.displayName="DialogFooter";var co=v.forwardRef(({className:o,...e},t)=>jsx(s.Title,{ref:t,"aria-describedby":"tuwa:modal-title",className:b("novacore:text-lg novacore:font-bold novacore:leading-none novacore:tracking-tight novacore:text-[var(--tuwa-text-primary)] novacore:m-0 novacore:font-mono",o),...e}));co.displayName=s.Title.displayName;var lo=v.forwardRef(({className:o,...e},t)=>jsx(s.Description,{"aria-describedby":"tuwa:modal-description",ref:t,className:b("novacore:text-sm novacore:text-[var(--tuwa-text-secondary)]",o),...e}));lo.displayName=s.Description.displayName;function h({children:o,iconId:e,alt:t,firstPathFill:r,...a}){let[n,d]=useState(null),l=useCallback(c=>{if(c){let w=i(c.outerHTML,r);d({id:e,src:w});}},[e,r]);return n&&n.id===e?jsx(P,{...a,src:n.src,alt:t}):jsx(Fragment,{children:o(l)})}var bo="var(--tuwa-testnet-icons)";function Ie({chainId:o,variant:e$1="background",className:t}){let r=d(o),a=typeof o=="string",n=a?o.split(":")[0].toLowerCase():o,l=a&&e(o)||r.name.toLowerCase().includes("testnet")?bo:void 0,c=b("novacore:w-full novacore:h-full novacore:rounded-full",t),w=typeof n=="string"?n:r.filePath,b$1=`networks/${e$1}/${j(w)}`,y=networks.find(f=>f.id===r.id)?.filePath;return r.name==="Unknown"||!y?typeof o=="number"?jsx(u,{content:"?",className:t}):jsx(C,{githubSrc:b$1,className:c,firstPathFill:l}):jsx(Suspense,{fallback:jsx(u,{animate:true,className:t}),children:jsx(h,{iconId:`${o}-${e$1}`,className:c,firstPathFill:l,children:f=>jsx(Web3IconLazy,{ref:f,filePath:y,variant:e$1})})})}function Me({starsCount:o}){let[e,t]=useState(false);useEffect(()=>t(true),[]);let r=useMemo(()=>e?Array.from({length:o??200}).map(()=>({x:Math.random()*window.innerWidth,y:Math.random()*window.innerHeight,r:Math.random()*1+.5,isSupernova:Math.random()<.1,delay:Math.random()*10,duration:5+Math.random()*5})):[],[e]);return jsx("div",{className:"novacore:absolute novacore:inset-0 novacore:z-1 novacore:h-full novacore:w-full novacore:overflow-hidden",children:jsxs("svg",{width:"100%",height:"100%",xmlns:"http://www.w3.org/2000/svg",children:[jsx("defs",{children:jsx("style",{children:`
|
|
2
2
|
/* Pulse animation now includes scale for a more organic feel. */
|
|
3
3
|
@keyframes pulse {
|
|
4
4
|
0%, 100% {
|
|
@@ -44,5 +44,5 @@ import {motion,AnimatePresence}from'framer-motion';import {clsx}from'clsx';impor
|
|
|
44
44
|
transform-origin: center;
|
|
45
45
|
stroke-width: 2;
|
|
46
46
|
}
|
|
47
|
-
`})}),
|
|
48
|
-
export{
|
|
47
|
+
`})}),r.map((a,n)=>jsx("circle",{cx:a.x,cy:a.y,r:a.r,fill:"rgba(var(--tuwa-bg-primary), 0.7)",className:a.isSupernova?"supernova":"pulsar",style:{animationDelay:`${a.delay}s`,animationDuration:`${a.duration}s`}},n))]})})}function Fe({closeToast:o,ariaLabel:e="Close toast notification",title:t="Close toast notification",className:r,iconClassName:a}){return jsx("button",{type:"button",onClick:o,"aria-label":e,title:t,className:b("novacore:absolute novacore:top-2 novacore:right-2 novacore:cursor-pointer novacore:rounded-[var(--tuwa-rounded-corners)] novacore:p-1","novacore:text-[var(--tuwa-text-tertiary)] novacore:transition-colors","novacore:hover:bg-[var(--tuwa-bg-muted)] novacore:hover:text-[var(--tuwa-text-primary)]",r),children:jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:b("novacore:h-5 novacore:w-5",a),children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})})})}var Co={walletconnect:"wallet-connect"};function Io(o){return wallets.find(e=>e.id===o||e.name?.toLowerCase()===o)?.filePath}var Do=({className:o,ref:e})=>jsxs("svg",{ref:e,className:o,fill:"none",viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{fill:"#fff",fillRule:"evenodd",d:"M16 0c8.84 0 16 7.16 16 16s-7.16 16-16 16S0 24.84 0 16 7.16 0 16 0",clipRule:"evenodd"}),jsx("path",{fill:"#000",fillRule:"evenodd",d:"M16.54 2.01h1.53c.5.09.99.23 1.48.42.21.25.19.48-.05.69q-.195.045-.39 0c-1.86-.65-3.55-.35-5.07.89 2.39.7 3.84 2.27 4.36 4.7.12.85.08 1.68-.12 2.51.87 0 1.74 0 2.61-.02.39-.4.7-.85.94-1.35-.45-.45-.65-.99-.59-1.63-1.15.08-1.79-.44-1.92-1.58.14-1.12.78-1.67 1.92-1.63a.7.7 0 0 0-.12-.49l-.89-.89c-.02-.45.19-.6.62-.47.24.19.46.39.66.62.71-.79 1.5-.89 2.39-.32.44.42.62.94.54 1.55 1.49.02 2.11.76 1.85 2.22-.08.17-.17.34-.27.49.53.59.87 1.28 1.01 2.07.08 4.6.1 9.19.05 13.79-.19 1.58-1 2.71-2.44 3.37-.29.1-.59.2-.89.27H7.2c-1.31-.33-2.05-1.17-2.24-2.51-.03-5.24-.03-10.47 0-15.71.3-1.62 1.28-2.46 2.93-2.54 1.26-1.77 2.98-2.64 5.17-2.61.96-1.01 2.13-1.62 3.5-1.85zm6.11 1.87c.39-.03.7.12.91.44.06.39.09.79.1 1.18.02.12.07.21.17.27.41 0 .82.04 1.23.1.49.26.63.65.42 1.16-.07.14-.18.25-.32.32-.39.06-.79.09-1.18.1-.12.02-.21.07-.27.17l-.15 1.33c-.32.46-.72.55-1.21.27a.76.76 0 0 1-.27-.37c-.06-.41-.09-.82-.1-1.23a.35.35 0 0 0-.27-.17l-1.08-.05c-.46-.24-.62-.61-.47-1.11.14-.27.36-.43.66-.47l.99-.05s.09-.04.12-.07l.15-1.28q.18-.39.57-.54m-10.49.79c2.41-.09 4.12.94 5.15 3.1.44 1.12.48 2.25.12 3.4-.84.06-1.67.07-2.51.02.56-.68.52-1.32-.1-1.92-.26-.13-.54-.19-.84-.17.02-.95 0-1.91-.07-2.86-.21-.41-.55-.58-1.01-.52-.17.03-.31.09-.44.2-.72.92-1.43 1.85-2.14 2.78-.28.45-.29.91-.05 1.38q.225.3.57.42c.34.02.69.03 1.03.02v.69c-1.3.02-2.59 0-3.89-.05-.58-2.1-.08-3.88 1.53-5.34.79-.62 1.68-1 2.66-1.16zm.83 1.82c.07 0 .13.03.17.1l.05 3.05c.04.09.1.16.17.22l.89.05c.22.08.3.24.22.47q-.27.42-.57.81c-.43.02-.85.03-1.28.02 0-.41 0-.82-.02-1.23a.46.46 0 0 0-.17-.17l-1.28-.05c-.3-.1-.37-.29-.22-.57.7-.89 1.39-1.79 2.04-2.71zm-5.81.84h.2a6.1 6.1 0 0 0-.25 3.77c-.59-.13-1.01-.49-1.26-1.06-.36-1.29.08-2.19 1.31-2.71m17.98.83c.05 0 .1 0 .15.02q.825.855.96 2.04.045 1.305 0 2.61a3.76 3.76 0 0 0-2.54-1.55c-.61-.05-1.21-.08-1.82-.1.26-.31.48-.66.64-1.03 1.31.02 1.94-.62 1.87-1.95.26.02.5 0 .74-.05zM5.7 11.22c.41.4.91.65 1.48.76l16.06.05c1.42.13 2.38.87 2.88 2.19.07.24.12.49.15.74.03 2.86.03 5.71 0 8.57-.21 1.44-1 2.38-2.39 2.83-.24.05-.49.08-.74.1-1.26.02-2.53.03-3.79.02 0-1.33 0-2.66.02-3.99l1.55-1.55c1.42-.04 2.09-.78 1.99-2.19-.24-.88-.81-1.34-1.72-1.38-1.2.12-1.81.8-1.82 2.02l-1.92 1.92c-.08.11-.14.22-.2.34-.07 1.61-.1 3.22-.07 4.83h-.44c0-2.28 0-4.56-.02-6.85a1.8 1.8 0 0 0-.15-.34l-1.13-1.13c0-1.23-.61-1.92-1.82-2.07-1.29.17-1.87.91-1.72 2.22q.465 1.395 1.95 1.35l.71.71c0 .3.04.6.1.89.25.21.48.19.69-.05.03-.39.03-.79 0-1.18-.2-.25-.43-.49-.66-.71.15-.1.29-.22.39-.37.3.27.58.55.86.84.02 2.23.03 4.47.02 6.7h-.59c0-1.38 0-2.76-.02-4.14-.15-.25-.35-.31-.62-.17a1 1 0 0 0-.12.22c-.02 1.36-.03 2.73-.02 4.09h-.44c0-.99 0-1.97-.02-2.96-.02-.09-.06-.17-.1-.25-.67-.72-1.36-1.43-2.07-2.12-.06-1.48-.82-2.13-2.29-1.95-1.02.41-1.42 1.16-1.21 2.24q.51 1.32 1.95 1.26l1.55 1.55c.02.74.03 1.48.02 2.22-1.56.02-3.12 0-4.68-.07-.9-.24-1.42-.83-1.55-1.75-.02-4.48-.03-8.96-.02-13.45zm7.79 5.66c.84.06 1.19.5 1.06 1.33-.32.62-.8.79-1.45.52-.46-.37-.56-.82-.32-1.35.18-.26.42-.42.71-.49zm7.43 1.28c.89-.03 1.29.4 1.21 1.28-.33.67-.83.85-1.5.52-.54-.49-.58-1-.1-1.55.12-.11.25-.19.39-.25M9.94 19.94c.84 0 1.22.4 1.16 1.23-.28.68-.76.89-1.45.62-.63-.54-.65-1.09-.05-1.67l.34-.17zm9.75.24c.16.13.3.27.44.42-.53.52-1.05 1.05-1.55 1.6-.02 1.43-.03 2.86-.02 4.28h-.59c0-1.51 0-3.02.02-4.53a71 71 0 0 1 1.7-1.77M11.56 22c.62.53 1.21 1.11 1.75 1.72.02.92.03 1.84.02 2.76h-.59c0-.85 0-1.71-.02-2.56l-1.48-1.48s-.03-.07 0-.1c.12-.11.22-.22.32-.34",clipRule:"evenodd"})]});function Ye({walletName:o,variant:e="background",className:t}){let r=b("novacore:w-full novacore:h-full novacore:rounded-full",t),a=o.toLowerCase();if(a==="impersonatedwallet")return jsx(h,{iconId:"impersonatedwallet",className:r,children:c=>jsx(Do,{ref:c})});let n=Co[a]??a,d=`wallets/${e}/${j(n)}`,l=Io(n);return l?jsx(Suspense,{fallback:jsx(u,{animate:true,className:t}),children:jsx(h,{iconId:`${n}-${e}`,className:r,children:c=>jsx(Web3IconLazy,{ref:c,filePath:l,variant:e})})}):jsx(C,{githubSrc:d,className:r})}function Qe(o=2e3){let[e,t]=useState(false),[r,a]=useState(null),n=useCallback(async d=>{if(!d)return {copied:false,error:new Error("There is no text to copy.")};try{return await navigator.clipboard.writeText(d),t(!0),a(null),setTimeout(()=>t(!1),o),{copied:!0}}catch(l){let c=l instanceof Error?l:new Error("Failed to copy text.");return console.error(c),a(c),setTimeout(()=>a(null),o),{copied:false,error:c}}},[o]);return {isCopied:e,copy:n,error:r}}function Xe(o){let e=a=>typeof window<"u"?window.matchMedia(a).matches:false,[t,r]=useState(e(o));return useEffect(()=>{let a=window.matchMedia(o),n=()=>r(a.matches);return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[o]),t}
|
|
48
|
+
export{Bo as ChevronArrowWithAnim,K as CloseIcon,ce as Dialog,me as DialogClose,no as DialogContent,lo as DialogDescription,so as DialogFooter,io as DialogHeader,_ as DialogOverlay,eo as DialogPortal,co as DialogTitle,le as DialogTrigger,u as FallbackIcon,C as GithubFallbackIcon,Ie as NetworkIcon,Me as StarsBackground,P as SvgImg,h as SvgToImg,Fe as ToastCloseButton,Ye as WalletIcon,Qe as useCopyToClipboard,Xe as useMediaQuery};
|
package/dist/utils.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkLLVSKNQR_cjs=require('./chunk-LLVSKNQR.cjs');Object.defineProperty(exports,"applyFirstPathFill",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.h}});Object.defineProperty(exports,"cn",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.b}});Object.defineProperty(exports,"deepMerge",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.c}});Object.defineProperty(exports,"formatIconNameForGithub",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.j}});Object.defineProperty(exports,"getChainName",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.d}});Object.defineProperty(exports,"isSolanaDev",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.e}});Object.defineProperty(exports,"isTouchDevice",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.f}});Object.defineProperty(exports,"resolveCssVariable",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.g}});Object.defineProperty(exports,"standardButtonClasses",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.a}});Object.defineProperty(exports,"svgToBase64",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.i}});Object.defineProperty(exports,"textCenterEllipsis",{enumerable:true,get:function(){return chunkLLVSKNQR_cjs.k}});
|
package/dist/utils.d.cts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Classes of the standard secondary button of Nova (Tailwind utilities with the `novacore:` prefix, styled with the
|
|
5
|
+
* `--tuwa-standart-button-*` variables). The connect modal uses them for its buttons.
|
|
6
|
+
*/
|
|
7
|
+
declare const standardButtonClasses = "novacore:cursor-pointer novacore:rounded-[var(--tuwa-rounded-corners)] novacore:bg-[var(--tuwa-standart-button-bg)] novacore:px-3 novacore:py-2 novacore:flex novacore:items-center novacore:gap-1 novacore:text-sm novacore:font-mono novacore:font-semibold novacore:text-[var(--tuwa-text-primary)] novacore:transition-colors novacore:hover:bg-[var(--tuwa-standart-button-hover)] novacore:disabled:cursor-not-allowed novacore:disabled:opacity-50 novacore:min-h-[36px]";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @file This file contains a utility function for conditionally merging Tailwind CSS classes.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A utility function to conditionally join class names together and resolve
|
|
15
|
+
* conflicting Tailwind CSS classes.
|
|
16
|
+
*
|
|
17
|
+
* It combines the functionality of `clsx` and `tailwind-merge`.
|
|
18
|
+
*
|
|
19
|
+
* @param {...ClassValue[]} inputs - A list of class values to be combined.
|
|
20
|
+
* This can include strings, numbers, objects, arrays, and booleans.
|
|
21
|
+
* @returns {string} The final, merged class name string.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* cn('p-4', 'bg-red-500', { 'font-bold': true }); // => 'p-4 bg-red-500 font-bold'
|
|
25
|
+
* cn('p-2', 'p-4'); // => 'p-4' (tailwind-merge resolves the conflict)
|
|
26
|
+
*
|
|
27
|
+
* @see https://github.com/dcastil/tailwind-merge
|
|
28
|
+
* @see https://github.com/lukeed/clsx
|
|
29
|
+
*/
|
|
30
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @file This file contains a utility for performing a deep (recursive) merge of two objects.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* Recursively merges the properties of a source object into a target object.
|
|
37
|
+
* This function creates a new object and does not mutate the original target.
|
|
38
|
+
*
|
|
39
|
+
* @template T - The type of the objects being merged.
|
|
40
|
+
* @param {T} target - The base object.
|
|
41
|
+
* @param {Partial<T>} source - The object with properties to merge into the target.
|
|
42
|
+
* @returns {T} A new object representing the merged result.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const defaults = { a: 1, b: { c: 2, d: 3 } };
|
|
46
|
+
* const custom = { b: { c: 99 } };
|
|
47
|
+
* const result = deepMerge(defaults, custom);
|
|
48
|
+
* // result will be { a: 1, b: { c: 99, d: 3 } }
|
|
49
|
+
*/
|
|
50
|
+
declare function deepMerge<T extends object>(target: T, source: Partial<T>): T;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Result of chain name resolution.
|
|
54
|
+
*/
|
|
55
|
+
interface ChainInfo {
|
|
56
|
+
/** Human-readable network name (e.g., "Ethereum", "Solana Devnet") */
|
|
57
|
+
name: string;
|
|
58
|
+
/** Normalized network identifier for icon libraries (e.g., "ethereum", "solana") */
|
|
59
|
+
id: string;
|
|
60
|
+
/** Original chain ID as provided */
|
|
61
|
+
chainId: number | string;
|
|
62
|
+
/** File path for icon resolution */
|
|
63
|
+
filePath: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Retrieves blockchain network information based on its chain ID.
|
|
67
|
+
*
|
|
68
|
+
* Supports both EVM and non-EVM chain identifiers:
|
|
69
|
+
* - **Numeric IDs (EVM):** e.g., `1` → "Ethereum", `137` → "Polygon"
|
|
70
|
+
* - **String IDs (Non-EVM):** e.g., `"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"` or `"solana:devnet"` → "Solana Devnet"
|
|
71
|
+
*
|
|
72
|
+
* For Solana dev and test clusters, given as the genesis-hash chain ID of CAIP-30 or as the cluster name
|
|
73
|
+
* (`solana:devnet`), the cluster is appended to the name. Mainnet (`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`) is
|
|
74
|
+
* "Solana".
|
|
75
|
+
*
|
|
76
|
+
* The networks are looked up in the metadata of `@web3icons/common`.
|
|
77
|
+
*
|
|
78
|
+
* @param chainId - Chain identifier (number for EVM, string for non-EVM)
|
|
79
|
+
* @returns The network name, id and icon file path, and the original `chainId`; `'Unknown'`/`'unknown'` when the
|
|
80
|
+
* network is not listed.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { getChainName } from '@tuwaio/nova-core';
|
|
85
|
+
*
|
|
86
|
+
* getChainName(1);
|
|
87
|
+
* // → { name: 'Ethereum', id: 'ethereum', filePath: 'ethereum', chainId: 1 }
|
|
88
|
+
*
|
|
89
|
+
* getChainName('solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1');
|
|
90
|
+
* // → { name: 'Solana Devnet', id: 'solana', filePath: 'solana', chainId: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1' }
|
|
91
|
+
*
|
|
92
|
+
* getChainName(999999);
|
|
93
|
+
* // → { name: 'Unknown', id: 'unknown', filePath: 'unknown', chainId: 999999 }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
declare function getChainName(chainId: number | string): ChainInfo;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Determines if the current chain is a Solana development or test network.
|
|
100
|
+
*
|
|
101
|
+
* It checks that the ID is a Solana chain ID (or a string containing 'solana') that names a non-production cluster:
|
|
102
|
+
* the genesis-hash chain ID of devnet or testnet (CAIP-30, e.g. `solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1`), or
|
|
103
|
+
* 'devnet' / 'testnet' in any letter case (e.g. `solana:devnet`).
|
|
104
|
+
*
|
|
105
|
+
* @param chainId - The chain identifier (e.g., "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", "solana:devnet", 1).
|
|
106
|
+
* @returns {boolean} True only if it is a Solana dev/test chain.
|
|
107
|
+
*/
|
|
108
|
+
declare function isSolanaDev(chainId: number | string): boolean;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @file Utility function to determine if the current environment supports touch input.
|
|
112
|
+
* This is safe to use in Next.js applications as it checks for the `window` object existence.
|
|
113
|
+
*/
|
|
114
|
+
/**
|
|
115
|
+
* Determines if the current browsing device supports touch input,
|
|
116
|
+
* while also excluding large screens (typically desktop-sized touch monitors).
|
|
117
|
+
*
|
|
118
|
+
* It checks for:
|
|
119
|
+
* 1. The presence of 'ontouchstart' or navigator.maxTouchPoints > 0 or '(pointer: coarse)'.
|
|
120
|
+
* 2. ONLY returns true if the screen width is less than or equal to the specified threshold (e.g., 1200px).
|
|
121
|
+
*
|
|
122
|
+
* This function is safe for server-side rendering (SSR) environments like Next.js.
|
|
123
|
+
*
|
|
124
|
+
* @param {number} [maxWidth=1200] The maximum screen width (in pixels) for a device to be considered 'touch' (default
|
|
125
|
+
* is 1200).
|
|
126
|
+
* @returns {boolean} Returns true if the environment is determined to support touch input AND is within the width
|
|
127
|
+
* limit, otherwise false.
|
|
128
|
+
*/
|
|
129
|
+
declare function isTouchDevice(maxWidth?: number): boolean;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Resolves a CSS variable to its computed value on `document.documentElement`.
|
|
133
|
+
* Returns the original value if it's not a CSS variable. Call it in the browser: it reads `getComputedStyle`.
|
|
134
|
+
*
|
|
135
|
+
* @param value - Color value, potentially a CSS variable like `var(--my-color)`
|
|
136
|
+
* @returns Resolved color value (e.g., `#ff0000`) or original if not a variable
|
|
137
|
+
*/
|
|
138
|
+
declare function resolveCssVariable(value: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* Modifies the fill attribute of the first `<path>` element in an SVG string.
|
|
141
|
+
* Uses DOMParser for safe XML manipulation, so call it in the browser.
|
|
142
|
+
* Automatically resolves CSS variables (e.g., `var(--color)`) to their computed values with {@link resolveCssVariable}.
|
|
143
|
+
*
|
|
144
|
+
* @param svgString - The original SVG markup
|
|
145
|
+
* @param fillColor - The color to apply (supports CSS variables)
|
|
146
|
+
* @returns Modified SVG string, or the original string (with a console warning) when it cannot be parsed
|
|
147
|
+
*/
|
|
148
|
+
declare function applyFirstPathFill(svgString: string, fillColor: string): string;
|
|
149
|
+
/**
|
|
150
|
+
* Encodes an SVG string to a base64 data URL.
|
|
151
|
+
*
|
|
152
|
+
* @param svgString - The SVG markup
|
|
153
|
+
* @param firstPathFill - Optional fill color to apply to the first path, with {@link applyFirstPathFill} (browser only)
|
|
154
|
+
* @returns Base64-encoded data URL (`data:image/svg+xml;base64,…`)
|
|
155
|
+
*/
|
|
156
|
+
declare function svgToBase64(svgString: string, firstPathFill?: string): string;
|
|
157
|
+
/**
|
|
158
|
+
* Formats a name string into a GitHub-compatible SVG filename.
|
|
159
|
+
*
|
|
160
|
+
* Converts spaces to hyphens and lowercases the string,
|
|
161
|
+
* then appends the `.svg` extension.
|
|
162
|
+
*
|
|
163
|
+
* @param name - The name to format (e.g., "Wallet Connect", "MetaMask")
|
|
164
|
+
* @returns Formatted filename (e.g., "wallet-connect.svg", "metamask.svg")
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* import { formatIconNameForGithub } from '@tuwaio/nova-core';
|
|
169
|
+
*
|
|
170
|
+
* formatIconNameForGithub('Wallet Connect'); // → 'wallet-connect.svg'
|
|
171
|
+
* formatIconNameForGithub('MetaMask'); // → 'metamask.svg'
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
declare const formatIconNameForGithub: (name: string) => string;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @file This file contains a utility function for truncating a string with a center ellipsis.
|
|
178
|
+
*/
|
|
179
|
+
/**
|
|
180
|
+
* Truncates a string by showing a specified number of characters from the start and end,
|
|
181
|
+
* with an ellipsis in the middle. If the string is too short to be truncated, it's returned as is.
|
|
182
|
+
*
|
|
183
|
+
* @param {string} str - The string to truncate.
|
|
184
|
+
* @param {number} from - The number of characters to show from the beginning of the string.
|
|
185
|
+
* @param {number} to - The number of characters to show from the end of the string.
|
|
186
|
+
* @returns {string} The truncated string, or the original string if it's too short.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* const hash = '0x1234567890abcdef1234567890abcdef';
|
|
190
|
+
* textCenterEllipsis(hash, 6, 4); // => "0x1234...cdef"
|
|
191
|
+
*
|
|
192
|
+
* textCenterEllipsis('short', 6, 4); // => "short"
|
|
193
|
+
*/
|
|
194
|
+
declare function textCenterEllipsis(str: string | undefined | null, from: number, to: number): string;
|
|
195
|
+
|
|
196
|
+
export { type ChainInfo, applyFirstPathFill, cn, deepMerge, formatIconNameForGithub, getChainName, isSolanaDev, isTouchDevice, resolveCssVariable, standardButtonClasses, svgToBase64, textCenterEllipsis };
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Classes of the standard secondary button of Nova (Tailwind utilities with the `novacore:` prefix, styled with the
|
|
5
|
+
* `--tuwa-standart-button-*` variables). The connect modal uses them for its buttons.
|
|
6
|
+
*/
|
|
7
|
+
declare const standardButtonClasses = "novacore:cursor-pointer novacore:rounded-[var(--tuwa-rounded-corners)] novacore:bg-[var(--tuwa-standart-button-bg)] novacore:px-3 novacore:py-2 novacore:flex novacore:items-center novacore:gap-1 novacore:text-sm novacore:font-mono novacore:font-semibold novacore:text-[var(--tuwa-text-primary)] novacore:transition-colors novacore:hover:bg-[var(--tuwa-standart-button-hover)] novacore:disabled:cursor-not-allowed novacore:disabled:opacity-50 novacore:min-h-[36px]";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @file This file contains a utility function for conditionally merging Tailwind CSS classes.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A utility function to conditionally join class names together and resolve
|
|
15
|
+
* conflicting Tailwind CSS classes.
|
|
16
|
+
*
|
|
17
|
+
* It combines the functionality of `clsx` and `tailwind-merge`.
|
|
18
|
+
*
|
|
19
|
+
* @param {...ClassValue[]} inputs - A list of class values to be combined.
|
|
20
|
+
* This can include strings, numbers, objects, arrays, and booleans.
|
|
21
|
+
* @returns {string} The final, merged class name string.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* cn('p-4', 'bg-red-500', { 'font-bold': true }); // => 'p-4 bg-red-500 font-bold'
|
|
25
|
+
* cn('p-2', 'p-4'); // => 'p-4' (tailwind-merge resolves the conflict)
|
|
26
|
+
*
|
|
27
|
+
* @see https://github.com/dcastil/tailwind-merge
|
|
28
|
+
* @see https://github.com/lukeed/clsx
|
|
29
|
+
*/
|
|
30
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @file This file contains a utility for performing a deep (recursive) merge of two objects.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* Recursively merges the properties of a source object into a target object.
|
|
37
|
+
* This function creates a new object and does not mutate the original target.
|
|
38
|
+
*
|
|
39
|
+
* @template T - The type of the objects being merged.
|
|
40
|
+
* @param {T} target - The base object.
|
|
41
|
+
* @param {Partial<T>} source - The object with properties to merge into the target.
|
|
42
|
+
* @returns {T} A new object representing the merged result.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const defaults = { a: 1, b: { c: 2, d: 3 } };
|
|
46
|
+
* const custom = { b: { c: 99 } };
|
|
47
|
+
* const result = deepMerge(defaults, custom);
|
|
48
|
+
* // result will be { a: 1, b: { c: 99, d: 3 } }
|
|
49
|
+
*/
|
|
50
|
+
declare function deepMerge<T extends object>(target: T, source: Partial<T>): T;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Result of chain name resolution.
|
|
54
|
+
*/
|
|
55
|
+
interface ChainInfo {
|
|
56
|
+
/** Human-readable network name (e.g., "Ethereum", "Solana Devnet") */
|
|
57
|
+
name: string;
|
|
58
|
+
/** Normalized network identifier for icon libraries (e.g., "ethereum", "solana") */
|
|
59
|
+
id: string;
|
|
60
|
+
/** Original chain ID as provided */
|
|
61
|
+
chainId: number | string;
|
|
62
|
+
/** File path for icon resolution */
|
|
63
|
+
filePath: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Retrieves blockchain network information based on its chain ID.
|
|
67
|
+
*
|
|
68
|
+
* Supports both EVM and non-EVM chain identifiers:
|
|
69
|
+
* - **Numeric IDs (EVM):** e.g., `1` → "Ethereum", `137` → "Polygon"
|
|
70
|
+
* - **String IDs (Non-EVM):** e.g., `"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"` or `"solana:devnet"` → "Solana Devnet"
|
|
71
|
+
*
|
|
72
|
+
* For Solana dev and test clusters, given as the genesis-hash chain ID of CAIP-30 or as the cluster name
|
|
73
|
+
* (`solana:devnet`), the cluster is appended to the name. Mainnet (`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`) is
|
|
74
|
+
* "Solana".
|
|
75
|
+
*
|
|
76
|
+
* The networks are looked up in the metadata of `@web3icons/common`.
|
|
77
|
+
*
|
|
78
|
+
* @param chainId - Chain identifier (number for EVM, string for non-EVM)
|
|
79
|
+
* @returns The network name, id and icon file path, and the original `chainId`; `'Unknown'`/`'unknown'` when the
|
|
80
|
+
* network is not listed.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { getChainName } from '@tuwaio/nova-core';
|
|
85
|
+
*
|
|
86
|
+
* getChainName(1);
|
|
87
|
+
* // → { name: 'Ethereum', id: 'ethereum', filePath: 'ethereum', chainId: 1 }
|
|
88
|
+
*
|
|
89
|
+
* getChainName('solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1');
|
|
90
|
+
* // → { name: 'Solana Devnet', id: 'solana', filePath: 'solana', chainId: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1' }
|
|
91
|
+
*
|
|
92
|
+
* getChainName(999999);
|
|
93
|
+
* // → { name: 'Unknown', id: 'unknown', filePath: 'unknown', chainId: 999999 }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
declare function getChainName(chainId: number | string): ChainInfo;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Determines if the current chain is a Solana development or test network.
|
|
100
|
+
*
|
|
101
|
+
* It checks that the ID is a Solana chain ID (or a string containing 'solana') that names a non-production cluster:
|
|
102
|
+
* the genesis-hash chain ID of devnet or testnet (CAIP-30, e.g. `solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1`), or
|
|
103
|
+
* 'devnet' / 'testnet' in any letter case (e.g. `solana:devnet`).
|
|
104
|
+
*
|
|
105
|
+
* @param chainId - The chain identifier (e.g., "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", "solana:devnet", 1).
|
|
106
|
+
* @returns {boolean} True only if it is a Solana dev/test chain.
|
|
107
|
+
*/
|
|
108
|
+
declare function isSolanaDev(chainId: number | string): boolean;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @file Utility function to determine if the current environment supports touch input.
|
|
112
|
+
* This is safe to use in Next.js applications as it checks for the `window` object existence.
|
|
113
|
+
*/
|
|
114
|
+
/**
|
|
115
|
+
* Determines if the current browsing device supports touch input,
|
|
116
|
+
* while also excluding large screens (typically desktop-sized touch monitors).
|
|
117
|
+
*
|
|
118
|
+
* It checks for:
|
|
119
|
+
* 1. The presence of 'ontouchstart' or navigator.maxTouchPoints > 0 or '(pointer: coarse)'.
|
|
120
|
+
* 2. ONLY returns true if the screen width is less than or equal to the specified threshold (e.g., 1200px).
|
|
121
|
+
*
|
|
122
|
+
* This function is safe for server-side rendering (SSR) environments like Next.js.
|
|
123
|
+
*
|
|
124
|
+
* @param {number} [maxWidth=1200] The maximum screen width (in pixels) for a device to be considered 'touch' (default
|
|
125
|
+
* is 1200).
|
|
126
|
+
* @returns {boolean} Returns true if the environment is determined to support touch input AND is within the width
|
|
127
|
+
* limit, otherwise false.
|
|
128
|
+
*/
|
|
129
|
+
declare function isTouchDevice(maxWidth?: number): boolean;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Resolves a CSS variable to its computed value on `document.documentElement`.
|
|
133
|
+
* Returns the original value if it's not a CSS variable. Call it in the browser: it reads `getComputedStyle`.
|
|
134
|
+
*
|
|
135
|
+
* @param value - Color value, potentially a CSS variable like `var(--my-color)`
|
|
136
|
+
* @returns Resolved color value (e.g., `#ff0000`) or original if not a variable
|
|
137
|
+
*/
|
|
138
|
+
declare function resolveCssVariable(value: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* Modifies the fill attribute of the first `<path>` element in an SVG string.
|
|
141
|
+
* Uses DOMParser for safe XML manipulation, so call it in the browser.
|
|
142
|
+
* Automatically resolves CSS variables (e.g., `var(--color)`) to their computed values with {@link resolveCssVariable}.
|
|
143
|
+
*
|
|
144
|
+
* @param svgString - The original SVG markup
|
|
145
|
+
* @param fillColor - The color to apply (supports CSS variables)
|
|
146
|
+
* @returns Modified SVG string, or the original string (with a console warning) when it cannot be parsed
|
|
147
|
+
*/
|
|
148
|
+
declare function applyFirstPathFill(svgString: string, fillColor: string): string;
|
|
149
|
+
/**
|
|
150
|
+
* Encodes an SVG string to a base64 data URL.
|
|
151
|
+
*
|
|
152
|
+
* @param svgString - The SVG markup
|
|
153
|
+
* @param firstPathFill - Optional fill color to apply to the first path, with {@link applyFirstPathFill} (browser only)
|
|
154
|
+
* @returns Base64-encoded data URL (`data:image/svg+xml;base64,…`)
|
|
155
|
+
*/
|
|
156
|
+
declare function svgToBase64(svgString: string, firstPathFill?: string): string;
|
|
157
|
+
/**
|
|
158
|
+
* Formats a name string into a GitHub-compatible SVG filename.
|
|
159
|
+
*
|
|
160
|
+
* Converts spaces to hyphens and lowercases the string,
|
|
161
|
+
* then appends the `.svg` extension.
|
|
162
|
+
*
|
|
163
|
+
* @param name - The name to format (e.g., "Wallet Connect", "MetaMask")
|
|
164
|
+
* @returns Formatted filename (e.g., "wallet-connect.svg", "metamask.svg")
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* import { formatIconNameForGithub } from '@tuwaio/nova-core';
|
|
169
|
+
*
|
|
170
|
+
* formatIconNameForGithub('Wallet Connect'); // → 'wallet-connect.svg'
|
|
171
|
+
* formatIconNameForGithub('MetaMask'); // → 'metamask.svg'
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
declare const formatIconNameForGithub: (name: string) => string;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @file This file contains a utility function for truncating a string with a center ellipsis.
|
|
178
|
+
*/
|
|
179
|
+
/**
|
|
180
|
+
* Truncates a string by showing a specified number of characters from the start and end,
|
|
181
|
+
* with an ellipsis in the middle. If the string is too short to be truncated, it's returned as is.
|
|
182
|
+
*
|
|
183
|
+
* @param {string} str - The string to truncate.
|
|
184
|
+
* @param {number} from - The number of characters to show from the beginning of the string.
|
|
185
|
+
* @param {number} to - The number of characters to show from the end of the string.
|
|
186
|
+
* @returns {string} The truncated string, or the original string if it's too short.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* const hash = '0x1234567890abcdef1234567890abcdef';
|
|
190
|
+
* textCenterEllipsis(hash, 6, 4); // => "0x1234...cdef"
|
|
191
|
+
*
|
|
192
|
+
* textCenterEllipsis('short', 6, 4); // => "short"
|
|
193
|
+
*/
|
|
194
|
+
declare function textCenterEllipsis(str: string | undefined | null, from: number, to: number): string;
|
|
195
|
+
|
|
196
|
+
export { type ChainInfo, applyFirstPathFill, cn, deepMerge, formatIconNameForGithub, getChainName, isSolanaDev, isTouchDevice, resolveCssVariable, standardButtonClasses, svgToBase64, textCenterEllipsis };
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{h as applyFirstPathFill,b as cn,c as deepMerge,j as formatIconNameForGithub,d as getChainName,e as isSolanaDev,f as isTouchDevice,g as resolveCssVariable,a as standardButtonClasses,i as svgToBase64,k as textCenterEllipsis}from'./chunk-VLQ5TKDD.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuwaio/nova-core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Oleksandr Tkach",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"import": "./dist/index.js",
|
|
16
16
|
"require": "./dist/index.cjs"
|
|
17
17
|
},
|
|
18
|
+
"./utils": {
|
|
19
|
+
"types": "./dist/utils.d.ts",
|
|
20
|
+
"import": "./dist/utils.js",
|
|
21
|
+
"require": "./dist/utils.cjs"
|
|
22
|
+
},
|
|
18
23
|
"./dist/index.css": "./dist/index.css"
|
|
19
24
|
},
|
|
20
25
|
"publishConfig": {
|
|
@@ -24,6 +29,9 @@
|
|
|
24
29
|
"dist",
|
|
25
30
|
"socket.json"
|
|
26
31
|
],
|
|
32
|
+
"sideEffects": [
|
|
33
|
+
"*.css"
|
|
34
|
+
],
|
|
27
35
|
"keywords": [
|
|
28
36
|
"react",
|
|
29
37
|
"tailwindcss",
|