@tuwaio/nova-core 1.0.0-fix-integrate-orbit-alpha.7.37786c4 → 1.0.0-fix-integrate-orbit-alpha.8.2a0be00
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 +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +5 -128
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
package/dist/index.cjs
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
'use strict';var c=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime'),
|
2
|
-
exports.CloseIcon=
|
1
|
+
'use strict';var c=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime'),a=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 c__namespace=/*#__PURE__*/_interopNamespace(c);var a__namespace=/*#__PURE__*/_interopNamespace(a);function s(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var m=e=>e&&typeof e=="object"&&!Array.isArray(e);function R(e,t){let i={...e};return m(e)&&m(t)&&Object.keys(t).forEach(o=>{let r=e[o],l=t[o];m(r)&&m(l)?i[o]=R(r,l):i[o]=l;}),i}function W(e,t,i){if(!e)return "";if(e.length<=t+i)return e;let o=e.slice(0,t),r=e.slice(e.length-i);return `${o}...${r}`}var P=c__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:s("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"})]}));P.displayName="CloseIcon";var q=a__namespace.Root,ee=a__namespace.Trigger,C=a__namespace.Portal,te=a__namespace.Close,N={initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,transition:{duration:.2}}},T={initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},x=c__namespace.forwardRef(({className:e,backdropAnimation:t,...i},o)=>jsxRuntime.jsx(framerMotion.AnimatePresence,{children:jsxRuntime.jsx(framerMotion.motion.div,{variants:t??T,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"relative rounded-2xl overflow-hidden",children:jsxRuntime.jsx(a__namespace.Overlay,{ref:o,className:s("fixed inset-0 z-50 bg-black/55 backdrop-blur-sm backdrop-saturate-150",e),...i})})}));x.displayName=a__namespace.Overlay.displayName;var E=c__namespace.forwardRef(({className:e,children:t,modalAnimation:i,backdropAnimation:o,...r},l)=>jsxRuntime.jsxs(C,{children:[jsxRuntime.jsx(x,{backdropAnimation:o}),jsxRuntime.jsx(a__namespace.Content,{"aria-describedby":"tuwa:modal-content",ref:l,className:s("fixed left-[50%] top-[50%] z-50 w-full max-w-full translate-x-[-50%] translate-y-[-50%] p-4 outline-none",e),...r,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??N,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"relative rounded-2xl overflow-hidden",children:jsxRuntime.jsx("div",{className:s("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})})})})})]}));E.displayName=a__namespace.Content.displayName;var V=({className:e,...t})=>jsxRuntime.jsx("div",{"aria-describedby":"tuwa:modal-header",className:s("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});V.displayName="DialogHeader";var k=({className:e,...t})=>jsxRuntime.jsx("div",{"aria-describedby":"tuwa:modal-footer",className:s("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});k.displayName="DialogFooter";var A=c__namespace.forwardRef(({className:e,...t},i)=>jsxRuntime.jsx(a__namespace.Title,{ref:i,"aria-describedby":"tuwa:modal-title",className:s("text-lg font-bold leading-none tracking-tight text-[var(--tuwa-text-primary)] m-0",e),...t}));A.displayName=a__namespace.Title.displayName;var M=c__namespace.forwardRef(({className:e,...t},i)=>jsxRuntime.jsx(a__namespace.Description,{"aria-describedby":"tuwa:modal-description",ref:i,className:s("text-sm text-[var(--tuwa-text-secondary)]",e),...t}));M.displayName=a__namespace.Description.displayName;function re(e=2e3){let[t,i]=c.useState(false),[o,r]=c.useState(null),l=c.useCallback(async p=>{if(p)try{await navigator.clipboard.writeText(p),i(!0),r(null),setTimeout(()=>i(!1),e);}catch(f){let u=f instanceof Error?f:new Error("Failed to copy text.");console.error(u),r(u),setTimeout(()=>r(null),e);}},[e]);return {isCopied:t,copy:l,error:o}}function se(e){let t=r=>typeof window<"u"?window.matchMedia(r).matches:false,[i,o]=c.useState(t(e));return c.useEffect(()=>{let r=window.matchMedia(e),l=()=>o(r.matches);return l(),window.addEventListener("resize",l),()=>window.removeEventListener("resize",l)},[e]),i}
|
2
|
+
exports.CloseIcon=P;exports.Dialog=q;exports.DialogClose=te;exports.DialogContent=E;exports.DialogDescription=M;exports.DialogFooter=k;exports.DialogHeader=V;exports.DialogOverlay=x;exports.DialogPortal=C;exports.DialogTitle=A;exports.DialogTrigger=ee;exports.cn=s;exports.deepMerge=R;exports.textCenterEllipsis=W;exports.useCopyToClipboard=re;exports.useMediaQuery=se;//# sourceMappingURL=index.cjs.map
|
3
3
|
//# 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,CAE5E,IAAMC,EAAS,CAAE,GAAGF,CAAO,CAAA,CAE3B,OAAIH,CAAAA,CAASG,CAAM,CAAA,EAAKH,EAASI,CAAM,CAAA,EAErC,MAAA,CAAO,IAAA,CAAKA,CAAM,CAAA,CAAE,OAAA,CAASE,CAAAA,EAAQ,CACnC,IAAMC,CAAAA,CAAcJ,CAAAA,CAAOG,CAAc,CAAA,CACnCE,CAAAA,CAAcJ,CAAAA,CAAOE,CAAc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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/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","a","DialogTrigger","DialogPortal","DialogClose","defaultModalAnimation","defaultModalBackdropAnimation","DialogOverlay","c","backdropAnimation","AnimatePresence","motion","DialogContent","children","modalAnimation","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":"4mBAwBO,SAASA,KAAMC,CAAAA,CAA8B,CAClD,OAAOC,qBAAAA,CAAQC,SAAAA,CAAKF,CAAM,CAAC,CAC7B,CChBA,IAAMG,EAAYC,CAAAA,EACTA,CAAAA,EAAQ,OAAOA,CAAAA,EAAS,QAAA,EAAY,CAAC,KAAA,CAAM,OAAA,CAAQA,CAAI,CAAA,CAkBzD,SAASC,CAAAA,CAA4BC,CAAAA,CAAWC,EAAuB,CAE5E,IAAMC,EAAS,CAAE,GAAGF,CAAO,CAAA,CAE3B,OAAIH,CAAAA,CAASG,CAAM,GAAKH,CAAAA,CAASI,CAAM,GAErC,MAAA,CAAO,IAAA,CAAKA,CAAM,CAAA,CAAE,QAASE,CAAAA,EAAQ,CACnC,IAAMC,CAAAA,CAAcJ,CAAAA,CAAOG,CAAc,CAAA,CACnCE,CAAAA,CAAcJ,CAAAA,CAAOE,CAAc,EAGrCN,CAAAA,CAASO,CAAW,GAAKP,CAAAA,CAASQ,CAAW,EAG9CH,CAAAA,CAA+B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,CACxCN,CAAAA,CAAY,CAAA,CAAI,EAChBG,CAAAA,CAAS,IAAI,EAEb,UAAA,CAAW,IAAMH,EAAY,CAAA,CAAK,CAAA,CAAGF,CAAO,EAC9C,OAASS,CAAAA,CAAG,CACV,IAAMC,CAAAA,CAAYD,CAAAA,YAAa,MAAQA,CAAAA,CAAI,IAAI,MAAM,sBAAsB,CAAA,CAC3E,QAAQ,KAAA,CAAMC,CAAS,EACvBL,CAAAA,CAASK,CAAS,EAGlB,UAAA,CAAW,IAAML,CAAAA,CAAS,IAAI,EAAGL,CAAO,EAC1C,CACF,CAAA,CACA,CAACA,CAAO,CACV,CAAA,CAEA,OAAO,CAAE,SAAAC,CAAAA,CAAU,IAAA,CAAAK,EAAM,KAAA,CAAAF,CAAM,CACjC,CCpDO,SAASO,EAAAA,CAAcC,CAAAA,CAAwB,CACpD,IAAMC,CAAAA,CAAcC,CAAAA,EACd,OAAO,OAAW,GAAA,CACb,MAAA,CAAO,WAAWA,CAAC,CAAA,CAAE,QAEvB,KAAA,CAGH,CAACC,CAAAA,CAASC,CAAU,EAAIb,UAAAA,CAAkBU,CAAAA,CAAWD,CAAK,CAAC,CAAA,CAEjE,OAAAK,WAAAA,CAAU,IAAM,CACd,IAAMC,EAAQ,MAAA,CAAO,UAAA,CAAWN,CAAK,CAAA,CAC/BO,CAAAA,CAAW,IAAMH,CAAAA,CAAWE,CAAAA,CAAM,OAAO,CAAA,CAG/C,OAAAC,CAAAA,EAAS,CACT,OAAO,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 { 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","/**\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
@@ -61,9 +61,6 @@
|
|
61
61
|
--tw-translate-y: -50%;
|
62
62
|
translate: var(--tw-translate-x) var(--tw-translate-y);
|
63
63
|
}
|
64
|
-
.animate-in {
|
65
|
-
animation: enter var(--tw-animation-duration,var(--tw-duration,.15s))var(--tw-ease,ease)var(--tw-animation-delay,0s)var(--tw-animation-iteration-count,1)var(--tw-animation-direction,normal)var(--tw-animation-fill-mode,none);
|
66
|
-
}
|
67
64
|
.resize {
|
68
65
|
resize: both;
|
69
66
|
}
|
@@ -172,27 +169,20 @@
|
|
172
169
|
--tw-backdrop-saturate: saturate(150%);
|
173
170
|
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
171
|
}
|
172
|
+
.transition {
|
173
|
+
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;
|
174
|
+
transition-timing-function: var(--tw-ease, cubic-bezier(0.4, 0, 0.2, 1));
|
175
|
+
transition-duration: var(--tw-duration, 150ms);
|
176
|
+
}
|
175
177
|
.transition-colors {
|
176
178
|
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;
|
177
179
|
transition-timing-function: var(--tw-ease, cubic-bezier(0.4, 0, 0.2, 1));
|
178
180
|
transition-duration: var(--tw-duration, 150ms);
|
179
181
|
}
|
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
182
|
.outline-none {
|
189
183
|
--tw-outline-style: none;
|
190
184
|
outline-style: none;
|
191
185
|
}
|
192
|
-
.zoom-in-95 {
|
193
|
-
--tw-enter-scale: calc(95*1%);
|
194
|
-
--tw-enter-scale: .95;
|
195
|
-
}
|
196
186
|
.sm\:flex-row {
|
197
187
|
@media (width >= 40rem) {
|
198
188
|
flex-direction: row;
|
@@ -213,90 +203,6 @@
|
|
213
203
|
}
|
214
204
|
}
|
215
205
|
}
|
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
206
|
:root {
|
301
207
|
--tuwa-success-bg: oklch(96.2% 0.044 156.743);
|
302
208
|
--tuwa-success-text: oklch(52.7% 0.154 150.069);
|
@@ -486,22 +392,11 @@
|
|
486
392
|
syntax: "*";
|
487
393
|
inherits: false;
|
488
394
|
}
|
489
|
-
@property --tw-duration {
|
490
|
-
syntax: "*";
|
491
|
-
inherits: false;
|
492
|
-
}
|
493
395
|
@property --tw-space-x-reverse {
|
494
396
|
syntax: "*";
|
495
397
|
inherits: false;
|
496
398
|
initial-value: 0;
|
497
399
|
}
|
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
400
|
@layer properties {
|
506
401
|
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
507
402
|
*, ::before, ::after, ::backdrop {
|
@@ -535,25 +430,7 @@
|
|
535
430
|
--tw-backdrop-opacity: initial;
|
536
431
|
--tw-backdrop-saturate: initial;
|
537
432
|
--tw-backdrop-sepia: initial;
|
538
|
-
--tw-duration: initial;
|
539
433
|
--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
434
|
}
|
558
435
|
}
|
559
436
|
}
|
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;
|
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;
|
package/dist/index.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import*as c from'react';import {useState,useCallback,useEffect}from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsxs,jsx}from'react/jsx-runtime';import*as
|
2
|
-
export{
|
1
|
+
import*as c from'react';import {useState,useCallback,useEffect}from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsxs,jsx}from'react/jsx-runtime';import*as a from'@radix-ui/react-dialog';import {AnimatePresence,motion}from'framer-motion';function s(...e){return twMerge(clsx(e))}var m=e=>e&&typeof e=="object"&&!Array.isArray(e);function R(e,t){let i={...e};return m(e)&&m(t)&&Object.keys(t).forEach(o=>{let r=e[o],l=t[o];m(r)&&m(l)?i[o]=R(r,l):i[o]=l;}),i}function W(e,t,i){if(!e)return "";if(e.length<=t+i)return e;let o=e.slice(0,t),r=e.slice(e.length-i);return `${o}...${r}`}var P=c.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:s("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"})]}));P.displayName="CloseIcon";var q=a.Root,ee=a.Trigger,C=a.Portal,te=a.Close,N={initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,transition:{duration:.2}}},T={initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},x=c.forwardRef(({className:e,backdropAnimation:t,...i},o)=>jsx(AnimatePresence,{children:jsx(motion.div,{variants:t??T,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"relative rounded-2xl overflow-hidden",children:jsx(a.Overlay,{ref:o,className:s("fixed inset-0 z-50 bg-black/55 backdrop-blur-sm backdrop-saturate-150",e),...i})})}));x.displayName=a.Overlay.displayName;var E=c.forwardRef(({className:e,children:t,modalAnimation:i,backdropAnimation:o,...r},l)=>jsxs(C,{children:[jsx(x,{backdropAnimation:o}),jsx(a.Content,{"aria-describedby":"tuwa:modal-content",ref:l,className:s("fixed left-[50%] top-[50%] z-50 w-full max-w-full translate-x-[-50%] translate-y-[-50%] p-4 outline-none",e),...r,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??N,transition:{duration:.2,ease:"easeInOut"},animate:"animate",initial:"initial",exit:"exit",className:"relative rounded-2xl overflow-hidden",children:jsx("div",{className:s("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})})})})})]}));E.displayName=a.Content.displayName;var V=({className:e,...t})=>jsx("div",{"aria-describedby":"tuwa:modal-header",className:s("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});V.displayName="DialogHeader";var k=({className:e,...t})=>jsx("div",{"aria-describedby":"tuwa:modal-footer",className:s("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});k.displayName="DialogFooter";var A=c.forwardRef(({className:e,...t},i)=>jsx(a.Title,{ref:i,"aria-describedby":"tuwa:modal-title",className:s("text-lg font-bold leading-none tracking-tight text-[var(--tuwa-text-primary)] m-0",e),...t}));A.displayName=a.Title.displayName;var M=c.forwardRef(({className:e,...t},i)=>jsx(a.Description,{"aria-describedby":"tuwa:modal-description",ref:i,className:s("text-sm text-[var(--tuwa-text-secondary)]",e),...t}));M.displayName=a.Description.displayName;function re(e=2e3){let[t,i]=useState(false),[o,r]=useState(null),l=useCallback(async p=>{if(p)try{await navigator.clipboard.writeText(p),i(!0),r(null),setTimeout(()=>i(!1),e);}catch(f){let u=f instanceof Error?f:new Error("Failed to copy text.");console.error(u),r(u),setTimeout(()=>r(null),e);}},[e]);return {isCopied:t,copy:l,error:o}}function se(e){let t=r=>typeof window<"u"?window.matchMedia(r).matches:false,[i,o]=useState(t(e));return useEffect(()=>{let r=window.matchMedia(e),l=()=>o(r.matches);return l(),window.addEventListener("resize",l),()=>window.removeEventListener("resize",l)},[e]),i}
|
2
|
+
export{P as CloseIcon,q as Dialog,te as DialogClose,E as DialogContent,M as DialogDescription,k as DialogFooter,V as DialogHeader,x as DialogOverlay,C as DialogPortal,A as DialogTitle,ee as DialogTrigger,s as cn,R as deepMerge,W as textCenterEllipsis,re as useCopyToClipboard,se as useMediaQuery};//# sourceMappingURL=index.js.map
|
3
3
|
//# 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,CAAI,CAAA,CAkBzD,SAASC,CAAAA,CAA4BC,CAAAA,CAAWC,CAAAA,CAAuB,CAE5E,IAAMC,EAAS,CAAE,GAAGF,CAAO,CAAA,CAE3B,OAAIH,CAAAA,CAASG,CAAM,CAAA,EAAKH,EAASI,CAAM,CAAA,EAErC,MAAA,CAAO,IAAA,CAAKA,CAAM,CAAA,CAAE,OAAA,CAASE,CAAAA,EAAQ,CACnC,IAAMC,CAAAA,CAAcJ,CAAAA,CAAOG,CAAc,CAAA,CACnCE,CAAAA,CAAcJ,CAAAA,CAAOE,CAAc,EAG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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/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","useCopyToClipboard","timeout","isCopied","setIsCopied","useState","error","setError","copy","useCallback","text","e","copyError","useMediaQuery","query","getMatches","q","matches","setMatches","useEffect","media","listener"],"mappings":"6QAwBO,SAASA,KAAMC,CAAAA,CAA8B,CAClD,OAAOC,OAAAA,CAAQC,IAAAA,CAAKF,CAAM,CAAC,CAC7B,CChBA,IAAMG,EAAYC,CAAAA,EACTA,CAAAA,EAAQ,OAAOA,CAAAA,EAAS,QAAA,EAAY,CAAC,KAAA,CAAM,OAAA,CAAQA,CAAI,CAAA,CAkBzD,SAASC,CAAAA,CAA4BC,CAAAA,CAAWC,EAAuB,CAE5E,IAAMC,EAAS,CAAE,GAAGF,CAAO,CAAA,CAE3B,OAAIH,CAAAA,CAASG,CAAM,GAAKH,CAAAA,CAASI,CAAM,GAErC,MAAA,CAAO,IAAA,CAAKA,CAAM,CAAA,CAAE,QAASE,CAAAA,EAAQ,CACnC,IAAMC,CAAAA,CAAcJ,CAAAA,CAAOG,CAAc,CAAA,CACnCE,CAAAA,CAAcJ,CAAAA,CAAOE,CAAc,EAGrCN,CAAAA,CAASO,CAAW,GAAKP,CAAAA,CAASQ,CAAW,EAG9CH,CAAAA,CAA+BC,CAAG,CAAA,CAAIJ,CAAAA,CAAUK,EAAaC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EAAY,CAAA,CAAK,CAAA,CAAGF,CAAO,EAC9C,OAASS,CAAAA,CAAG,CACV,IAAMC,CAAAA,CAAYD,CAAAA,YAAa,MAAQA,CAAAA,CAAI,IAAI,MAAM,sBAAsB,CAAA,CAC3E,QAAQ,KAAA,CAAMC,CAAS,EACvBL,CAAAA,CAASK,CAAS,EAGlB,UAAA,CAAW,IAAML,CAAAA,CAAS,IAAI,EAAGL,CAAO,EAC1C,CACF,CAAA,CACA,CAACA,CAAO,CACV,CAAA,CAEA,OAAO,CAAE,SAAAC,CAAAA,CAAU,IAAA,CAAAK,EAAM,KAAA,CAAAF,CAAM,CACjC,CCpDO,SAASO,EAAAA,CAAcC,CAAAA,CAAwB,CACpD,IAAMC,CAAAA,CAAcC,CAAAA,EACd,OAAO,OAAW,GAAA,CACb,MAAA,CAAO,WAAWA,CAAC,CAAA,CAAE,QAEvB,KAAA,CAGH,CAACC,CAAAA,CAASC,CAAU,EAAIb,QAAAA,CAAkBU,CAAAA,CAAWD,CAAK,CAAC,CAAA,CAEjE,OAAAK,SAAAA,CAAU,IAAM,CACd,IAAMC,EAAQ,MAAA,CAAO,UAAA,CAAWN,CAAK,CAAA,CAC/BO,CAAAA,CAAW,IAAMH,CAAAA,CAAWE,CAAAA,CAAM,OAAO,CAAA,CAG/C,OAAAC,CAAAA,EAAS,CACT,OAAO,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 { 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","/**\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.8.2a0be00",
|
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
|
},
|