@tuwaio/nova-core 1.0.0-fix-integrate-orbit-alpha.7.37786c4 → 1.0.0-fix-integrate-orbit-alpha.9.ee24217
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/dist/index.cjs +47 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +41 -127
- package/dist/index.d.cts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +47 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
|
|
1
|
+
'use strict';var m=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime'),o=require('@radix-ui/react-dialog'),framerMotion=require('framer-motion');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 m__namespace=/*#__PURE__*/_interopNamespace(m);var o__namespace=/*#__PURE__*/_interopNamespace(o);function l(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var c=e=>e&&typeof e=="object"&&!Array.isArray(e);function P(e,t){let i={...e};return c(e)&&c(t)&&Object.keys(t).forEach(r=>{let a=e[r],n=t[r];c(a)&&c(n)?i[r]=P(a,n):i[r]=n;}),i}function J(e,t,i){if(!e)return "";if(e.length<=t+i)return e;let r=e.slice(0,t),a=e.slice(e.length-i);return `${r}...${a}`}var R=m__namespace.forwardRef(({className:e,...t},i)=>jsxRuntime.jsxs("svg",{ref:i,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:l("h-5 w-5 text-[var(--tuwa-text-primary)] transition-colors",e),...t,children:[jsxRuntime.jsx("path",{d:"M18 6 6 18"}),jsxRuntime.jsx("path",{d:"m6 6 12 12"})]}));R.displayName="CloseIcon";var oe=o__namespace.Root,re=o__namespace.Trigger,N=o__namespace.Portal,ne=o__namespace.Close,M={initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,transition:{duration:.2}}},k={initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},x=m__namespace.forwardRef(({className:e,backdropAnimation:t,...i},r)=>jsxRuntime.jsx(framerMotion.AnimatePresence,{children:jsxRuntime.jsx(framerMotion.motion.div,{variants:t??k,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"relative rounded-2xl overflow-hidden",children:jsxRuntime.jsx(o__namespace.Overlay,{ref:r,className:l("fixed inset-0 z-50 bg-black/55 backdrop-blur-sm backdrop-saturate-150",e),...i})})}));x.displayName=o__namespace.Overlay.displayName;var T=m__namespace.forwardRef(({className:e,children:t,modalAnimation:i,backdropAnimation:r,...a},n)=>jsxRuntime.jsxs(N,{children:[jsxRuntime.jsx(x,{backdropAnimation:r}),jsxRuntime.jsx(o__namespace.Content,{"aria-describedby":"tuwa:modal-content",ref:n,className:l("fixed left-[50%] top-[50%] z-50 w-full max-w-full translate-x-[-50%] translate-y-[-50%] p-4 outline-none",e),...a,children:jsxRuntime.jsx(framerMotion.motion.div,{layout:true,className:"relative overflow-hidden",transition:{layout:{duration:.2,ease:[.1,.1,.2,1]}},children:jsxRuntime.jsx(framerMotion.AnimatePresence,{children:jsxRuntime.jsx(framerMotion.motion.div,{variants:i??M,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"relative rounded-2xl overflow-hidden",children:jsxRuntime.jsx("div",{className:l("relative flex max-h-[98dvh] w-full flex-col gap-3 overflow-y-auto rounded-2xl shadow-2xl","border border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)]"),children:t})})})})})]}));T.displayName=o__namespace.Content.displayName;var E=({className:e,...t})=>jsxRuntime.jsx("div",{"aria-describedby":"tuwa:modal-header",className:l("sticky flex top-0 z-11 w-full flex-row items-center justify-between","border-b border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)] p-4",e),...t});E.displayName="DialogHeader";var A=({className:e,...t})=>jsxRuntime.jsx("div",{"aria-describedby":"tuwa:modal-footer",className:l("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});A.displayName="DialogFooter";var V=m__namespace.forwardRef(({className:e,...t},i)=>jsxRuntime.jsx(o__namespace.Title,{ref:i,"aria-describedby":"tuwa:modal-title",className:l("text-lg font-bold leading-none tracking-tight text-[var(--tuwa-text-primary)] m-0",e),...t}));V.displayName=o__namespace.Title.displayName;var S=m__namespace.forwardRef(({className:e,...t},i)=>jsxRuntime.jsx(o__namespace.Description,{"aria-describedby":"tuwa:modal-description",ref:i,className:l("text-sm text-[var(--tuwa-text-secondary)]",e),...t}));S.displayName=o__namespace.Description.displayName;function ce({starsCount:e}){let[t,i]=m.useState(false);m.useEffect(()=>i(true),[]);let r=m.useMemo(()=>{if(!t)return [];let a=e??200;return Array.from({length:a}).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}))},[t]);return jsxRuntime.jsx("div",{className:"absolute inset-0 z-1 h-full w-full 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
|
+
/* Pulse animation now includes scale for a more organic feel. */
|
|
3
|
+
@keyframes pulse {
|
|
4
|
+
0%, 100% {
|
|
5
|
+
opacity: 0.2;
|
|
6
|
+
transform: scale(0.9);
|
|
7
|
+
}
|
|
8
|
+
50% {
|
|
9
|
+
opacity: 0.8;
|
|
10
|
+
transform: scale(1.2);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Supernova animation remains impactful. */
|
|
15
|
+
@keyframes supernova {
|
|
16
|
+
0% {
|
|
17
|
+
transform: scale(1);
|
|
18
|
+
stroke: rgba(var(--tuwa-bg-primary), 0.5);
|
|
19
|
+
opacity: 0.8;
|
|
20
|
+
}
|
|
21
|
+
20% {
|
|
22
|
+
transform: scale(3);
|
|
23
|
+
stroke: var(--tuwa-button-gradient-from);
|
|
24
|
+
opacity: 1;
|
|
25
|
+
}
|
|
26
|
+
100% {
|
|
27
|
+
transform: scale(0.8);
|
|
28
|
+
stroke: var(--tuwa-button-gradient-to);
|
|
29
|
+
opacity: 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.pulsar {
|
|
34
|
+
animation-name: pulse;
|
|
35
|
+
animation-timing-function: ease-in-out;
|
|
36
|
+
animation-iteration-count: infinite;
|
|
37
|
+
transform-origin: center;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.supernova {
|
|
41
|
+
animation-name: supernova;
|
|
42
|
+
animation-timing-function: ease-out;
|
|
43
|
+
animation-iteration-count: infinite;
|
|
44
|
+
transform-origin: center;
|
|
45
|
+
stroke-width: 2;
|
|
46
|
+
}
|
|
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 ue(e=2e3){let[t,i]=m.useState(false),[r,a]=m.useState(null),n=m.useCallback(async p=>{if(p)try{await navigator.clipboard.writeText(p),i(!0),a(null),setTimeout(()=>i(!1),e);}catch(u){let g=u instanceof Error?u:new Error("Failed to copy text.");console.error(g),a(g),setTimeout(()=>a(null),e);}},[e]);return {isCopied:t,copy:n,error:r}}function ve(e){let t=a=>typeof window<"u"?window.matchMedia(a).matches:false,[i,r]=m.useState(t(e));return m.useEffect(()=>{let a=window.matchMedia(e),n=()=>r(a.matches);return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[e]),i}exports.CloseIcon=R;exports.Dialog=oe;exports.DialogClose=ne;exports.DialogContent=T;exports.DialogDescription=S;exports.DialogFooter=A;exports.DialogHeader=E;exports.DialogOverlay=x;exports.DialogPortal=N;exports.DialogTitle=V;exports.DialogTrigger=re;exports.StarsBackground=ce;exports.cn=l;exports.deepMerge=P;exports.textCenterEllipsis=J;exports.useCopyToClipboard=ue;exports.useMediaQuery=ve;//# sourceMappingURL=index.cjs.map
|
|
3
48
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/cn.ts","../src/utils/deepMerge.ts","../src/utils/textCenterEllipsis.ts","../src/components/CloseIcon.tsx","../src/components/Modal.tsx","../src/hooks/useCopyToClipboard.ts","../src/hooks/useMediaQuery.ts"],"names":["cn","inputs","twMerge","clsx","isObject","item","deepMerge","target","source","output","key","targetValue","sourceValue","textCenterEllipsis","str","from","to","start","end","CloseIcon","g","className","props","ref","jsxs","jsx","Dialog","i","DialogTrigger","DialogPortal","DialogClose","DialogOverlay","c","DialogContent","children","DialogHeader","DialogFooter","DialogTitle","DialogDescription","useCopyToClipboard","timeout","isCopied","setIsCopied","useState","error","setError","copy","useCallback","text","e","copyError","useMediaQuery","query","getMatches","q","matches","setMatches","useEffect","media","listener"],"mappings":"skBAwBO,SAASA,CAAAA,CAAAA,GAAMC,EAA8B,CAClD,OAAOC,qBAAAA,CAAQC,SAAAA,CAAKF,CAAM,CAAC,CAC7B,CChBA,IAAMG,CAAAA,CAAYC,CAAAA,EACTA,CAAAA,EAAQ,OAAOA,CAAAA,EAAS,QAAA,EAAY,CAAC,KAAA,CAAM,QAAQA,CAAI,CAAA,CAkBzD,SAASC,CAAAA,CAA4BC,CAAAA,CAAWC,CAAAA,CAAuB,CA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AA,CAAM,KAAA,CAAAF,CAAM,CACjC,CCpDO,SAASO,EAAAA,CAAcC,CAAAA,CAAwB,CACpD,IAAMC,EAAcC,CAAAA,EACd,OAAO,MAAA,CAAW,GAAA,CACb,MAAA,CAAO,UAAA,CAAWA,CAAC,CAAA,CAAE,QAEvB,KAAA,CAGH,CAACC,CAAAA,CAASC,CAAU,CAAA,CAAIb,UAAAA,CAAkBU,CAAAA,CAAWD,CAAK,CAAC,CAAA,CAEjE,OAAAK,WAAAA,CAAU,IAAM,CACd,IAAMC,CAAAA,CAAQ,MAAA,CAAO,WAAWN,CAAK,CAAA,CAC/BO,CAAAA,CAAW,IAAMH,CAAAA,CAAWE,CAAAA,CAAM,OAAO,CAAA,CAG/C,OAAAC,CAAAA,EAAS,CACT,MAAA,CAAO,gBAAA,CAAiB,QAAA,CAAUA,CAAQ,CAAA,CAEnC,IAAM,OAAO,mBAAA,CAAoB,QAAA,CAAUA,CAAQ,CAC5D,CAAA,CAAG,CAACP,CAAK,CAAC,EAEHG,CACT","file":"index.cjs","sourcesContent":["/**\n * @file This file contains a utility function for conditionally merging Tailwind CSS classes.\n */\n\nimport { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/**\n * A utility function to conditionally join class names together and resolve\n * conflicting Tailwind CSS classes.\n *\n * It combines the functionality of `clsx` and `tailwind-merge`.\n *\n * @param {...ClassValue[]} inputs - A list of class values to be combined.\n * This can include strings, numbers, objects, arrays, and booleans.\n * @returns {string} The final, merged class name string.\n *\n * @example\n * cn('p-4', 'bg-red-500', { 'font-bold': true }); // => 'p-4 bg-red-500 font-bold'\n * cn('p-2', 'p-4'); // => 'p-4' (tailwind-merge resolves the conflict)\n *\n * @see https://github.com/dcastil/tailwind-merge\n * @see https://github.com/lukeed/clsx\n */\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs));\n}\n","/**\n * @file This file contains a utility for performing a deep (recursive) merge of two objects.\n */\n\n/**\n * Checks if the provided item is a plain object (i.e., not null and not an array).\n *\n * @param {any} item - The item to check.\n * @returns {item is Record<string, any>} True if the item is a plain object, otherwise false.\n */\nconst isObject = (item: any): item is Record<string, any> => {\n return item && typeof item === 'object' && !Array.isArray(item);\n};\n\n/**\n * Recursively merges the properties of a source object into a target object.\n * This function creates a new object and does not mutate the original target.\n *\n * @template T - The type of the objects being merged.\n * @param {T} target - The base object.\n * @param {Partial<T>} source - The object with properties to merge into the target.\n * @returns {T} A new object representing the merged result.\n *\n * @example\n * const defaults = { a: 1, b: { c: 2, d: 3 } };\n * const custom = { b: { c: 99 } };\n * const result = deepMerge(defaults, custom);\n * // result will be { a: 1, b: { c: 99, d: 3 } }\n */\nexport function deepMerge<T extends object>(target: T, source: Partial<T>): T {\n // Start with a shallow copy of the target to avoid mutation.\n const output = { ...target };\n\n if (isObject(target) && isObject(source)) {\n // Iterate over the keys in the source object.\n Object.keys(source).forEach((key) => {\n const targetValue = target[key as keyof T];\n const sourceValue = source[key as keyof T];\n\n // If the value is an object in both target and source, merge them recursively.\n if (isObject(targetValue) && isObject(sourceValue)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n (output as Record<string, any>)[key] = deepMerge(targetValue, sourceValue);\n } else {\n // Otherwise, the source value overwrites the target value.\n (output as Record<string, any>)[key] = sourceValue;\n }\n });\n }\n\n return output;\n}\n","/**\n * @file This file contains a utility function for truncating a string with a center ellipsis.\n */\n\n/**\n * Truncates a string by showing a specified number of characters from the start and end,\n * with an ellipsis in the middle. If the string is too short to be truncated, it's returned as is.\n *\n * @param {string} str - The string to truncate.\n * @param {number} from - The number of characters to show from the beginning of the string.\n * @param {number} to - The number of characters to show from the end of the string.\n * @returns {string} The truncated string, or the original string if it's too short.\n *\n * @example\n * const hash = '0x1234567890abcdef1234567890abcdef';\n * textCenterEllipsis(hash, 6, 4); // => \"0x1234...cdef\"\n *\n * textCenterEllipsis('short', 6, 4); // => \"short\"\n */\nexport function textCenterEllipsis(str: string | undefined | null, from: number, to: number): string {\n if (!str) {\n return '';\n }\n\n // If the string is short enough, don't truncate it.\n if (str.length <= from + to) {\n return str;\n }\n\n const start = str.slice(0, from);\n const end = str.slice(str.length - to);\n\n return `${start}...${end}`;\n}\n","import * as React from 'react';\n\nimport { cn } from '../utils';\n\n/**\n * A reusable close button icon (X mark) styled with TUWA color scheme.\n */\nexport const CloseIcon = React.forwardRef<SVGSVGElement, React.SVGAttributes<SVGSVGElement>>(\n ({ className, ...props }, ref) => (\n <svg\n ref={ref}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={cn('h-5 w-5 text-[var(--tuwa-text-primary)] transition-colors', className)}\n {...props}\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n ),\n);\nCloseIcon.displayName = 'CloseIcon';\n","import * as DialogPrimitive from '@radix-ui/react-dialog';\nimport * as React from 'react';\n\nimport { cn } from '../utils';\n\nconst Dialog = DialogPrimitive.Root;\nconst DialogTrigger = DialogPrimitive.Trigger;\nconst DialogPortal = DialogPrimitive.Portal;\nconst DialogClose = DialogPrimitive.Close;\n\nconst DialogOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n 'fixed inset-0 z-50 bg-black/55 backdrop-blur-sm backdrop-saturate-150',\n 'animate-in fade-in-0',\n className,\n )}\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay />\n\n <DialogPrimitive.Content\n aria-describedby=\"tuwa:modal-content\"\n ref={ref}\n className={cn(\n 'fixed left-[50%] top-[50%] z-50 w-full max-w-full translate-x-[-50%] translate-y-[-50%] p-4 outline-none',\n className,\n )}\n {...props}\n >\n <div className=\"relative rounded-2xl overflow-hidden\">\n <div\n className={cn(\n 'relative flex max-h-[98dvh] w-full flex-col gap-3 overflow-y-auto rounded-2xl shadow-2xl',\n 'border border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)]',\n 'animate-in fade-in-0 zoom-in-95 lide-in-from-top-[48%] duration-350',\n )}\n >\n {children}\n </div>\n </div>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n aria-describedby=\"tuwa:modal-header\"\n className={cn(\n 'sticky flex top-0 z-11 w-full flex-row items-center justify-between',\n 'border-b border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)] p-4',\n className,\n )}\n {...props}\n />\n);\nDialogHeader.displayName = 'DialogHeader';\n\nconst DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n aria-describedby=\"tuwa:modal-footer\"\n className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)}\n {...props}\n />\n);\nDialogFooter.displayName = 'DialogFooter';\n\nconst DialogTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n aria-describedby=\"tuwa:modal-title\"\n className={cn('text-lg font-bold leading-none tracking-tight text-[var(--tuwa-text-primary)] m-0', className)}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n aria-describedby=\"tuwa:modal-description\"\n ref={ref}\n className={cn('text-sm text-[var(--tuwa-text-secondary)]', className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n};\n","/**\n * @file This file contains a custom React hook for copying text to the clipboard.\n */\n\nimport { useCallback, useState } from 'react';\n\n/**\n * A custom React hook that provides functionality to copy text to the clipboard.\n * It also manages a \"copied\" state with a timeout for user feedback.\n *\n * @param {number} [timeout=2000] - The duration in milliseconds to keep the `isCopied` state as true.\n * @returns {{\n * isCopied: boolean;\n * copy: (text: string) => Promise<void>;\n * error: Error | null;\n * }} An object containing the `isCopied` state, the `copy` function, and any potential error.\n *\n * @example\n * const MyComponent = () => {\n * const { isCopied, copy } = useCopyToClipboard();\n * const textToCopy = '0x123...';\n *\n * return (\n * <button onClick={() => copy(textToCopy)}>\n * {isCopied ? 'Copied!' : 'Copy Address'}\n * </button>\n * );\n * }\n */\nexport function useCopyToClipboard(timeout = 2000): {\n isCopied: boolean;\n copy: (text: string) => Promise<void>;\n error: Error | null;\n} {\n const [isCopied, setIsCopied] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const copy = useCallback(\n async (text: string) => {\n if (!text) return;\n\n try {\n await navigator.clipboard.writeText(text);\n setIsCopied(true);\n setError(null);\n\n setTimeout(() => setIsCopied(false), timeout);\n } catch (e) {\n const copyError = e instanceof Error ? e : new Error('Failed to copy text.');\n console.error(copyError);\n setError(copyError);\n\n // Reset error state after timeout as well\n setTimeout(() => setError(null), timeout);\n }\n },\n [timeout],\n );\n\n return { isCopied, copy, error };\n}\n","import { useEffect, useState } from 'react';\n\n/**\n * A custom hook to detect if a media query matches the current screen dimensions.\n * Handles SSR gracefully.\n * @param {string} query - The media query string (e.g., '(max-width: 767px)').\n * @returns {boolean} Whether the query matches or not.\n */\nexport function useMediaQuery(query: string): boolean {\n const getMatches = (q: string): boolean => {\n if (typeof window !== 'undefined') {\n return window.matchMedia(q).matches;\n }\n return false;\n };\n\n const [matches, setMatches] = useState<boolean>(getMatches(query));\n\n useEffect(() => {\n const media = window.matchMedia(query);\n const listener = () => setMatches(media.matches);\n\n // Re-check on mount and subscribe to changes\n listener();\n window.addEventListener('resize', listener);\n\n return () => window.removeEventListener('resize', listener);\n }, [query]);\n\n return matches;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/cn.ts","../src/utils/deepMerge.ts","../src/utils/textCenterEllipsis.ts","../src/components/CloseIcon.tsx","../src/components/Modal.tsx","../src/components/StarsBackground.tsx","../src/hooks/useCopyToClipboard.ts","../src/hooks/useMediaQuery.ts"],"names":["cn","inputs","twMerge","clsx","isObject","item","deepMerge","target","source","output","key","targetValue","sourceValue","textCenterEllipsis","str","from","to","start","end","CloseIcon","v","className","props","ref","jsxs","jsx","Dialog","o","DialogTrigger","DialogPortal","DialogClose","defaultModalAnimation","defaultModalBackdropAnimation","DialogOverlay","m","backdropAnimation","AnimatePresence","motion","DialogContent","children","modalAnimation","DialogHeader","DialogFooter","DialogTitle","DialogDescription","StarsBackground","starsCount","isMounted","setIsMounted","useState","useEffect","stars","useMemo","numStars","star","i","useCopyToClipboard","timeout","isCopied","setIsCopied","error","setError","copy","useCallback","text","e","copyError","useMediaQuery","query","getMatches","q","matches","setMatches","media","listener"],"mappings":"4mBAwBO,SAASA,CAAAA,CAAAA,GAAMC,CAAAA,CAA8B,CAClD,OAAOC,qBAAAA,CAAQC,UAAKF,CAAM,CAAC,CAC7B,CChBA,IAAMG,CAAAA,CAAYC,CAAAA,EACTA,CAAAA,EAAQ,OAAOA,GAAS,QAAA,EAAY,CAAC,KAAA,CAAM,OAAA,CAAQA,CAAI,CAAA,CAkBzD,SAASC,EAA4BC,CAAAA,CAAWC,CAAAA,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CAAK,CAAA,CAAGF,CAAO,EAC9C,CAAA,MAASQ,CAAAA,CAAG,CACV,IAAMC,CAAAA,CAAYD,aAAa,KAAA,CAAQA,CAAAA,CAAI,IAAI,KAAA,CAAM,sBAAsB,EAC3E,OAAA,CAAQ,KAAA,CAAMC,CAAS,CAAA,CACvBL,CAAAA,CAASK,CAAS,EAGlB,UAAA,CAAW,IAAML,EAAS,IAAI,CAAA,CAAGJ,CAAO,EAC1C,CACF,CAAA,CACA,CAACA,CAAO,CACV,EAEA,OAAO,CAAE,SAAAC,CAAAA,CAAU,IAAA,CAAAI,EAAM,KAAA,CAAAF,CAAM,CACjC,CCpDO,SAASO,EAAAA,CAAcC,EAAwB,CACpD,IAAMC,CAAAA,CAAcC,CAAAA,EACd,OAAO,MAAA,CAAW,IACb,MAAA,CAAO,UAAA,CAAWA,CAAC,CAAA,CAAE,OAAA,CAEvB,MAGH,CAACC,CAAAA,CAASC,CAAU,CAAA,CAAIvB,UAAAA,CAAkBoB,CAAAA,CAAWD,CAAK,CAAC,CAAA,CAEjE,OAAAlB,WAAAA,CAAU,IAAM,CACd,IAAMuB,CAAAA,CAAQ,MAAA,CAAO,UAAA,CAAWL,CAAK,CAAA,CAC/BM,EAAW,IAAMF,CAAAA,CAAWC,EAAM,OAAO,CAAA,CAG/C,OAAAC,CAAAA,EAAS,CACT,MAAA,CAAO,gBAAA,CAAiB,QAAA,CAAUA,CAAQ,EAEnC,IAAM,MAAA,CAAO,mBAAA,CAAoB,QAAA,CAAUA,CAAQ,CAC5D,EAAG,CAACN,CAAK,CAAC,CAAA,CAEHG,CACT","file":"index.cjs","sourcesContent":["/**\n * @file This file contains a utility function for conditionally merging Tailwind CSS classes.\n */\n\nimport { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/**\n * A utility function to conditionally join class names together and resolve\n * conflicting Tailwind CSS classes.\n *\n * It combines the functionality of `clsx` and `tailwind-merge`.\n *\n * @param {...ClassValue[]} inputs - A list of class values to be combined.\n * This can include strings, numbers, objects, arrays, and booleans.\n * @returns {string} The final, merged class name string.\n *\n * @example\n * cn('p-4', 'bg-red-500', { 'font-bold': true }); // => 'p-4 bg-red-500 font-bold'\n * cn('p-2', 'p-4'); // => 'p-4' (tailwind-merge resolves the conflict)\n *\n * @see https://github.com/dcastil/tailwind-merge\n * @see https://github.com/lukeed/clsx\n */\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs));\n}\n","/**\n * @file This file contains a utility for performing a deep (recursive) merge of two objects.\n */\n\n/**\n * Checks if the provided item is a plain object (i.e., not null and not an array).\n *\n * @param {any} item - The item to check.\n * @returns {item is Record<string, any>} True if the item is a plain object, otherwise false.\n */\nconst isObject = (item: any): item is Record<string, any> => {\n return item && typeof item === 'object' && !Array.isArray(item);\n};\n\n/**\n * Recursively merges the properties of a source object into a target object.\n * This function creates a new object and does not mutate the original target.\n *\n * @template T - The type of the objects being merged.\n * @param {T} target - The base object.\n * @param {Partial<T>} source - The object with properties to merge into the target.\n * @returns {T} A new object representing the merged result.\n *\n * @example\n * const defaults = { a: 1, b: { c: 2, d: 3 } };\n * const custom = { b: { c: 99 } };\n * const result = deepMerge(defaults, custom);\n * // result will be { a: 1, b: { c: 99, d: 3 } }\n */\nexport function deepMerge<T extends object>(target: T, source: Partial<T>): T {\n // Start with a shallow copy of the target to avoid mutation.\n const output = { ...target };\n\n if (isObject(target) && isObject(source)) {\n // Iterate over the keys in the source object.\n Object.keys(source).forEach((key) => {\n const targetValue = target[key as keyof T];\n const sourceValue = source[key as keyof T];\n\n // If the value is an object in both target and source, merge them recursively.\n if (isObject(targetValue) && isObject(sourceValue)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n (output as Record<string, any>)[key] = deepMerge(targetValue, sourceValue);\n } else {\n // Otherwise, the source value overwrites the target value.\n (output as Record<string, any>)[key] = sourceValue;\n }\n });\n }\n\n return output;\n}\n","/**\n * @file This file contains a utility function for truncating a string with a center ellipsis.\n */\n\n/**\n * Truncates a string by showing a specified number of characters from the start and end,\n * with an ellipsis in the middle. If the string is too short to be truncated, it's returned as is.\n *\n * @param {string} str - The string to truncate.\n * @param {number} from - The number of characters to show from the beginning of the string.\n * @param {number} to - The number of characters to show from the end of the string.\n * @returns {string} The truncated string, or the original string if it's too short.\n *\n * @example\n * const hash = '0x1234567890abcdef1234567890abcdef';\n * textCenterEllipsis(hash, 6, 4); // => \"0x1234...cdef\"\n *\n * textCenterEllipsis('short', 6, 4); // => \"short\"\n */\nexport function textCenterEllipsis(str: string | undefined | null, from: number, to: number): string {\n if (!str) {\n return '';\n }\n\n // If the string is short enough, don't truncate it.\n if (str.length <= from + to) {\n return str;\n }\n\n const start = str.slice(0, from);\n const end = str.slice(str.length - to);\n\n return `${start}...${end}`;\n}\n","import * as React from 'react';\n\nimport { cn } from '../utils';\n\n/**\n * A reusable close button icon (X mark) styled with TUWA color scheme.\n */\nexport const CloseIcon = React.forwardRef<SVGSVGElement, React.SVGAttributes<SVGSVGElement>>(\n ({ className, ...props }, ref) => (\n <svg\n ref={ref}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={cn('h-5 w-5 text-[var(--tuwa-text-primary)] transition-colors', className)}\n {...props}\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n ),\n);\nCloseIcon.displayName = 'CloseIcon';\n","import * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { AnimatePresence, motion, Variants } from 'framer-motion';\nimport * as React from 'react';\n\nimport { cn } from '../utils';\n\nconst Dialog = DialogPrimitive.Root;\nconst DialogTrigger = DialogPrimitive.Trigger;\nconst DialogPortal = DialogPrimitive.Portal;\nconst DialogClose = DialogPrimitive.Close;\n\nconst defaultModalAnimation: Variants = {\n initial: { opacity: 0, scale: 0.9, y: 20 },\n animate: { opacity: 1, scale: 1, y: 0 },\n exit: {\n opacity: 0,\n scale: 0.9,\n transition: {\n duration: 0.2,\n },\n },\n};\n\nconst defaultModalBackdropAnimation: Variants = {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n exit: { opacity: 0 },\n};\n\nconst DialogOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> & {\n backdropAnimation?: Variants;\n }\n>(({ className, backdropAnimation, ...props }, ref) => (\n <AnimatePresence>\n <motion.div\n variants={backdropAnimation ?? defaultModalBackdropAnimation}\n transition={{ duration: 0.2, ease: 'easeInOut' }}\n animate=\"animate\"\n initial=\"initial\"\n exit=\"exit\"\n className=\"relative rounded-2xl overflow-hidden\"\n >\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn('fixed inset-0 z-50 bg-black/55 backdrop-blur-sm backdrop-saturate-150', className)}\n {...props}\n />\n </motion.div>\n </AnimatePresence>\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {\n modalAnimation?: Variants;\n backdropAnimation?: Variants;\n }\n>(({ className, children, modalAnimation, backdropAnimation, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay backdropAnimation={backdropAnimation} />\n\n <DialogPrimitive.Content\n aria-describedby=\"tuwa:modal-content\"\n ref={ref}\n className={cn(\n 'fixed left-[50%] top-[50%] z-50 w-full max-w-full translate-x-[-50%] translate-y-[-50%] p-4 outline-none',\n className,\n )}\n {...props}\n >\n <motion.div\n layout\n className=\"relative overflow-hidden\"\n transition={{\n layout: {\n duration: 0.2,\n ease: [0.1, 0.1, 0.2, 1],\n },\n }}\n >\n <AnimatePresence>\n <motion.div\n variants={modalAnimation ?? defaultModalAnimation}\n transition={{ duration: 0.2, ease: 'easeInOut' }}\n animate=\"animate\"\n initial=\"initial\"\n exit=\"exit\"\n className=\"relative rounded-2xl overflow-hidden\"\n >\n <div\n className={cn(\n 'relative flex max-h-[98dvh] w-full flex-col gap-3 overflow-y-auto rounded-2xl shadow-2xl',\n 'border border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)]',\n )}\n >\n {children}\n </div>\n </motion.div>\n </AnimatePresence>\n </motion.div>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n aria-describedby=\"tuwa:modal-header\"\n className={cn(\n 'sticky flex top-0 z-11 w-full flex-row items-center justify-between',\n 'border-b border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)] p-4',\n className,\n )}\n {...props}\n />\n);\nDialogHeader.displayName = 'DialogHeader';\n\nconst DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n aria-describedby=\"tuwa:modal-footer\"\n className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)}\n {...props}\n />\n);\nDialogFooter.displayName = 'DialogFooter';\n\nconst DialogTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n aria-describedby=\"tuwa:modal-title\"\n className={cn('text-lg font-bold leading-none tracking-tight text-[var(--tuwa-text-primary)] m-0', className)}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n aria-describedby=\"tuwa:modal-description\"\n ref={ref}\n className={cn('text-sm text-[var(--tuwa-text-secondary)]', className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n};\n","import { useEffect, useMemo, useState } from 'react';\n\nexport function StarsBackground({ starsCount }: { starsCount?: number }) {\n const [isMounted, setIsMounted] = useState(false);\n useEffect(() => setIsMounted(true), []);\n\n const stars = useMemo(() => {\n if (!isMounted) {\n return [];\n }\n\n const numStars = starsCount ?? 200;\n return Array.from({ length: numStars }).map(() => ({\n x: Math.random() * window.innerWidth,\n y: Math.random() * window.innerHeight,\n r: Math.random() * 1 + 0.5,\n isSupernova: Math.random() < 0.1,\n delay: Math.random() * 10,\n duration: 5 + Math.random() * 5,\n }));\n }, [isMounted]);\n\n return (\n <div className=\"absolute inset-0 z-1 h-full w-full overflow-hidden\">\n <svg width=\"100%\" height=\"100%\" xmlns=\"http://www.w3.org/2000/svg\">\n <defs>\n <style>\n {`\n /* Pulse animation now includes scale for a more organic feel. */\n @keyframes pulse {\n 0%, 100% { \n opacity: 0.2;\n transform: scale(0.9);\n }\n 50% {\n opacity: 0.8;\n transform: scale(1.2);\n }\n }\n \n /* Supernova animation remains impactful. */\n @keyframes supernova {\n 0% { \n transform: scale(1);\n stroke: rgba(var(--tuwa-bg-primary), 0.5);\n opacity: 0.8;\n }\n 20% { \n transform: scale(3);\n stroke: var(--tuwa-button-gradient-from);\n opacity: 1;\n }\n 100% { \n transform: scale(0.8);\n stroke: var(--tuwa-button-gradient-to);\n opacity: 0;\n }\n }\n\n .pulsar {\n animation-name: pulse;\n animation-timing-function: ease-in-out;\n animation-iteration-count: infinite;\n transform-origin: center;\n }\n\n .supernova {\n animation-name: supernova;\n animation-timing-function: ease-out;\n animation-iteration-count: infinite;\n transform-origin: center;\n stroke-width: 2;\n }\n `}\n </style>\n </defs>\n\n {stars.map((star, i) => (\n <circle\n key={i}\n cx={star.x}\n cy={star.y}\n r={star.r}\n fill={`rgba(var(--tuwa-bg-primary), 0.7)`}\n className={star.isSupernova ? 'supernova' : 'pulsar'}\n style={{\n animationDelay: `${star.delay}s`,\n animationDuration: `${star.duration}s`,\n }}\n />\n ))}\n </svg>\n </div>\n );\n}\n","/**\n * @file This file contains a custom React hook for copying text to the clipboard.\n */\n\nimport { useCallback, useState } from 'react';\n\n/**\n * A custom React hook that provides functionality to copy text to the clipboard.\n * It also manages a \"copied\" state with a timeout for user feedback.\n *\n * @param {number} [timeout=2000] - The duration in milliseconds to keep the `isCopied` state as true.\n * @returns {{\n * isCopied: boolean;\n * copy: (text: string) => Promise<void>;\n * error: Error | null;\n * }} An object containing the `isCopied` state, the `copy` function, and any potential error.\n *\n * @example\n * const MyComponent = () => {\n * const { isCopied, copy } = useCopyToClipboard();\n * const textToCopy = '0x123...';\n *\n * return (\n * <button onClick={() => copy(textToCopy)}>\n * {isCopied ? 'Copied!' : 'Copy Address'}\n * </button>\n * );\n * }\n */\nexport function useCopyToClipboard(timeout = 2000): {\n isCopied: boolean;\n copy: (text: string) => Promise<void>;\n error: Error | null;\n} {\n const [isCopied, setIsCopied] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const copy = useCallback(\n async (text: string) => {\n if (!text) return;\n\n try {\n await navigator.clipboard.writeText(text);\n setIsCopied(true);\n setError(null);\n\n setTimeout(() => setIsCopied(false), timeout);\n } catch (e) {\n const copyError = e instanceof Error ? e : new Error('Failed to copy text.');\n console.error(copyError);\n setError(copyError);\n\n // Reset error state after timeout as well\n setTimeout(() => setError(null), timeout);\n }\n },\n [timeout],\n );\n\n return { isCopied, copy, error };\n}\n","import { useEffect, useState } from 'react';\n\n/**\n * A custom hook to detect if a media query matches the current screen dimensions.\n * Handles SSR gracefully.\n * @param {string} query - The media query string (e.g., '(max-width: 767px)').\n * @returns {boolean} Whether the query matches or not.\n */\nexport function useMediaQuery(query: string): boolean {\n const getMatches = (q: string): boolean => {\n if (typeof window !== 'undefined') {\n return window.matchMedia(q).matches;\n }\n return false;\n };\n\n const [matches, setMatches] = useState<boolean>(getMatches(query));\n\n useEffect(() => {\n const media = window.matchMedia(query);\n const listener = () => setMatches(media.matches);\n\n // Re-check on mount and subscribe to changes\n listener();\n window.addEventListener('resize', listener);\n\n return () => window.removeEventListener('resize', listener);\n }, [query]);\n\n return matches;\n}\n"]}
|
package/dist/index.css
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
@layer properties;
|
|
3
3
|
@layer theme, base, components, utilities;
|
|
4
4
|
@layer utilities {
|
|
5
|
+
.absolute {
|
|
6
|
+
position: absolute;
|
|
7
|
+
}
|
|
5
8
|
.fixed {
|
|
6
9
|
position: fixed;
|
|
7
10
|
}
|
|
@@ -23,6 +26,9 @@
|
|
|
23
26
|
.left-\[50\%\] {
|
|
24
27
|
left: 50%;
|
|
25
28
|
}
|
|
29
|
+
.z-1 {
|
|
30
|
+
z-index: 1;
|
|
31
|
+
}
|
|
26
32
|
.z-11 {
|
|
27
33
|
z-index: 11;
|
|
28
34
|
}
|
|
@@ -41,6 +47,9 @@
|
|
|
41
47
|
.h-5 {
|
|
42
48
|
height: calc(0.25rem * 5);
|
|
43
49
|
}
|
|
50
|
+
.h-full {
|
|
51
|
+
height: 100%;
|
|
52
|
+
}
|
|
44
53
|
.max-h-\[98dvh\] {
|
|
45
54
|
max-height: 98dvh;
|
|
46
55
|
}
|
|
@@ -61,8 +70,8 @@
|
|
|
61
70
|
--tw-translate-y: -50%;
|
|
62
71
|
translate: var(--tw-translate-x) var(--tw-translate-y);
|
|
63
72
|
}
|
|
64
|
-
.
|
|
65
|
-
|
|
73
|
+
.transform {
|
|
74
|
+
transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,);
|
|
66
75
|
}
|
|
67
76
|
.resize {
|
|
68
77
|
resize: both;
|
|
@@ -172,27 +181,20 @@
|
|
|
172
181
|
--tw-backdrop-saturate: saturate(150%);
|
|
173
182
|
backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
|
|
174
183
|
}
|
|
184
|
+
.transition {
|
|
185
|
+
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, backdrop-filter, display, content-visibility, overlay, pointer-events;
|
|
186
|
+
transition-timing-function: var(--tw-ease, cubic-bezier(0.4, 0, 0.2, 1));
|
|
187
|
+
transition-duration: var(--tw-duration, 150ms);
|
|
188
|
+
}
|
|
175
189
|
.transition-colors {
|
|
176
190
|
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;
|
|
177
191
|
transition-timing-function: var(--tw-ease, cubic-bezier(0.4, 0, 0.2, 1));
|
|
178
192
|
transition-duration: var(--tw-duration, 150ms);
|
|
179
193
|
}
|
|
180
|
-
.duration-350 {
|
|
181
|
-
--tw-duration: 350ms;
|
|
182
|
-
transition-duration: 350ms;
|
|
183
|
-
}
|
|
184
|
-
.fade-in-0 {
|
|
185
|
-
--tw-enter-opacity: calc(0/100);
|
|
186
|
-
--tw-enter-opacity: 0;
|
|
187
|
-
}
|
|
188
194
|
.outline-none {
|
|
189
195
|
--tw-outline-style: none;
|
|
190
196
|
outline-style: none;
|
|
191
197
|
}
|
|
192
|
-
.zoom-in-95 {
|
|
193
|
-
--tw-enter-scale: calc(95*1%);
|
|
194
|
-
--tw-enter-scale: .95;
|
|
195
|
-
}
|
|
196
198
|
.sm\:flex-row {
|
|
197
199
|
@media (width >= 40rem) {
|
|
198
200
|
flex-direction: row;
|
|
@@ -213,90 +215,6 @@
|
|
|
213
215
|
}
|
|
214
216
|
}
|
|
215
217
|
}
|
|
216
|
-
@property --tw-animation-delay {
|
|
217
|
-
syntax: "*";
|
|
218
|
-
inherits: false;
|
|
219
|
-
initial-value: 0s;
|
|
220
|
-
}
|
|
221
|
-
@property --tw-animation-direction {
|
|
222
|
-
syntax: "*";
|
|
223
|
-
inherits: false;
|
|
224
|
-
initial-value: normal;
|
|
225
|
-
}
|
|
226
|
-
@property --tw-animation-duration {
|
|
227
|
-
syntax: "*";
|
|
228
|
-
inherits: false;
|
|
229
|
-
}
|
|
230
|
-
@property --tw-animation-fill-mode {
|
|
231
|
-
syntax: "*";
|
|
232
|
-
inherits: false;
|
|
233
|
-
initial-value: none;
|
|
234
|
-
}
|
|
235
|
-
@property --tw-animation-iteration-count {
|
|
236
|
-
syntax: "*";
|
|
237
|
-
inherits: false;
|
|
238
|
-
initial-value: 1;
|
|
239
|
-
}
|
|
240
|
-
@property --tw-enter-blur {
|
|
241
|
-
syntax: "*";
|
|
242
|
-
inherits: false;
|
|
243
|
-
initial-value: 0;
|
|
244
|
-
}
|
|
245
|
-
@property --tw-enter-opacity {
|
|
246
|
-
syntax: "*";
|
|
247
|
-
inherits: false;
|
|
248
|
-
initial-value: 1;
|
|
249
|
-
}
|
|
250
|
-
@property --tw-enter-rotate {
|
|
251
|
-
syntax: "*";
|
|
252
|
-
inherits: false;
|
|
253
|
-
initial-value: 0;
|
|
254
|
-
}
|
|
255
|
-
@property --tw-enter-scale {
|
|
256
|
-
syntax: "*";
|
|
257
|
-
inherits: false;
|
|
258
|
-
initial-value: 1;
|
|
259
|
-
}
|
|
260
|
-
@property --tw-enter-translate-x {
|
|
261
|
-
syntax: "*";
|
|
262
|
-
inherits: false;
|
|
263
|
-
initial-value: 0;
|
|
264
|
-
}
|
|
265
|
-
@property --tw-enter-translate-y {
|
|
266
|
-
syntax: "*";
|
|
267
|
-
inherits: false;
|
|
268
|
-
initial-value: 0;
|
|
269
|
-
}
|
|
270
|
-
@property --tw-exit-blur {
|
|
271
|
-
syntax: "*";
|
|
272
|
-
inherits: false;
|
|
273
|
-
initial-value: 0;
|
|
274
|
-
}
|
|
275
|
-
@property --tw-exit-opacity {
|
|
276
|
-
syntax: "*";
|
|
277
|
-
inherits: false;
|
|
278
|
-
initial-value: 1;
|
|
279
|
-
}
|
|
280
|
-
@property --tw-exit-rotate {
|
|
281
|
-
syntax: "*";
|
|
282
|
-
inherits: false;
|
|
283
|
-
initial-value: 0;
|
|
284
|
-
}
|
|
285
|
-
@property --tw-exit-scale {
|
|
286
|
-
syntax: "*";
|
|
287
|
-
inherits: false;
|
|
288
|
-
initial-value: 1;
|
|
289
|
-
}
|
|
290
|
-
@property --tw-exit-translate-x {
|
|
291
|
-
syntax: "*";
|
|
292
|
-
inherits: false;
|
|
293
|
-
initial-value: 0;
|
|
294
|
-
}
|
|
295
|
-
@property --tw-exit-translate-y {
|
|
296
|
-
syntax: "*";
|
|
297
|
-
inherits: false;
|
|
298
|
-
initial-value: 0;
|
|
299
|
-
}
|
|
300
218
|
:root {
|
|
301
219
|
--tuwa-success-bg: oklch(96.2% 0.044 156.743);
|
|
302
220
|
--tuwa-success-text: oklch(52.7% 0.154 150.069);
|
|
@@ -368,6 +286,26 @@
|
|
|
368
286
|
inherits: false;
|
|
369
287
|
initial-value: 0;
|
|
370
288
|
}
|
|
289
|
+
@property --tw-rotate-x {
|
|
290
|
+
syntax: "*";
|
|
291
|
+
inherits: false;
|
|
292
|
+
}
|
|
293
|
+
@property --tw-rotate-y {
|
|
294
|
+
syntax: "*";
|
|
295
|
+
inherits: false;
|
|
296
|
+
}
|
|
297
|
+
@property --tw-rotate-z {
|
|
298
|
+
syntax: "*";
|
|
299
|
+
inherits: false;
|
|
300
|
+
}
|
|
301
|
+
@property --tw-skew-x {
|
|
302
|
+
syntax: "*";
|
|
303
|
+
inherits: false;
|
|
304
|
+
}
|
|
305
|
+
@property --tw-skew-y {
|
|
306
|
+
syntax: "*";
|
|
307
|
+
inherits: false;
|
|
308
|
+
}
|
|
371
309
|
@property --tw-border-style {
|
|
372
310
|
syntax: "*";
|
|
373
311
|
inherits: false;
|
|
@@ -486,28 +424,22 @@
|
|
|
486
424
|
syntax: "*";
|
|
487
425
|
inherits: false;
|
|
488
426
|
}
|
|
489
|
-
@property --tw-duration {
|
|
490
|
-
syntax: "*";
|
|
491
|
-
inherits: false;
|
|
492
|
-
}
|
|
493
427
|
@property --tw-space-x-reverse {
|
|
494
428
|
syntax: "*";
|
|
495
429
|
inherits: false;
|
|
496
430
|
initial-value: 0;
|
|
497
431
|
}
|
|
498
|
-
@keyframes enter {
|
|
499
|
-
from {
|
|
500
|
-
opacity: var(--tw-enter-opacity,1);
|
|
501
|
-
transform: translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0)scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1))rotate(var(--tw-enter-rotate,0));
|
|
502
|
-
filter: blur(var(--tw-enter-blur,0));
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
432
|
@layer properties {
|
|
506
433
|
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
|
507
434
|
*, ::before, ::after, ::backdrop {
|
|
508
435
|
--tw-translate-x: 0;
|
|
509
436
|
--tw-translate-y: 0;
|
|
510
437
|
--tw-translate-z: 0;
|
|
438
|
+
--tw-rotate-x: initial;
|
|
439
|
+
--tw-rotate-y: initial;
|
|
440
|
+
--tw-rotate-z: initial;
|
|
441
|
+
--tw-skew-x: initial;
|
|
442
|
+
--tw-skew-y: initial;
|
|
511
443
|
--tw-border-style: solid;
|
|
512
444
|
--tw-leading: initial;
|
|
513
445
|
--tw-font-weight: initial;
|
|
@@ -535,25 +467,7 @@
|
|
|
535
467
|
--tw-backdrop-opacity: initial;
|
|
536
468
|
--tw-backdrop-saturate: initial;
|
|
537
469
|
--tw-backdrop-sepia: initial;
|
|
538
|
-
--tw-duration: initial;
|
|
539
470
|
--tw-space-x-reverse: 0;
|
|
540
|
-
--tw-animation-delay: 0s;
|
|
541
|
-
--tw-animation-direction: normal;
|
|
542
|
-
--tw-animation-duration: initial;
|
|
543
|
-
--tw-animation-fill-mode: none;
|
|
544
|
-
--tw-animation-iteration-count: 1;
|
|
545
|
-
--tw-enter-blur: 0;
|
|
546
|
-
--tw-enter-opacity: 1;
|
|
547
|
-
--tw-enter-rotate: 0;
|
|
548
|
-
--tw-enter-scale: 1;
|
|
549
|
-
--tw-enter-translate-x: 0;
|
|
550
|
-
--tw-enter-translate-y: 0;
|
|
551
|
-
--tw-exit-blur: 0;
|
|
552
|
-
--tw-exit-opacity: 1;
|
|
553
|
-
--tw-exit-rotate: 0;
|
|
554
|
-
--tw-exit-scale: 1;
|
|
555
|
-
--tw-exit-translate-x: 0;
|
|
556
|
-
--tw-exit-translate-y: 0;
|
|
557
471
|
}
|
|
558
472
|
}
|
|
559
473
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
4
|
+
import { Variants } from 'framer-motion';
|
|
4
5
|
import { ClassValue } from 'clsx';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -12,8 +13,13 @@ declare const Dialog: React.FC<DialogPrimitive.DialogProps>;
|
|
|
12
13
|
declare const DialogTrigger: React.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
13
14
|
declare const DialogPortal: React.FC<DialogPrimitive.DialogPortalProps>;
|
|
14
15
|
declare const DialogClose: React.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
15
|
-
declare const DialogOverlay: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> &
|
|
16
|
-
|
|
16
|
+
declare const DialogOverlay: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
17
|
+
backdropAnimation?: Variants;
|
|
18
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
19
|
+
declare const DialogContent: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
20
|
+
modalAnimation?: Variants;
|
|
21
|
+
backdropAnimation?: Variants;
|
|
22
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
17
23
|
declare const DialogHeader: {
|
|
18
24
|
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
19
25
|
displayName: string;
|
|
@@ -25,6 +31,10 @@ declare const DialogFooter: {
|
|
|
25
31
|
declare const DialogTitle: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React.RefAttributes<HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
|
|
26
32
|
declare const DialogDescription: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
27
33
|
|
|
34
|
+
declare function StarsBackground({ starsCount }: {
|
|
35
|
+
starsCount?: number;
|
|
36
|
+
}): react_jsx_runtime.JSX.Element;
|
|
37
|
+
|
|
28
38
|
/**
|
|
29
39
|
* @file This file contains a custom React hook for copying text to the clipboard.
|
|
30
40
|
*/
|
|
@@ -128,4 +138,4 @@ declare function deepMerge<T extends object>(target: T, source: Partial<T>): T;
|
|
|
128
138
|
*/
|
|
129
139
|
declare function textCenterEllipsis(str: string | undefined | null, from: number, to: number): string;
|
|
130
140
|
|
|
131
|
-
export { CloseIcon, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, cn, deepMerge, textCenterEllipsis, useCopyToClipboard, useMediaQuery };
|
|
141
|
+
export { CloseIcon, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, StarsBackground, cn, deepMerge, textCenterEllipsis, useCopyToClipboard, useMediaQuery };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
4
|
+
import { Variants } from 'framer-motion';
|
|
4
5
|
import { ClassValue } from 'clsx';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -12,8 +13,13 @@ declare const Dialog: React.FC<DialogPrimitive.DialogProps>;
|
|
|
12
13
|
declare const DialogTrigger: React.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
13
14
|
declare const DialogPortal: React.FC<DialogPrimitive.DialogPortalProps>;
|
|
14
15
|
declare const DialogClose: React.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
15
|
-
declare const DialogOverlay: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> &
|
|
16
|
-
|
|
16
|
+
declare const DialogOverlay: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
17
|
+
backdropAnimation?: Variants;
|
|
18
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
19
|
+
declare const DialogContent: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
20
|
+
modalAnimation?: Variants;
|
|
21
|
+
backdropAnimation?: Variants;
|
|
22
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
17
23
|
declare const DialogHeader: {
|
|
18
24
|
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
19
25
|
displayName: string;
|
|
@@ -25,6 +31,10 @@ declare const DialogFooter: {
|
|
|
25
31
|
declare const DialogTitle: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React.RefAttributes<HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
|
|
26
32
|
declare const DialogDescription: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
27
33
|
|
|
34
|
+
declare function StarsBackground({ starsCount }: {
|
|
35
|
+
starsCount?: number;
|
|
36
|
+
}): react_jsx_runtime.JSX.Element;
|
|
37
|
+
|
|
28
38
|
/**
|
|
29
39
|
* @file This file contains a custom React hook for copying text to the clipboard.
|
|
30
40
|
*/
|
|
@@ -128,4 +138,4 @@ declare function deepMerge<T extends object>(target: T, source: Partial<T>): T;
|
|
|
128
138
|
*/
|
|
129
139
|
declare function textCenterEllipsis(str: string | undefined | null, from: number, to: number): string;
|
|
130
140
|
|
|
131
|
-
export { CloseIcon, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, cn, deepMerge, textCenterEllipsis, useCopyToClipboard, useMediaQuery };
|
|
141
|
+
export { CloseIcon, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, StarsBackground, cn, deepMerge, textCenterEllipsis, useCopyToClipboard, useMediaQuery };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
-
import*as
|
|
2
|
-
|
|
1
|
+
import*as m from'react';import {useState,useEffect,useMemo,useCallback}from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsxs,jsx}from'react/jsx-runtime';import*as o from'@radix-ui/react-dialog';import {AnimatePresence,motion}from'framer-motion';function l(...e){return twMerge(clsx(e))}var c=e=>e&&typeof e=="object"&&!Array.isArray(e);function P(e,t){let i={...e};return c(e)&&c(t)&&Object.keys(t).forEach(r=>{let a=e[r],n=t[r];c(a)&&c(n)?i[r]=P(a,n):i[r]=n;}),i}function J(e,t,i){if(!e)return "";if(e.length<=t+i)return e;let r=e.slice(0,t),a=e.slice(e.length-i);return `${r}...${a}`}var R=m.forwardRef(({className:e,...t},i)=>jsxs("svg",{ref:i,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:l("h-5 w-5 text-[var(--tuwa-text-primary)] transition-colors",e),...t,children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]}));R.displayName="CloseIcon";var oe=o.Root,re=o.Trigger,N=o.Portal,ne=o.Close,M={initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,transition:{duration:.2}}},k={initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},x=m.forwardRef(({className:e,backdropAnimation:t,...i},r)=>jsx(AnimatePresence,{children:jsx(motion.div,{variants:t??k,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"relative rounded-2xl overflow-hidden",children:jsx(o.Overlay,{ref:r,className:l("fixed inset-0 z-50 bg-black/55 backdrop-blur-sm backdrop-saturate-150",e),...i})})}));x.displayName=o.Overlay.displayName;var T=m.forwardRef(({className:e,children:t,modalAnimation:i,backdropAnimation:r,...a},n)=>jsxs(N,{children:[jsx(x,{backdropAnimation:r}),jsx(o.Content,{"aria-describedby":"tuwa:modal-content",ref:n,className:l("fixed left-[50%] top-[50%] z-50 w-full max-w-full translate-x-[-50%] translate-y-[-50%] p-4 outline-none",e),...a,children:jsx(motion.div,{layout:true,className:"relative overflow-hidden",transition:{layout:{duration:.2,ease:[.1,.1,.2,1]}},children:jsx(AnimatePresence,{children:jsx(motion.div,{variants:i??M,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"relative rounded-2xl overflow-hidden",children:jsx("div",{className:l("relative flex max-h-[98dvh] w-full flex-col gap-3 overflow-y-auto rounded-2xl shadow-2xl","border border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)]"),children:t})})})})})]}));T.displayName=o.Content.displayName;var E=({className:e,...t})=>jsx("div",{"aria-describedby":"tuwa:modal-header",className:l("sticky flex top-0 z-11 w-full flex-row items-center justify-between","border-b border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)] p-4",e),...t});E.displayName="DialogHeader";var A=({className:e,...t})=>jsx("div",{"aria-describedby":"tuwa:modal-footer",className:l("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});A.displayName="DialogFooter";var V=m.forwardRef(({className:e,...t},i)=>jsx(o.Title,{ref:i,"aria-describedby":"tuwa:modal-title",className:l("text-lg font-bold leading-none tracking-tight text-[var(--tuwa-text-primary)] m-0",e),...t}));V.displayName=o.Title.displayName;var S=m.forwardRef(({className:e,...t},i)=>jsx(o.Description,{"aria-describedby":"tuwa:modal-description",ref:i,className:l("text-sm text-[var(--tuwa-text-secondary)]",e),...t}));S.displayName=o.Description.displayName;function ce({starsCount:e}){let[t,i]=useState(false);useEffect(()=>i(true),[]);let r=useMemo(()=>{if(!t)return [];let a=e??200;return Array.from({length:a}).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}))},[t]);return jsx("div",{className:"absolute inset-0 z-1 h-full w-full overflow-hidden",children:jsxs("svg",{width:"100%",height:"100%",xmlns:"http://www.w3.org/2000/svg",children:[jsx("defs",{children:jsx("style",{children:`
|
|
2
|
+
/* Pulse animation now includes scale for a more organic feel. */
|
|
3
|
+
@keyframes pulse {
|
|
4
|
+
0%, 100% {
|
|
5
|
+
opacity: 0.2;
|
|
6
|
+
transform: scale(0.9);
|
|
7
|
+
}
|
|
8
|
+
50% {
|
|
9
|
+
opacity: 0.8;
|
|
10
|
+
transform: scale(1.2);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Supernova animation remains impactful. */
|
|
15
|
+
@keyframes supernova {
|
|
16
|
+
0% {
|
|
17
|
+
transform: scale(1);
|
|
18
|
+
stroke: rgba(var(--tuwa-bg-primary), 0.5);
|
|
19
|
+
opacity: 0.8;
|
|
20
|
+
}
|
|
21
|
+
20% {
|
|
22
|
+
transform: scale(3);
|
|
23
|
+
stroke: var(--tuwa-button-gradient-from);
|
|
24
|
+
opacity: 1;
|
|
25
|
+
}
|
|
26
|
+
100% {
|
|
27
|
+
transform: scale(0.8);
|
|
28
|
+
stroke: var(--tuwa-button-gradient-to);
|
|
29
|
+
opacity: 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.pulsar {
|
|
34
|
+
animation-name: pulse;
|
|
35
|
+
animation-timing-function: ease-in-out;
|
|
36
|
+
animation-iteration-count: infinite;
|
|
37
|
+
transform-origin: center;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.supernova {
|
|
41
|
+
animation-name: supernova;
|
|
42
|
+
animation-timing-function: ease-out;
|
|
43
|
+
animation-iteration-count: infinite;
|
|
44
|
+
transform-origin: center;
|
|
45
|
+
stroke-width: 2;
|
|
46
|
+
}
|
|
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 ue(e=2e3){let[t,i]=useState(false),[r,a]=useState(null),n=useCallback(async p=>{if(p)try{await navigator.clipboard.writeText(p),i(!0),a(null),setTimeout(()=>i(!1),e);}catch(u){let g=u instanceof Error?u:new Error("Failed to copy text.");console.error(g),a(g),setTimeout(()=>a(null),e);}},[e]);return {isCopied:t,copy:n,error:r}}function ve(e){let t=a=>typeof window<"u"?window.matchMedia(a).matches:false,[i,r]=useState(t(e));return useEffect(()=>{let a=window.matchMedia(e),n=()=>r(a.matches);return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[e]),i}export{R as CloseIcon,oe as Dialog,ne as DialogClose,T as DialogContent,S as DialogDescription,A as DialogFooter,E as DialogHeader,x as DialogOverlay,N as DialogPortal,V as DialogTitle,re as DialogTrigger,ce as StarsBackground,l as cn,P as deepMerge,J as textCenterEllipsis,ue as useCopyToClipboard,ve as useMediaQuery};//# sourceMappingURL=index.js.map
|
|
3
48
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/cn.ts","../src/utils/deepMerge.ts","../src/utils/textCenterEllipsis.ts","../src/components/CloseIcon.tsx","../src/components/Modal.tsx","../src/hooks/useCopyToClipboard.ts","../src/hooks/useMediaQuery.ts"],"names":["cn","inputs","twMerge","clsx","isObject","item","deepMerge","target","source","output","key","targetValue","sourceValue","textCenterEllipsis","str","from","to","start","end","CloseIcon","g","className","props","ref","jsxs","jsx","Dialog","DialogTrigger","DialogPortal","DialogClose","DialogOverlay","DialogContent","children","DialogHeader","DialogFooter","DialogTitle","DialogDescription","useCopyToClipboard","timeout","isCopied","setIsCopied","useState","error","setError","copy","useCallback","text","e","copyError","useMediaQuery","query","getMatches","q","matches","setMatches","useEffect","media","listener"],"mappings":"0NAwBO,SAASA,CAAAA,CAAAA,GAAMC,EAA8B,CAClD,OAAOC,OAAAA,CAAQC,IAAAA,CAAKF,CAAM,CAAC,CAC7B,CChBA,IAAMG,CAAAA,CAAYC,CAAAA,EACTA,CAAAA,EAAQ,OAAOA,CAAAA,EAAS,QAAA,EAAY,CAAC,KAAA,CAAM,QAAQA,CAA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AAE,QAAA,CAAAC,EAAU,IAAA,CAAAK,CAAAA,CAAM,KAAA,CAAAF,CAAM,CACjC,CCpDO,SAASO,EAAAA,CAAcC,CAAAA,CAAwB,CACpD,IAAMC,EAAcC,CAAAA,EACd,OAAO,MAAA,CAAW,GAAA,CACb,MAAA,CAAO,UAAA,CAAWA,CAAC,CAAA,CAAE,QAEvB,KAAA,CAGH,CAACC,CAAAA,CAASC,CAAU,CAAA,CAAIb,QAAAA,CAAkBU,CAAAA,CAAWD,CAAK,CAAC,CAAA,CAEjE,OAAAK,SAAAA,CAAU,IAAM,CACd,IAAMC,CAAAA,CAAQ,MAAA,CAAO,WAAWN,CAAK,CAAA,CAC/BO,CAAAA,CAAW,IAAMH,CAAAA,CAAWE,CAAAA,CAAM,OAAO,CAAA,CAG/C,OAAAC,CAAAA,EAAS,CACT,MAAA,CAAO,gBAAA,CAAiB,QAAA,CAAUA,CAAQ,CAAA,CAEnC,IAAM,OAAO,mBAAA,CAAoB,QAAA,CAAUA,CAAQ,CAC5D,CAAA,CAAG,CAACP,CAAK,CAAC,EAEHG,CACT","file":"index.js","sourcesContent":["/**\n * @file This file contains a utility function for conditionally merging Tailwind CSS classes.\n */\n\nimport { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/**\n * A utility function to conditionally join class names together and resolve\n * conflicting Tailwind CSS classes.\n *\n * It combines the functionality of `clsx` and `tailwind-merge`.\n *\n * @param {...ClassValue[]} inputs - A list of class values to be combined.\n * This can include strings, numbers, objects, arrays, and booleans.\n * @returns {string} The final, merged class name string.\n *\n * @example\n * cn('p-4', 'bg-red-500', { 'font-bold': true }); // => 'p-4 bg-red-500 font-bold'\n * cn('p-2', 'p-4'); // => 'p-4' (tailwind-merge resolves the conflict)\n *\n * @see https://github.com/dcastil/tailwind-merge\n * @see https://github.com/lukeed/clsx\n */\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs));\n}\n","/**\n * @file This file contains a utility for performing a deep (recursive) merge of two objects.\n */\n\n/**\n * Checks if the provided item is a plain object (i.e., not null and not an array).\n *\n * @param {any} item - The item to check.\n * @returns {item is Record<string, any>} True if the item is a plain object, otherwise false.\n */\nconst isObject = (item: any): item is Record<string, any> => {\n return item && typeof item === 'object' && !Array.isArray(item);\n};\n\n/**\n * Recursively merges the properties of a source object into a target object.\n * This function creates a new object and does not mutate the original target.\n *\n * @template T - The type of the objects being merged.\n * @param {T} target - The base object.\n * @param {Partial<T>} source - The object with properties to merge into the target.\n * @returns {T} A new object representing the merged result.\n *\n * @example\n * const defaults = { a: 1, b: { c: 2, d: 3 } };\n * const custom = { b: { c: 99 } };\n * const result = deepMerge(defaults, custom);\n * // result will be { a: 1, b: { c: 99, d: 3 } }\n */\nexport function deepMerge<T extends object>(target: T, source: Partial<T>): T {\n // Start with a shallow copy of the target to avoid mutation.\n const output = { ...target };\n\n if (isObject(target) && isObject(source)) {\n // Iterate over the keys in the source object.\n Object.keys(source).forEach((key) => {\n const targetValue = target[key as keyof T];\n const sourceValue = source[key as keyof T];\n\n // If the value is an object in both target and source, merge them recursively.\n if (isObject(targetValue) && isObject(sourceValue)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n (output as Record<string, any>)[key] = deepMerge(targetValue, sourceValue);\n } else {\n // Otherwise, the source value overwrites the target value.\n (output as Record<string, any>)[key] = sourceValue;\n }\n });\n }\n\n return output;\n}\n","/**\n * @file This file contains a utility function for truncating a string with a center ellipsis.\n */\n\n/**\n * Truncates a string by showing a specified number of characters from the start and end,\n * with an ellipsis in the middle. If the string is too short to be truncated, it's returned as is.\n *\n * @param {string} str - The string to truncate.\n * @param {number} from - The number of characters to show from the beginning of the string.\n * @param {number} to - The number of characters to show from the end of the string.\n * @returns {string} The truncated string, or the original string if it's too short.\n *\n * @example\n * const hash = '0x1234567890abcdef1234567890abcdef';\n * textCenterEllipsis(hash, 6, 4); // => \"0x1234...cdef\"\n *\n * textCenterEllipsis('short', 6, 4); // => \"short\"\n */\nexport function textCenterEllipsis(str: string | undefined | null, from: number, to: number): string {\n if (!str) {\n return '';\n }\n\n // If the string is short enough, don't truncate it.\n if (str.length <= from + to) {\n return str;\n }\n\n const start = str.slice(0, from);\n const end = str.slice(str.length - to);\n\n return `${start}...${end}`;\n}\n","import * as React from 'react';\n\nimport { cn } from '../utils';\n\n/**\n * A reusable close button icon (X mark) styled with TUWA color scheme.\n */\nexport const CloseIcon = React.forwardRef<SVGSVGElement, React.SVGAttributes<SVGSVGElement>>(\n ({ className, ...props }, ref) => (\n <svg\n ref={ref}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={cn('h-5 w-5 text-[var(--tuwa-text-primary)] transition-colors', className)}\n {...props}\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n ),\n);\nCloseIcon.displayName = 'CloseIcon';\n","import * as DialogPrimitive from '@radix-ui/react-dialog';\nimport * as React from 'react';\n\nimport { cn } from '../utils';\n\nconst Dialog = DialogPrimitive.Root;\nconst DialogTrigger = DialogPrimitive.Trigger;\nconst DialogPortal = DialogPrimitive.Portal;\nconst DialogClose = DialogPrimitive.Close;\n\nconst DialogOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n 'fixed inset-0 z-50 bg-black/55 backdrop-blur-sm backdrop-saturate-150',\n 'animate-in fade-in-0',\n className,\n )}\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay />\n\n <DialogPrimitive.Content\n aria-describedby=\"tuwa:modal-content\"\n ref={ref}\n className={cn(\n 'fixed left-[50%] top-[50%] z-50 w-full max-w-full translate-x-[-50%] translate-y-[-50%] p-4 outline-none',\n className,\n )}\n {...props}\n >\n <div className=\"relative rounded-2xl overflow-hidden\">\n <div\n className={cn(\n 'relative flex max-h-[98dvh] w-full flex-col gap-3 overflow-y-auto rounded-2xl shadow-2xl',\n 'border border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)]',\n 'animate-in fade-in-0 zoom-in-95 lide-in-from-top-[48%] duration-350',\n )}\n >\n {children}\n </div>\n </div>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n aria-describedby=\"tuwa:modal-header\"\n className={cn(\n 'sticky flex top-0 z-11 w-full flex-row items-center justify-between',\n 'border-b border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)] p-4',\n className,\n )}\n {...props}\n />\n);\nDialogHeader.displayName = 'DialogHeader';\n\nconst DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n aria-describedby=\"tuwa:modal-footer\"\n className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)}\n {...props}\n />\n);\nDialogFooter.displayName = 'DialogFooter';\n\nconst DialogTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n aria-describedby=\"tuwa:modal-title\"\n className={cn('text-lg font-bold leading-none tracking-tight text-[var(--tuwa-text-primary)] m-0', className)}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n aria-describedby=\"tuwa:modal-description\"\n ref={ref}\n className={cn('text-sm text-[var(--tuwa-text-secondary)]', className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n};\n","/**\n * @file This file contains a custom React hook for copying text to the clipboard.\n */\n\nimport { useCallback, useState } from 'react';\n\n/**\n * A custom React hook that provides functionality to copy text to the clipboard.\n * It also manages a \"copied\" state with a timeout for user feedback.\n *\n * @param {number} [timeout=2000] - The duration in milliseconds to keep the `isCopied` state as true.\n * @returns {{\n * isCopied: boolean;\n * copy: (text: string) => Promise<void>;\n * error: Error | null;\n * }} An object containing the `isCopied` state, the `copy` function, and any potential error.\n *\n * @example\n * const MyComponent = () => {\n * const { isCopied, copy } = useCopyToClipboard();\n * const textToCopy = '0x123...';\n *\n * return (\n * <button onClick={() => copy(textToCopy)}>\n * {isCopied ? 'Copied!' : 'Copy Address'}\n * </button>\n * );\n * }\n */\nexport function useCopyToClipboard(timeout = 2000): {\n isCopied: boolean;\n copy: (text: string) => Promise<void>;\n error: Error | null;\n} {\n const [isCopied, setIsCopied] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const copy = useCallback(\n async (text: string) => {\n if (!text) return;\n\n try {\n await navigator.clipboard.writeText(text);\n setIsCopied(true);\n setError(null);\n\n setTimeout(() => setIsCopied(false), timeout);\n } catch (e) {\n const copyError = e instanceof Error ? e : new Error('Failed to copy text.');\n console.error(copyError);\n setError(copyError);\n\n // Reset error state after timeout as well\n setTimeout(() => setError(null), timeout);\n }\n },\n [timeout],\n );\n\n return { isCopied, copy, error };\n}\n","import { useEffect, useState } from 'react';\n\n/**\n * A custom hook to detect if a media query matches the current screen dimensions.\n * Handles SSR gracefully.\n * @param {string} query - The media query string (e.g., '(max-width: 767px)').\n * @returns {boolean} Whether the query matches or not.\n */\nexport function useMediaQuery(query: string): boolean {\n const getMatches = (q: string): boolean => {\n if (typeof window !== 'undefined') {\n return window.matchMedia(q).matches;\n }\n return false;\n };\n\n const [matches, setMatches] = useState<boolean>(getMatches(query));\n\n useEffect(() => {\n const media = window.matchMedia(query);\n const listener = () => setMatches(media.matches);\n\n // Re-check on mount and subscribe to changes\n listener();\n window.addEventListener('resize', listener);\n\n return () => window.removeEventListener('resize', listener);\n }, [query]);\n\n return matches;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/cn.ts","../src/utils/deepMerge.ts","../src/utils/textCenterEllipsis.ts","../src/components/CloseIcon.tsx","../src/components/Modal.tsx","../src/components/StarsBackground.tsx","../src/hooks/useCopyToClipboard.ts","../src/hooks/useMediaQuery.ts"],"names":["cn","inputs","twMerge","clsx","isObject","item","deepMerge","target","source","output","key","targetValue","sourceValue","textCenterEllipsis","str","from","to","start","end","CloseIcon","v","className","props","ref","jsxs","jsx","Dialog","DialogTrigger","DialogPortal","DialogClose","defaultModalAnimation","defaultModalBackdropAnimation","DialogOverlay","backdropAnimation","AnimatePresence","motion","DialogContent","children","modalAnimation","DialogHeader","DialogFooter","DialogTitle","DialogDescription","StarsBackground","starsCount","isMounted","setIsMounted","useState","useEffect","stars","useMemo","numStars","star","i","useCopyToClipboard","timeout","isCopied","setIsCopied","error","setError","copy","useCallback","text","e","copyError","useMediaQuery","query","getMatches","q","matches","setMatches","media","listener"],"mappings":"qRAwBO,SAASA,CAAAA,CAAAA,GAAMC,CAAAA,CAA8B,CAClD,OAAOC,OAAAA,CAAQC,KAAKF,CAAM,CAAC,CAC7B,CChBA,IAAMG,CAAAA,CAAYC,CAAAA,EACTA,CAAAA,EAAQ,OAAOA,GAAS,QAAA,EAAY,CAAC,KAAA,CAAM,OAAA,CAAQA,CAAI,CAAA,CAkBzD,SAASC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AA,CAAGF,CAAO,EAC9C,CAAA,MAASQ,CAAAA,CAAG,CACV,IAAMC,CAAAA,CAAYD,aAAa,KAAA,CAAQA,CAAAA,CAAI,IAAI,KAAA,CAAM,sBAAsB,EAC3E,OAAA,CAAQ,KAAA,CAAMC,CAAS,CAAA,CACvBL,CAAAA,CAASK,CAAS,EAGlB,UAAA,CAAW,IAAML,EAAS,IAAI,CAAA,CAAGJ,CAAO,EAC1C,CACF,CAAA,CACA,CAACA,CAAO,CACV,EAEA,OAAO,CAAE,SAAAC,CAAAA,CAAU,IAAA,CAAAI,EAAM,KAAA,CAAAF,CAAM,CACjC,CCpDO,SAASO,EAAAA,CAAcC,EAAwB,CACpD,IAAMC,CAAAA,CAAcC,CAAAA,EACd,OAAO,MAAA,CAAW,IACb,MAAA,CAAO,UAAA,CAAWA,CAAC,CAAA,CAAE,OAAA,CAEvB,MAGH,CAACC,CAAAA,CAASC,CAAU,CAAA,CAAIvB,QAAAA,CAAkBoB,CAAAA,CAAWD,CAAK,CAAC,CAAA,CAEjE,OAAAlB,SAAAA,CAAU,IAAM,CACd,IAAMuB,CAAAA,CAAQ,MAAA,CAAO,UAAA,CAAWL,CAAK,CAAA,CAC/BM,EAAW,IAAMF,CAAAA,CAAWC,EAAM,OAAO,CAAA,CAG/C,OAAAC,CAAAA,EAAS,CACT,MAAA,CAAO,gBAAA,CAAiB,QAAA,CAAUA,CAAQ,EAEnC,IAAM,MAAA,CAAO,mBAAA,CAAoB,QAAA,CAAUA,CAAQ,CAC5D,EAAG,CAACN,CAAK,CAAC,CAAA,CAEHG,CACT","file":"index.js","sourcesContent":["/**\n * @file This file contains a utility function for conditionally merging Tailwind CSS classes.\n */\n\nimport { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/**\n * A utility function to conditionally join class names together and resolve\n * conflicting Tailwind CSS classes.\n *\n * It combines the functionality of `clsx` and `tailwind-merge`.\n *\n * @param {...ClassValue[]} inputs - A list of class values to be combined.\n * This can include strings, numbers, objects, arrays, and booleans.\n * @returns {string} The final, merged class name string.\n *\n * @example\n * cn('p-4', 'bg-red-500', { 'font-bold': true }); // => 'p-4 bg-red-500 font-bold'\n * cn('p-2', 'p-4'); // => 'p-4' (tailwind-merge resolves the conflict)\n *\n * @see https://github.com/dcastil/tailwind-merge\n * @see https://github.com/lukeed/clsx\n */\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs));\n}\n","/**\n * @file This file contains a utility for performing a deep (recursive) merge of two objects.\n */\n\n/**\n * Checks if the provided item is a plain object (i.e., not null and not an array).\n *\n * @param {any} item - The item to check.\n * @returns {item is Record<string, any>} True if the item is a plain object, otherwise false.\n */\nconst isObject = (item: any): item is Record<string, any> => {\n return item && typeof item === 'object' && !Array.isArray(item);\n};\n\n/**\n * Recursively merges the properties of a source object into a target object.\n * This function creates a new object and does not mutate the original target.\n *\n * @template T - The type of the objects being merged.\n * @param {T} target - The base object.\n * @param {Partial<T>} source - The object with properties to merge into the target.\n * @returns {T} A new object representing the merged result.\n *\n * @example\n * const defaults = { a: 1, b: { c: 2, d: 3 } };\n * const custom = { b: { c: 99 } };\n * const result = deepMerge(defaults, custom);\n * // result will be { a: 1, b: { c: 99, d: 3 } }\n */\nexport function deepMerge<T extends object>(target: T, source: Partial<T>): T {\n // Start with a shallow copy of the target to avoid mutation.\n const output = { ...target };\n\n if (isObject(target) && isObject(source)) {\n // Iterate over the keys in the source object.\n Object.keys(source).forEach((key) => {\n const targetValue = target[key as keyof T];\n const sourceValue = source[key as keyof T];\n\n // If the value is an object in both target and source, merge them recursively.\n if (isObject(targetValue) && isObject(sourceValue)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n (output as Record<string, any>)[key] = deepMerge(targetValue, sourceValue);\n } else {\n // Otherwise, the source value overwrites the target value.\n (output as Record<string, any>)[key] = sourceValue;\n }\n });\n }\n\n return output;\n}\n","/**\n * @file This file contains a utility function for truncating a string with a center ellipsis.\n */\n\n/**\n * Truncates a string by showing a specified number of characters from the start and end,\n * with an ellipsis in the middle. If the string is too short to be truncated, it's returned as is.\n *\n * @param {string} str - The string to truncate.\n * @param {number} from - The number of characters to show from the beginning of the string.\n * @param {number} to - The number of characters to show from the end of the string.\n * @returns {string} The truncated string, or the original string if it's too short.\n *\n * @example\n * const hash = '0x1234567890abcdef1234567890abcdef';\n * textCenterEllipsis(hash, 6, 4); // => \"0x1234...cdef\"\n *\n * textCenterEllipsis('short', 6, 4); // => \"short\"\n */\nexport function textCenterEllipsis(str: string | undefined | null, from: number, to: number): string {\n if (!str) {\n return '';\n }\n\n // If the string is short enough, don't truncate it.\n if (str.length <= from + to) {\n return str;\n }\n\n const start = str.slice(0, from);\n const end = str.slice(str.length - to);\n\n return `${start}...${end}`;\n}\n","import * as React from 'react';\n\nimport { cn } from '../utils';\n\n/**\n * A reusable close button icon (X mark) styled with TUWA color scheme.\n */\nexport const CloseIcon = React.forwardRef<SVGSVGElement, React.SVGAttributes<SVGSVGElement>>(\n ({ className, ...props }, ref) => (\n <svg\n ref={ref}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={cn('h-5 w-5 text-[var(--tuwa-text-primary)] transition-colors', className)}\n {...props}\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n ),\n);\nCloseIcon.displayName = 'CloseIcon';\n","import * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { AnimatePresence, motion, Variants } from 'framer-motion';\nimport * as React from 'react';\n\nimport { cn } from '../utils';\n\nconst Dialog = DialogPrimitive.Root;\nconst DialogTrigger = DialogPrimitive.Trigger;\nconst DialogPortal = DialogPrimitive.Portal;\nconst DialogClose = DialogPrimitive.Close;\n\nconst defaultModalAnimation: Variants = {\n initial: { opacity: 0, scale: 0.9, y: 20 },\n animate: { opacity: 1, scale: 1, y: 0 },\n exit: {\n opacity: 0,\n scale: 0.9,\n transition: {\n duration: 0.2,\n },\n },\n};\n\nconst defaultModalBackdropAnimation: Variants = {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n exit: { opacity: 0 },\n};\n\nconst DialogOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> & {\n backdropAnimation?: Variants;\n }\n>(({ className, backdropAnimation, ...props }, ref) => (\n <AnimatePresence>\n <motion.div\n variants={backdropAnimation ?? defaultModalBackdropAnimation}\n transition={{ duration: 0.2, ease: 'easeInOut' }}\n animate=\"animate\"\n initial=\"initial\"\n exit=\"exit\"\n className=\"relative rounded-2xl overflow-hidden\"\n >\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn('fixed inset-0 z-50 bg-black/55 backdrop-blur-sm backdrop-saturate-150', className)}\n {...props}\n />\n </motion.div>\n </AnimatePresence>\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {\n modalAnimation?: Variants;\n backdropAnimation?: Variants;\n }\n>(({ className, children, modalAnimation, backdropAnimation, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay backdropAnimation={backdropAnimation} />\n\n <DialogPrimitive.Content\n aria-describedby=\"tuwa:modal-content\"\n ref={ref}\n className={cn(\n 'fixed left-[50%] top-[50%] z-50 w-full max-w-full translate-x-[-50%] translate-y-[-50%] p-4 outline-none',\n className,\n )}\n {...props}\n >\n <motion.div\n layout\n className=\"relative overflow-hidden\"\n transition={{\n layout: {\n duration: 0.2,\n ease: [0.1, 0.1, 0.2, 1],\n },\n }}\n >\n <AnimatePresence>\n <motion.div\n variants={modalAnimation ?? defaultModalAnimation}\n transition={{ duration: 0.2, ease: 'easeInOut' }}\n animate=\"animate\"\n initial=\"initial\"\n exit=\"exit\"\n className=\"relative rounded-2xl overflow-hidden\"\n >\n <div\n className={cn(\n 'relative flex max-h-[98dvh] w-full flex-col gap-3 overflow-y-auto rounded-2xl shadow-2xl',\n 'border border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)]',\n )}\n >\n {children}\n </div>\n </motion.div>\n </AnimatePresence>\n </motion.div>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n aria-describedby=\"tuwa:modal-header\"\n className={cn(\n 'sticky flex top-0 z-11 w-full flex-row items-center justify-between',\n 'border-b border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)] p-4',\n className,\n )}\n {...props}\n />\n);\nDialogHeader.displayName = 'DialogHeader';\n\nconst DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n aria-describedby=\"tuwa:modal-footer\"\n className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)}\n {...props}\n />\n);\nDialogFooter.displayName = 'DialogFooter';\n\nconst DialogTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n aria-describedby=\"tuwa:modal-title\"\n className={cn('text-lg font-bold leading-none tracking-tight text-[var(--tuwa-text-primary)] m-0', className)}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n aria-describedby=\"tuwa:modal-description\"\n ref={ref}\n className={cn('text-sm text-[var(--tuwa-text-secondary)]', className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n};\n","import { useEffect, useMemo, useState } from 'react';\n\nexport function StarsBackground({ starsCount }: { starsCount?: number }) {\n const [isMounted, setIsMounted] = useState(false);\n useEffect(() => setIsMounted(true), []);\n\n const stars = useMemo(() => {\n if (!isMounted) {\n return [];\n }\n\n const numStars = starsCount ?? 200;\n return Array.from({ length: numStars }).map(() => ({\n x: Math.random() * window.innerWidth,\n y: Math.random() * window.innerHeight,\n r: Math.random() * 1 + 0.5,\n isSupernova: Math.random() < 0.1,\n delay: Math.random() * 10,\n duration: 5 + Math.random() * 5,\n }));\n }, [isMounted]);\n\n return (\n <div className=\"absolute inset-0 z-1 h-full w-full overflow-hidden\">\n <svg width=\"100%\" height=\"100%\" xmlns=\"http://www.w3.org/2000/svg\">\n <defs>\n <style>\n {`\n /* Pulse animation now includes scale for a more organic feel. */\n @keyframes pulse {\n 0%, 100% { \n opacity: 0.2;\n transform: scale(0.9);\n }\n 50% {\n opacity: 0.8;\n transform: scale(1.2);\n }\n }\n \n /* Supernova animation remains impactful. */\n @keyframes supernova {\n 0% { \n transform: scale(1);\n stroke: rgba(var(--tuwa-bg-primary), 0.5);\n opacity: 0.8;\n }\n 20% { \n transform: scale(3);\n stroke: var(--tuwa-button-gradient-from);\n opacity: 1;\n }\n 100% { \n transform: scale(0.8);\n stroke: var(--tuwa-button-gradient-to);\n opacity: 0;\n }\n }\n\n .pulsar {\n animation-name: pulse;\n animation-timing-function: ease-in-out;\n animation-iteration-count: infinite;\n transform-origin: center;\n }\n\n .supernova {\n animation-name: supernova;\n animation-timing-function: ease-out;\n animation-iteration-count: infinite;\n transform-origin: center;\n stroke-width: 2;\n }\n `}\n </style>\n </defs>\n\n {stars.map((star, i) => (\n <circle\n key={i}\n cx={star.x}\n cy={star.y}\n r={star.r}\n fill={`rgba(var(--tuwa-bg-primary), 0.7)`}\n className={star.isSupernova ? 'supernova' : 'pulsar'}\n style={{\n animationDelay: `${star.delay}s`,\n animationDuration: `${star.duration}s`,\n }}\n />\n ))}\n </svg>\n </div>\n );\n}\n","/**\n * @file This file contains a custom React hook for copying text to the clipboard.\n */\n\nimport { useCallback, useState } from 'react';\n\n/**\n * A custom React hook that provides functionality to copy text to the clipboard.\n * It also manages a \"copied\" state with a timeout for user feedback.\n *\n * @param {number} [timeout=2000] - The duration in milliseconds to keep the `isCopied` state as true.\n * @returns {{\n * isCopied: boolean;\n * copy: (text: string) => Promise<void>;\n * error: Error | null;\n * }} An object containing the `isCopied` state, the `copy` function, and any potential error.\n *\n * @example\n * const MyComponent = () => {\n * const { isCopied, copy } = useCopyToClipboard();\n * const textToCopy = '0x123...';\n *\n * return (\n * <button onClick={() => copy(textToCopy)}>\n * {isCopied ? 'Copied!' : 'Copy Address'}\n * </button>\n * );\n * }\n */\nexport function useCopyToClipboard(timeout = 2000): {\n isCopied: boolean;\n copy: (text: string) => Promise<void>;\n error: Error | null;\n} {\n const [isCopied, setIsCopied] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const copy = useCallback(\n async (text: string) => {\n if (!text) return;\n\n try {\n await navigator.clipboard.writeText(text);\n setIsCopied(true);\n setError(null);\n\n setTimeout(() => setIsCopied(false), timeout);\n } catch (e) {\n const copyError = e instanceof Error ? e : new Error('Failed to copy text.');\n console.error(copyError);\n setError(copyError);\n\n // Reset error state after timeout as well\n setTimeout(() => setError(null), timeout);\n }\n },\n [timeout],\n );\n\n return { isCopied, copy, error };\n}\n","import { useEffect, useState } from 'react';\n\n/**\n * A custom hook to detect if a media query matches the current screen dimensions.\n * Handles SSR gracefully.\n * @param {string} query - The media query string (e.g., '(max-width: 767px)').\n * @returns {boolean} Whether the query matches or not.\n */\nexport function useMediaQuery(query: string): boolean {\n const getMatches = (q: string): boolean => {\n if (typeof window !== 'undefined') {\n return window.matchMedia(q).matches;\n }\n return false;\n };\n\n const [matches, setMatches] = useState<boolean>(getMatches(query));\n\n useEffect(() => {\n const media = window.matchMedia(query);\n const listener = () => setMatches(media.matches);\n\n // Re-check on mount and subscribe to changes\n listener();\n window.addEventListener('resize', listener);\n\n return () => window.removeEventListener('resize', listener);\n }, [query]);\n\n return matches;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuwaio/nova-core",
|
|
3
|
-
"version": "1.0.0-fix-integrate-orbit-alpha.
|
|
3
|
+
"version": "1.0.0-fix-integrate-orbit-alpha.9.ee24217",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Oleksandr Tkach",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,10 +48,11 @@
|
|
|
48
48
|
}
|
|
49
49
|
],
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@radix-ui/react-dialog": "
|
|
52
|
-
"clsx": "
|
|
53
|
-
"
|
|
54
|
-
"
|
|
51
|
+
"@radix-ui/react-dialog": "1.x.x",
|
|
52
|
+
"clsx": "2.x.x",
|
|
53
|
+
"framer-motion": "12.x.x",
|
|
54
|
+
"react": "19.x.x",
|
|
55
|
+
"tailwind-merge": "3.x.x"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@tailwindcss/postcss": "^4.1.13",
|
|
@@ -60,12 +61,12 @@
|
|
|
60
61
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
61
62
|
"autoprefixer": "^10.4.21",
|
|
62
63
|
"clsx": "^2.1.1",
|
|
64
|
+
"framer-motion": "^12.23.19",
|
|
63
65
|
"postcss": "^8.5.6",
|
|
64
66
|
"postcss-cli": "^11.0.1",
|
|
65
67
|
"react": "^19.1.1",
|
|
66
68
|
"tailwindcss": "^4.1.13",
|
|
67
69
|
"tailwind-merge": "^3.3.1",
|
|
68
|
-
"tw-animate-css": "^1.4.0",
|
|
69
70
|
"tsup": "^8.5.0",
|
|
70
71
|
"typescript": "^5.9.2"
|
|
71
72
|
},
|