@tuwaio/nova-core 0.0.5 → 0.0.6
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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +3 -0
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
'use strict';var react=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge');function
|
1
|
+
'use strict';var react=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge');function w(e=2e3){let[o,t]=react.useState(false),[n,r]=react.useState(null),s=react.useCallback(async a=>{if(a)try{await navigator.clipboard.writeText(a),t(!0),r(null),setTimeout(()=>t(!1),e);}catch(c){let l=c instanceof Error?c:new Error("Failed to copy text.");console.error(l),r(l),setTimeout(()=>r(null),e);}},[e]);return {isCopied:o,copy:s,error:n}}function E(e){let o=r=>typeof window<"u"?window.matchMedia(r).matches:false,[t,n]=react.useState(o(e));return react.useEffect(()=>{let r=window.matchMedia(e),s=()=>n(r.matches);return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[e]),t}function v(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var i=e=>e&&typeof e=="object"&&!Array.isArray(e);function g(e,o){let t={...e};return i(e)&&i(o)&&Object.keys(o).forEach(n=>{let r=e[n],s=o[n];i(r)&&i(s)?t[n]=g(r,s):t[n]=s;}),t}function R(e,o,t){if(!e)return "";if(e.length<=o+t)return e;let n=e.slice(0,o),r=e.slice(e.length-t);return `${n}...${r}`}exports.cn=v;exports.deepMerge=g;exports.textCenterEllipsis=R;exports.useCopyToClipboard=w;exports.useMediaQuery=E;//# sourceMappingURL=index.cjs.map
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useCopyToClipboard.ts","../src/utils/cn.ts","../src/utils/deepMerge.ts","../src/utils/textCenterEllipsis.ts"],"names":["useCopyToClipboard","timeout","isCopied","setIsCopied","useState","error","setError","copy","useCallback","text","e","copyError","cn","inputs","twMerge","clsx","isObject","item","deepMerge","target","source","output","key","targetValue","sourceValue","textCenterEllipsis","str","from","to","start","end"],"mappings":"qGA6BO,SAASA,CAAAA,CAAmBC,CAAAA,CAAU,GAAA,CAI3C,CACA,GAAM,CAACC,CAAAA,CAAUC,CAAW,CAAA,CAAIC,cAAAA,CAAS,KAAK,CAAA,CACxC,CAACC,CAAAA,CAAOC,CAAQ,CAAA,CAAIF,
|
1
|
+
{"version":3,"sources":["../src/hooks/useCopyToClipboard.ts","../src/hooks/useMediaQuery.ts","../src/utils/cn.ts","../src/utils/deepMerge.ts","../src/utils/textCenterEllipsis.ts"],"names":["useCopyToClipboard","timeout","isCopied","setIsCopied","useState","error","setError","copy","useCallback","text","e","copyError","useMediaQuery","query","getMatches","q","matches","setMatches","useEffect","media","listener","cn","inputs","twMerge","clsx","isObject","item","deepMerge","target","source","output","key","targetValue","sourceValue","textCenterEllipsis","str","from","to","start","end"],"mappings":"qGA6BO,SAASA,CAAAA,CAAmBC,CAAAA,CAAU,GAAA,CAI3C,CACA,GAAM,CAACC,CAAAA,CAAUC,CAAW,CAAA,CAAIC,cAAAA,CAAS,KAAK,CAAA,CACxC,CAACC,CAAAA,CAAOC,CAAQ,CAAA,CAAIF,eAAuB,IAAI,CAAA,CAE/CG,CAAAA,CAAOC,iBAAAA,CACX,MAAOC,CAAAA,EAAiB,CACtB,GAAKA,EAEL,GAAI,CACF,MAAM,SAAA,CAAU,SAAA,CAAU,SAAA,CAAUA,CAAI,CAAA,CACxCN,EAAY,CAAA,CAAI,CAAA,CAChBG,CAAAA,CAAS,IAAI,CAAA,CAEb,UAAA,CAAW,IAAMH,CAAAA,CAAY,EAAK,CAAA,CAAGF,CAAO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AkBzD,SAASC,CAAAA,CAA4BC,CAAAA,CAAWC,CAAAA,CAAuB,CAE5E,IAAMC,CAAAA,CAAS,CAAE,GAAGF,CAAO,CAAA,CAE3B,OAAIH,CAAAA,CAASG,CAAM,CAAA,EAAKH,CAAAA,CAASI,CAAM,CAAA,EAErC,OAAO,IAAA,CAAKA,CAAM,CAAA,CAAE,OAAA,CAASE,CAAAA,EAAQ,CACnC,IAAMC,CAAAA,CAAcJ,EAAOG,CAAc,CAAA,CACnCE,CAAAA,CAAcJ,CAAAA,CAAOE,CAAc,CAAA,CAGrCN,CAAAA,CAASO,CAAW,GAAKP,CAAAA,CAASQ,CAAW,CAAA,CAG9CH,CAAAA,CAA+BC,CAAG,CAAA,CAAIJ,CAAAA,CAAUK,CAAAA,CAAaC,CAAW,CAAA,CAGxEH,CAAAA,CAA+BC,CAAG,CAAA,CAAIE,EAE3C,CAAC,CAAA,CAGIH,CACT,CCjCO,SAASI,CAAAA,CAAmBC,CAAAA,CAAgCC,CAAAA,CAAcC,CAAAA,CAAoB,CACnG,GAAI,CAACF,EACH,OAAO,EAAA,CAIT,GAAIA,CAAAA,CAAI,MAAA,EAAUC,CAAAA,CAAOC,CAAAA,CACvB,OAAOF,EAGT,IAAMG,CAAAA,CAAQH,CAAAA,CAAI,KAAA,CAAM,CAAA,CAAGC,CAAI,CAAA,CACzBG,CAAAA,CAAMJ,EAAI,KAAA,CAAMA,CAAAA,CAAI,MAAA,CAASE,CAAE,EAErC,OAAO,CAAA,EAAGC,CAAK,CAAA,GAAA,EAAMC,CAAG,CAAA,CAC1B","file":"index.cjs","sourcesContent":["/**\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","/**\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"]}
|
package/dist/index.css
CHANGED
package/dist/index.d.cts
CHANGED
@@ -32,6 +32,14 @@ declare function useCopyToClipboard(timeout?: number): {
|
|
32
32
|
error: Error | null;
|
33
33
|
};
|
34
34
|
|
35
|
+
/**
|
36
|
+
* A custom hook to detect if a media query matches the current screen dimensions.
|
37
|
+
* Handles SSR gracefully.
|
38
|
+
* @param {string} query - The media query string (e.g., '(max-width: 767px)').
|
39
|
+
* @returns {boolean} Whether the query matches or not.
|
40
|
+
*/
|
41
|
+
declare function useMediaQuery(query: string): boolean;
|
42
|
+
|
35
43
|
/**
|
36
44
|
* @file This file contains a utility function for conditionally merging Tailwind CSS classes.
|
37
45
|
*/
|
@@ -95,4 +103,4 @@ declare function deepMerge<T extends object>(target: T, source: Partial<T>): T;
|
|
95
103
|
*/
|
96
104
|
declare function textCenterEllipsis(str: string | undefined | null, from: number, to: number): string;
|
97
105
|
|
98
|
-
export { cn, deepMerge, textCenterEllipsis, useCopyToClipboard };
|
106
|
+
export { cn, deepMerge, textCenterEllipsis, useCopyToClipboard, useMediaQuery };
|
package/dist/index.d.ts
CHANGED
@@ -32,6 +32,14 @@ declare function useCopyToClipboard(timeout?: number): {
|
|
32
32
|
error: Error | null;
|
33
33
|
};
|
34
34
|
|
35
|
+
/**
|
36
|
+
* A custom hook to detect if a media query matches the current screen dimensions.
|
37
|
+
* Handles SSR gracefully.
|
38
|
+
* @param {string} query - The media query string (e.g., '(max-width: 767px)').
|
39
|
+
* @returns {boolean} Whether the query matches or not.
|
40
|
+
*/
|
41
|
+
declare function useMediaQuery(query: string): boolean;
|
42
|
+
|
35
43
|
/**
|
36
44
|
* @file This file contains a utility function for conditionally merging Tailwind CSS classes.
|
37
45
|
*/
|
@@ -95,4 +103,4 @@ declare function deepMerge<T extends object>(target: T, source: Partial<T>): T;
|
|
95
103
|
*/
|
96
104
|
declare function textCenterEllipsis(str: string | undefined | null, from: number, to: number): string;
|
97
105
|
|
98
|
-
export { cn, deepMerge, textCenterEllipsis, useCopyToClipboard };
|
106
|
+
export { cn, deepMerge, textCenterEllipsis, useCopyToClipboard, useMediaQuery };
|
package/dist/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import {useState,useCallback}from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';function
|
1
|
+
import {useState,useCallback,useEffect}from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';function w(e=2e3){let[o,t]=useState(false),[n,r]=useState(null),s=useCallback(async a=>{if(a)try{await navigator.clipboard.writeText(a),t(!0),r(null),setTimeout(()=>t(!1),e);}catch(c){let l=c instanceof Error?c:new Error("Failed to copy text.");console.error(l),r(l),setTimeout(()=>r(null),e);}},[e]);return {isCopied:o,copy:s,error:n}}function E(e){let o=r=>typeof window<"u"?window.matchMedia(r).matches:false,[t,n]=useState(o(e));return useEffect(()=>{let r=window.matchMedia(e),s=()=>n(r.matches);return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[e]),t}function v(...e){return twMerge(clsx(e))}var i=e=>e&&typeof e=="object"&&!Array.isArray(e);function g(e,o){let t={...e};return i(e)&&i(o)&&Object.keys(o).forEach(n=>{let r=e[n],s=o[n];i(r)&&i(s)?t[n]=g(r,s):t[n]=s;}),t}function R(e,o,t){if(!e)return "";if(e.length<=o+t)return e;let n=e.slice(0,o),r=e.slice(e.length-t);return `${n}...${r}`}export{v as cn,g as deepMerge,R as textCenterEllipsis,w as useCopyToClipboard,E as useMediaQuery};//# sourceMappingURL=index.js.map
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useCopyToClipboard.ts","../src/utils/cn.ts","../src/utils/deepMerge.ts","../src/utils/textCenterEllipsis.ts"],"names":["useCopyToClipboard","timeout","isCopied","setIsCopied","useState","error","setError","copy","useCallback","text","e","copyError","cn","inputs","twMerge","clsx","isObject","item","deepMerge","target","source","output","key","targetValue","sourceValue","textCenterEllipsis","str","from","to","start","end"],"mappings":"
|
1
|
+
{"version":3,"sources":["../src/hooks/useCopyToClipboard.ts","../src/hooks/useMediaQuery.ts","../src/utils/cn.ts","../src/utils/deepMerge.ts","../src/utils/textCenterEllipsis.ts"],"names":["useCopyToClipboard","timeout","isCopied","setIsCopied","useState","error","setError","copy","useCallback","text","e","copyError","useMediaQuery","query","getMatches","q","matches","setMatches","useEffect","media","listener","cn","inputs","twMerge","clsx","isObject","item","deepMerge","target","source","output","key","targetValue","sourceValue","textCenterEllipsis","str","from","to","start","end"],"mappings":"gHA6BO,SAASA,CAAAA,CAAmBC,CAAAA,CAAU,GAAA,CAI3C,CACA,GAAM,CAACC,CAAAA,CAAUC,CAAW,CAAA,CAAIC,QAAAA,CAAS,KAAK,CAAA,CACxC,CAACC,CAAAA,CAAOC,CAAQ,CAAA,CAAIF,SAAuB,IAAI,CAAA,CAE/CG,CAAAA,CAAOC,WAAAA,CACX,MAAOC,CAAAA,EAAiB,CACtB,GAAKA,EAEL,GAAI,CACF,MAAM,SAAA,CAAU,SAAA,CAAU,SAAA,CAAUA,CAAI,CAAA,CACxCN,EAAY,CAA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AA,CAAYC,CAAAA,EACTA,GAAQ,OAAOA,CAAAA,EAAS,QAAA,EAAY,CAAC,KAAA,CAAM,OAAA,CAAQA,CAAI,CAAA,CAkBzD,SAASC,CAAAA,CAA4BC,CAAAA,CAAWC,CAAAA,CAAuB,CAE5E,IAAMC,CAAAA,CAAS,CAAE,GAAGF,CAAO,CAAA,CAE3B,OAAIH,CAAAA,CAASG,CAAM,CAAA,EAAKH,CAAAA,CAASI,CAAM,CAAA,EAErC,OAAO,IAAA,CAAKA,CAAM,CAAA,CAAE,OAAA,CAASE,CAAAA,EAAQ,CACnC,IAAMC,CAAAA,CAAcJ,EAAOG,CAAc,CAAA,CACnCE,CAAAA,CAAcJ,CAAAA,CAAOE,CAAc,CAAA,CAGrCN,CAAAA,CAASO,CAAW,GAAKP,CAAAA,CAASQ,CAAW,CAAA,CAG9CH,CAAAA,CAA+BC,CAAG,CAAA,CAAIJ,CAAAA,CAAUK,CAAAA,CAAaC,CAAW,CAAA,CAGxEH,CAAAA,CAA+BC,CAAG,CAAA,CAAIE,EAE3C,CAAC,CAAA,CAGIH,CACT,CCjCO,SAASI,CAAAA,CAAmBC,CAAAA,CAAgCC,CAAAA,CAAcC,CAAAA,CAAoB,CACnG,GAAI,CAACF,EACH,OAAO,EAAA,CAIT,GAAIA,CAAAA,CAAI,MAAA,EAAUC,CAAAA,CAAOC,CAAAA,CACvB,OAAOF,EAGT,IAAMG,CAAAA,CAAQH,CAAAA,CAAI,KAAA,CAAM,CAAA,CAAGC,CAAI,CAAA,CACzBG,CAAAA,CAAMJ,EAAI,KAAA,CAAMA,CAAAA,CAAI,MAAA,CAASE,CAAE,EAErC,OAAO,CAAA,EAAGC,CAAK,CAAA,GAAA,EAAMC,CAAG,CAAA,CAC1B","file":"index.js","sourcesContent":["/**\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","/**\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"]}
|