@tuwaio/nova-core 0.5.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -85
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +192 -69
- package/dist/index.d.ts +192 -69
- package/dist/index.js +3 -3
- package/package.json +17 -15
package/dist/index.d.cts
CHANGED
|
@@ -4,6 +4,16 @@ import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
|
4
4
|
import { Variants } from 'framer-motion';
|
|
5
5
|
import { ClassValue } from 'clsx';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* A chevron that points up when `isOpen` is `true` and down otherwise, animated with `framer-motion` when it flips.
|
|
9
|
+
* Nova uses it in dropdown triggers such as the chain selector.
|
|
10
|
+
*
|
|
11
|
+
* @param props - The chevron props.
|
|
12
|
+
* @param props.className - Classes merged with the default size and color (`--tuwa-text-secondary`).
|
|
13
|
+
* @param props.strokeWidth - Stroke width of the SVG path. Defaults to `2`.
|
|
14
|
+
* @param props.isOpen - Whether the related list is open.
|
|
15
|
+
* @returns The SVG element.
|
|
16
|
+
*/
|
|
7
17
|
declare function ChevronArrowWithAnim({ className, strokeWidth, isOpen, }: {
|
|
8
18
|
className?: string;
|
|
9
19
|
strokeWidth?: number;
|
|
@@ -69,10 +79,29 @@ interface GithubFallbackIconProps extends Omit<ComponentProps<'img'>, 'src'> {
|
|
|
69
79
|
*/
|
|
70
80
|
declare function GithubFallbackIcon({ githubSrc, className, alt, firstPathFill, ...props }: GithubFallbackIconProps): React$1.JSX.Element;
|
|
71
81
|
|
|
82
|
+
/**
|
|
83
|
+
* The dialog root (`Root` of `@radix-ui/react-dialog`): holds the open state (`open`, `defaultOpen`, `onOpenChange`).
|
|
84
|
+
*/
|
|
72
85
|
declare const Dialog: React$1.FC<DialogPrimitive.DialogProps>;
|
|
86
|
+
/** The element that opens the dialog (`Trigger` of `@radix-ui/react-dialog`). */
|
|
73
87
|
declare const DialogTrigger: React$1.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
88
|
+
/** Renders its children in `document.body` (`Portal` of `@radix-ui/react-dialog`). {@link DialogContent} uses it. */
|
|
74
89
|
declare const DialogPortal: React$1.FC<DialogPrimitive.DialogPortalProps>;
|
|
90
|
+
/** An element that closes the dialog (`Close` of `@radix-ui/react-dialog`). */
|
|
75
91
|
declare const DialogClose: React$1.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
92
|
+
/**
|
|
93
|
+
* The dimmed, blurred backdrop behind the dialog, faded in and out with `framer-motion`. {@link DialogContent} renders
|
|
94
|
+
* it.
|
|
95
|
+
*
|
|
96
|
+
* Side effect: while it is mounted, the `NovaModalOpen` class is set on `document.body`; the stylesheet of this package
|
|
97
|
+
* uses it to stop the page from scrolling.
|
|
98
|
+
*
|
|
99
|
+
* @param props - The overlay props.
|
|
100
|
+
* @param props.className - Classes added to the backdrop element.
|
|
101
|
+
* @param props.backdropAnimation - `framer-motion` variants (`initial`, `animate`, `exit`) of the backdrop; a fade by
|
|
102
|
+
* default.
|
|
103
|
+
* @returns The backdrop.
|
|
104
|
+
*/
|
|
76
105
|
declare const DialogOverlay: {
|
|
77
106
|
({ className, backdropAnimation }: {
|
|
78
107
|
backdropAnimation?: Variants;
|
|
@@ -80,28 +109,77 @@ declare const DialogOverlay: {
|
|
|
80
109
|
}): React$1.JSX.Element;
|
|
81
110
|
displayName: string | undefined;
|
|
82
111
|
};
|
|
112
|
+
/**
|
|
113
|
+
* The dialog panel (`Content` of `@radix-ui/react-dialog`), rendered in a portal above {@link DialogOverlay}. It takes
|
|
114
|
+
* the props of the Radix `Content` plus `modalAnimation` and `backdropAnimation` (`framer-motion` variants). By default
|
|
115
|
+
* the panel scales in at the center of the screen, or slides up from the bottom on touch devices (`isTouchDevice`); its
|
|
116
|
+
* content scrolls when it is taller than the viewport. Use it inside {@link Dialog}.
|
|
117
|
+
*/
|
|
83
118
|
declare const DialogContent: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogContentProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
84
119
|
modalAnimation?: Variants;
|
|
85
120
|
backdropAnimation?: Variants;
|
|
86
121
|
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
122
|
+
/**
|
|
123
|
+
* A sticky header row of the dialog, with a bottom border.
|
|
124
|
+
*
|
|
125
|
+
* @param props - Props of the `<div>` element; `className` is merged with the default classes.
|
|
126
|
+
* @returns The header element.
|
|
127
|
+
*/
|
|
87
128
|
declare const DialogHeader: {
|
|
88
129
|
({ className, ...props }: React$1.HTMLAttributes<HTMLDivElement>): React$1.JSX.Element;
|
|
89
130
|
displayName: string;
|
|
90
131
|
};
|
|
132
|
+
/**
|
|
133
|
+
* A footer row of the dialog: stacked on small screens, aligned to the end on wider ones.
|
|
134
|
+
*
|
|
135
|
+
* @param props - Props of the `<div>` element; `className` is merged with the default classes.
|
|
136
|
+
* @returns The footer element.
|
|
137
|
+
*/
|
|
91
138
|
declare const DialogFooter: {
|
|
92
139
|
({ className, ...props }: React$1.HTMLAttributes<HTMLDivElement>): React$1.JSX.Element;
|
|
93
140
|
displayName: string;
|
|
94
141
|
};
|
|
142
|
+
/** The dialog title (`Title` of `@radix-ui/react-dialog`), styled with the Nova theme. */
|
|
95
143
|
declare const DialogTitle: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React$1.RefAttributes<HTMLHeadingElement>, "ref"> & React$1.RefAttributes<HTMLHeadingElement>>;
|
|
144
|
+
/** The dialog description (`Description` of `@radix-ui/react-dialog`), styled with the Nova theme. */
|
|
96
145
|
declare const DialogDescription: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React$1.RefAttributes<HTMLParagraphElement>, "ref"> & React$1.RefAttributes<HTMLParagraphElement>>;
|
|
97
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Props of {@link NetworkIcon}.
|
|
149
|
+
*/
|
|
98
150
|
interface NetworkIconProps {
|
|
151
|
+
/**
|
|
152
|
+
* The network: an EVM chain ID (`1`), or a string whose part before `:` is a network id of `@web3icons/common`
|
|
153
|
+
* (`'solana:devnet'`, `'base'`).
|
|
154
|
+
*/
|
|
99
155
|
chainId: number | string;
|
|
156
|
+
/** Icon style of `@web3icons/react`. Defaults to `'background'`. */
|
|
100
157
|
variant?: 'background' | 'branded' | 'mono';
|
|
158
|
+
/** Classes merged with the default classes (full size of the parent, rounded). */
|
|
101
159
|
className?: string;
|
|
102
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* The icon of a network. Networks listed in `@web3icons/common` are drawn with `@web3icons/react`, loaded on demand
|
|
163
|
+
* (a pulsing {@link FallbackIcon} is shown meanwhile) and rendered through {@link SvgToImg}. An unknown numeric chain
|
|
164
|
+
* shows a `?` placeholder; an unknown string id is fetched from the web3icons repository on GitHub
|
|
165
|
+
* ({@link GithubFallbackIcon}). Testnets and the Solana devnet and testnet are recolored with `--tuwa-testnet-icons`.
|
|
166
|
+
*
|
|
167
|
+
* Side effect: a GitHub request (`raw.githubusercontent.com`) for icons that `@web3icons/common` does not list.
|
|
168
|
+
*
|
|
169
|
+
* @param props - See {@link NetworkIconProps}.
|
|
170
|
+
* @returns The icon element.
|
|
171
|
+
*/
|
|
103
172
|
declare function NetworkIcon({ chainId, variant, className }: NetworkIconProps): React$1.JSX.Element;
|
|
104
173
|
|
|
174
|
+
/**
|
|
175
|
+
* An animated background of twinkling stars, drawn as SVG circles with CSS animations. It fills its positioned parent
|
|
176
|
+
* (`absolute`, `inset-0`); the stars are placed at random over the window size after mount, so nothing is rendered on
|
|
177
|
+
* the server. Nova Connect uses it in the "about wallets" and "get a wallet" screens of the connect modal.
|
|
178
|
+
*
|
|
179
|
+
* @param props - The background props.
|
|
180
|
+
* @param props.starsCount - Number of stars. Defaults to `200`.
|
|
181
|
+
* @returns The background element.
|
|
182
|
+
*/
|
|
105
183
|
declare function StarsBackground({ starsCount }: {
|
|
106
184
|
starsCount?: number;
|
|
107
185
|
}): React$1.JSX.Element;
|
|
@@ -126,7 +204,12 @@ declare function SvgImg({ src, alt, ...props }: SvgImgProps): React$1.JSX.Elemen
|
|
|
126
204
|
* Props for the SvgToImg component.
|
|
127
205
|
*/
|
|
128
206
|
interface SvgToImgProps extends Omit<ComponentProps<'img'>, 'ref' | 'src' | 'children'> {
|
|
129
|
-
/**
|
|
207
|
+
/**
|
|
208
|
+
* Renders the SVG. Pass `ref` to the `<svg>` element: when it mounts, its markup is converted to an image.
|
|
209
|
+
*
|
|
210
|
+
* @param ref - Callback ref for the `<svg>` element; it receives the element (or `null` when it unmounts).
|
|
211
|
+
* @returns The SVG to convert.
|
|
212
|
+
*/
|
|
130
213
|
children: (ref: (node: SVGSVGElement | null) => void) => ReactNode;
|
|
131
214
|
/**
|
|
132
215
|
* Unique identifier for the icon. When this changes, the cached image is reset.
|
|
@@ -149,14 +232,22 @@ interface SvgToImgProps extends Omit<ComponentProps<'img'>, 'ref' | 'src' | 'chi
|
|
|
149
232
|
* Uses a render prop pattern to inject a callback ref that captures
|
|
150
233
|
* the SVG immediately when it mounts.
|
|
151
234
|
*
|
|
152
|
-
* @param props - {@link SvgToImgProps}
|
|
153
|
-
* @returns The converted
|
|
235
|
+
* @param props - See {@link SvgToImgProps}; the other props are passed to the `<img>` element.
|
|
236
|
+
* @returns The `<img>` with the converted SVG, or the output of `children` until the SVG has mounted.
|
|
154
237
|
*
|
|
155
238
|
* @example
|
|
156
239
|
* ```tsx
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
240
|
+
* import { SvgToImg } from '@tuwaio/nova-core';
|
|
241
|
+
*
|
|
242
|
+
* export const DotIcon = () => (
|
|
243
|
+
* <SvgToImg iconId="dot" alt="Dot">
|
|
244
|
+
* {(ref) => (
|
|
245
|
+
* <svg ref={ref} viewBox="0 0 24 24">
|
|
246
|
+
* <circle cx="12" cy="12" r="10" />
|
|
247
|
+
* </svg>
|
|
248
|
+
* )}
|
|
249
|
+
* </SvgToImg>
|
|
250
|
+
* );
|
|
160
251
|
* ```
|
|
161
252
|
*/
|
|
162
253
|
declare function SvgToImg({ children, iconId, alt, firstPathFill, ...props }: SvgToImgProps): React$1.JSX.Element;
|
|
@@ -169,17 +260,14 @@ declare function SvgToImg({ children, iconId, alt, firstPathFill, ...props }: Sv
|
|
|
169
260
|
*/
|
|
170
261
|
type ToastCloseButtonProps = {
|
|
171
262
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
263
|
+
* Called when the button is clicked. `react-toastify` passes it to a custom close button to dismiss the toast.
|
|
264
|
+
*
|
|
265
|
+
* @param e - The click event.
|
|
174
266
|
*/
|
|
175
267
|
closeToast?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
176
|
-
/**
|
|
177
|
-
* Optional custom aria-label for accessibility.
|
|
178
|
-
*/
|
|
268
|
+
/** Accessible label of the button. Defaults to `'Close toast notification'`. */
|
|
179
269
|
ariaLabel?: string;
|
|
180
|
-
/**
|
|
181
|
-
* Optional custom title for the button tooltip.
|
|
182
|
-
*/
|
|
270
|
+
/** Tooltip of the button. Defaults to `'Close toast notification'`. */
|
|
183
271
|
title?: string;
|
|
184
272
|
/**
|
|
185
273
|
* Optional custom className for the button container.
|
|
@@ -191,8 +279,11 @@ type ToastCloseButtonProps = {
|
|
|
191
279
|
iconClassName?: string;
|
|
192
280
|
};
|
|
193
281
|
/**
|
|
194
|
-
* A
|
|
195
|
-
*
|
|
282
|
+
* A close button with an X icon, placed in the top-right corner of a toast (`absolute`) and styled with the `--tuwa-*`
|
|
283
|
+
* variables. Pass it to `react-toastify` as `closeButton`, which provides `closeToast`.
|
|
284
|
+
*
|
|
285
|
+
* @param props - See {@link ToastCloseButtonProps}.
|
|
286
|
+
* @returns The button element.
|
|
196
287
|
*/
|
|
197
288
|
declare function ToastCloseButton({ closeToast, ariaLabel, title, className, iconClassName, }: ToastCloseButtonProps): React$1.JSX.Element;
|
|
198
289
|
|
|
@@ -230,42 +321,74 @@ declare function WalletIcon({ walletName, variant, className }: WalletIconProps)
|
|
|
230
321
|
* @file This file contains a custom React hook for copying text to the clipboard.
|
|
231
322
|
*/
|
|
232
323
|
/**
|
|
233
|
-
*
|
|
234
|
-
*
|
|
324
|
+
* Result of `copy` of {@link useCopyToClipboard}: `copied: true`, or `copied: false` with the error (also without
|
|
325
|
+
* text to copy).
|
|
326
|
+
*/
|
|
327
|
+
type CopyToClipboardResult = {
|
|
328
|
+
copied: true;
|
|
329
|
+
} | {
|
|
330
|
+
copied: false;
|
|
331
|
+
error: Error;
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* Value returned by {@link useCopyToClipboard}.
|
|
335
|
+
*/
|
|
336
|
+
interface UseCopyToClipboardResult {
|
|
337
|
+
/** `true` for `timeout` milliseconds after a successful copy */
|
|
338
|
+
isCopied: boolean;
|
|
339
|
+
/**
|
|
340
|
+
* Writes the text to the clipboard (`navigator.clipboard.writeText`). A failed write is logged with
|
|
341
|
+
* `console.error` and kept in `error` for `timeout` milliseconds.
|
|
342
|
+
*
|
|
343
|
+
* @param text - The text to copy.
|
|
344
|
+
* @returns Whether the text was copied, with the error when it was not.
|
|
345
|
+
*/
|
|
346
|
+
copy: (text: string) => Promise<CopyToClipboardResult>;
|
|
347
|
+
/** The error of the last failed write, for `timeout` milliseconds */
|
|
348
|
+
error: Error | null;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Copies text to the clipboard and keeps a "copied" state for user feedback.
|
|
235
352
|
*
|
|
236
|
-
* @param
|
|
237
|
-
* @returns {
|
|
238
|
-
* isCopied: boolean;
|
|
239
|
-
* copy: (text: string) => Promise<void>;
|
|
240
|
-
* error: Error | null;
|
|
241
|
-
* }} An object containing the `isCopied` state, the `copy` function, and any potential error.
|
|
353
|
+
* @param timeout - How long `isCopied` (and `error` after a failure) stays set, in milliseconds (default: `2000`).
|
|
354
|
+
* @returns See {@link UseCopyToClipboardResult}.
|
|
242
355
|
*
|
|
243
356
|
* @example
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
* );
|
|
357
|
+
* ```tsx
|
|
358
|
+
* import { useCopyToClipboard } from '@tuwaio/nova-core';
|
|
359
|
+
*
|
|
360
|
+
* export function CopyAddress({ address }: { address: string }) {
|
|
361
|
+
* const { isCopied, copy } = useCopyToClipboard();
|
|
362
|
+
*
|
|
363
|
+
* const handleClick = async () => {
|
|
364
|
+
* const result = await copy(address);
|
|
365
|
+
* if (!result.copied) console.warn(result.error.message);
|
|
366
|
+
* };
|
|
367
|
+
*
|
|
368
|
+
* return (
|
|
369
|
+
* <button type="button" onClick={handleClick}>
|
|
370
|
+
* {isCopied ? 'Copied!' : 'Copy address'}
|
|
371
|
+
* </button>
|
|
372
|
+
* );
|
|
253
373
|
* }
|
|
374
|
+
* ```
|
|
254
375
|
*/
|
|
255
|
-
declare function useCopyToClipboard(timeout?: number):
|
|
256
|
-
isCopied: boolean;
|
|
257
|
-
copy: (text: string) => Promise<void>;
|
|
258
|
-
error: Error | null;
|
|
259
|
-
};
|
|
376
|
+
declare function useCopyToClipboard(timeout?: number): UseCopyToClipboardResult;
|
|
260
377
|
|
|
261
378
|
/**
|
|
262
379
|
* A custom hook to detect if a media query matches the current screen dimensions.
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
380
|
+
* Returns `false` on the server. In the browser it checks the query again on every `resize` event of `window`
|
|
381
|
+
* (a listener that is removed on unmount).
|
|
382
|
+
*
|
|
383
|
+
* @param query - The media query string (e.g., '(max-width: 767px)').
|
|
384
|
+
* @returns Whether the query matches.
|
|
266
385
|
*/
|
|
267
386
|
declare function useMediaQuery(query: string): boolean;
|
|
268
387
|
|
|
388
|
+
/**
|
|
389
|
+
* Classes of the standard secondary button of Nova (Tailwind utilities with the `novacore:` prefix, styled with the
|
|
390
|
+
* `--tuwa-standart-button-*` variables). The connect modal uses them for its buttons.
|
|
391
|
+
*/
|
|
269
392
|
declare const standardButtonClasses = "novacore:cursor-pointer novacore:rounded-[var(--tuwa-rounded-corners)] novacore:bg-[var(--tuwa-standart-button-bg)] novacore:px-3 novacore:py-2 novacore:flex novacore:items-center novacore:gap-1 novacore:text-sm novacore:font-mono novacore:font-semibold novacore:text-[var(--tuwa-text-primary)] novacore:transition-colors novacore:hover:bg-[var(--tuwa-standart-button-hover)] novacore:disabled:cursor-not-allowed novacore:disabled:opacity-50 novacore:min-h-[36px]";
|
|
270
393
|
|
|
271
394
|
/**
|
|
@@ -334,22 +457,24 @@ interface ChainInfo {
|
|
|
334
457
|
* For string IDs with environment suffixes (like "solana:devnet"),
|
|
335
458
|
* the suffix is appended to the name if it's a known dev/test environment.
|
|
336
459
|
*
|
|
460
|
+
* The networks are looked up in the metadata of `@web3icons/common`.
|
|
461
|
+
*
|
|
337
462
|
* @param chainId - Chain identifier (number for EVM, string for non-EVM)
|
|
338
|
-
* @returns
|
|
463
|
+
* @returns The network name, id and icon file path, and the original `chainId`; `'Unknown'`/`'unknown'` when the
|
|
464
|
+
* network is not listed.
|
|
339
465
|
*
|
|
340
466
|
* @example
|
|
341
467
|
* ```ts
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
468
|
+
* import { getChainName } from '@tuwaio/nova-core';
|
|
469
|
+
*
|
|
470
|
+
* getChainName(1);
|
|
471
|
+
* // → { name: 'Ethereum', id: 'ethereum', filePath: 'ethereum', chainId: 1 }
|
|
345
472
|
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
* // → { name: "Solana Devnet", id: "solana", chainId: "solana:devnet" }
|
|
473
|
+
* getChainName('solana:devnet');
|
|
474
|
+
* // → { name: 'Solana Devnet', id: 'solana', filePath: 'solana', chainId: 'solana:devnet' }
|
|
349
475
|
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
* // → { name: "Unknown", id: "unknown", chainId: 999999 }
|
|
476
|
+
* getChainName(999999);
|
|
477
|
+
* // → { name: 'Unknown', id: 'unknown', filePath: 'unknown', chainId: 999999 }
|
|
353
478
|
* ```
|
|
354
479
|
*/
|
|
355
480
|
declare function getChainName(chainId: number | string): ChainInfo;
|
|
@@ -366,7 +491,7 @@ declare function getChainName(chainId: number | string): ChainInfo;
|
|
|
366
491
|
declare function isSolanaDev(chainId: number | string): boolean;
|
|
367
492
|
|
|
368
493
|
/**
|
|
369
|
-
* @
|
|
494
|
+
* @file Utility function to determine if the current environment supports touch input.
|
|
370
495
|
* This is safe to use in Next.js applications as it checks for the `window` object existence.
|
|
371
496
|
*/
|
|
372
497
|
/**
|
|
@@ -379,14 +504,16 @@ declare function isSolanaDev(chainId: number | string): boolean;
|
|
|
379
504
|
*
|
|
380
505
|
* This function is safe for server-side rendering (SSR) environments like Next.js.
|
|
381
506
|
*
|
|
382
|
-
* @param {number} [maxWidth=1200] The maximum screen width (in pixels) for a device to be considered 'touch' (default
|
|
383
|
-
*
|
|
507
|
+
* @param {number} [maxWidth=1200] The maximum screen width (in pixels) for a device to be considered 'touch' (default
|
|
508
|
+
* is 1200).
|
|
509
|
+
* @returns {boolean} Returns true if the environment is determined to support touch input AND is within the width
|
|
510
|
+
* limit, otherwise false.
|
|
384
511
|
*/
|
|
385
512
|
declare function isTouchDevice(maxWidth?: number): boolean;
|
|
386
513
|
|
|
387
514
|
/**
|
|
388
|
-
* Resolves a CSS variable to its computed value.
|
|
389
|
-
* Returns the original value if it's not a CSS variable.
|
|
515
|
+
* Resolves a CSS variable to its computed value on `document.documentElement`.
|
|
516
|
+
* Returns the original value if it's not a CSS variable. Call it in the browser: it reads `getComputedStyle`.
|
|
390
517
|
*
|
|
391
518
|
* @param value - Color value, potentially a CSS variable like `var(--my-color)`
|
|
392
519
|
* @returns Resolved color value (e.g., `#ff0000`) or original if not a variable
|
|
@@ -394,20 +521,20 @@ declare function isTouchDevice(maxWidth?: number): boolean;
|
|
|
394
521
|
declare function resolveCssVariable(value: string): string;
|
|
395
522
|
/**
|
|
396
523
|
* Modifies the fill attribute of the first `<path>` element in an SVG string.
|
|
397
|
-
* Uses DOMParser for safe XML manipulation.
|
|
398
|
-
* Automatically resolves CSS variables (e.g., `var(--color)`) to their computed values.
|
|
524
|
+
* Uses DOMParser for safe XML manipulation, so call it in the browser.
|
|
525
|
+
* Automatically resolves CSS variables (e.g., `var(--color)`) to their computed values with {@link resolveCssVariable}.
|
|
399
526
|
*
|
|
400
527
|
* @param svgString - The original SVG markup
|
|
401
528
|
* @param fillColor - The color to apply (supports CSS variables)
|
|
402
|
-
* @returns Modified SVG string
|
|
529
|
+
* @returns Modified SVG string, or the original string (with a console warning) when it cannot be parsed
|
|
403
530
|
*/
|
|
404
531
|
declare function applyFirstPathFill(svgString: string, fillColor: string): string;
|
|
405
532
|
/**
|
|
406
533
|
* Encodes an SVG string to a base64 data URL.
|
|
407
534
|
*
|
|
408
535
|
* @param svgString - The SVG markup
|
|
409
|
-
* @param firstPathFill - Optional fill color to apply to the first path
|
|
410
|
-
* @returns Base64-encoded data URL
|
|
536
|
+
* @param firstPathFill - Optional fill color to apply to the first path, with {@link applyFirstPathFill} (browser only)
|
|
537
|
+
* @returns Base64-encoded data URL (`data:image/svg+xml;base64,…`)
|
|
411
538
|
*/
|
|
412
539
|
declare function svgToBase64(svgString: string, firstPathFill?: string): string;
|
|
413
540
|
/**
|
|
@@ -421,14 +548,10 @@ declare function svgToBase64(svgString: string, firstPathFill?: string): string;
|
|
|
421
548
|
*
|
|
422
549
|
* @example
|
|
423
550
|
* ```ts
|
|
424
|
-
* formatIconNameForGithub
|
|
425
|
-
* // → "wallet-connect.svg"
|
|
426
|
-
*
|
|
427
|
-
* formatIconNameForGithub("MetaMask")
|
|
428
|
-
* // → "metamask.svg"
|
|
551
|
+
* import { formatIconNameForGithub } from '@tuwaio/nova-core';
|
|
429
552
|
*
|
|
430
|
-
* formatIconNameForGithub(
|
|
431
|
-
* // →
|
|
553
|
+
* formatIconNameForGithub('Wallet Connect'); // → 'wallet-connect.svg'
|
|
554
|
+
* formatIconNameForGithub('MetaMask'); // → 'metamask.svg'
|
|
432
555
|
* ```
|
|
433
556
|
*/
|
|
434
557
|
declare const formatIconNameForGithub: (name: string) => string;
|
|
@@ -453,4 +576,4 @@ declare const formatIconNameForGithub: (name: string) => string;
|
|
|
453
576
|
*/
|
|
454
577
|
declare function textCenterEllipsis(str: string | undefined | null, from: number, to: number): string;
|
|
455
578
|
|
|
456
|
-
export { type ChainInfo, ChevronArrowWithAnim, CloseIcon, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, FallbackIcon, type FallbackIconProps, GithubFallbackIcon, NetworkIcon, StarsBackground, SvgImg, type SvgImgProps, SvgToImg, ToastCloseButton, type ToastCloseButtonProps, WalletIcon, applyFirstPathFill, cn, deepMerge, formatIconNameForGithub, getChainName, isSolanaDev, isTouchDevice, resolveCssVariable, standardButtonClasses, svgToBase64, textCenterEllipsis, useCopyToClipboard, useMediaQuery };
|
|
579
|
+
export { type ChainInfo, ChevronArrowWithAnim, CloseIcon, type CopyToClipboardResult, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, FallbackIcon, type FallbackIconProps, GithubFallbackIcon, type GithubFallbackIconProps, NetworkIcon, type NetworkIconProps, StarsBackground, SvgImg, type SvgImgProps, SvgToImg, type SvgToImgProps, ToastCloseButton, type ToastCloseButtonProps, type UseCopyToClipboardResult, WalletIcon, type WalletIconProps, applyFirstPathFill, cn, deepMerge, formatIconNameForGithub, getChainName, isSolanaDev, isTouchDevice, resolveCssVariable, standardButtonClasses, svgToBase64, textCenterEllipsis, useCopyToClipboard, useMediaQuery };
|