@d13co/use-wallet-ui-react 1.0.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/LICENSE +21 -0
- package/README.md +556 -0
- package/dist/cjs/index.cjs +233 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/esm/index.js +65176 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/style.css +1239 -0
- package/dist/types/index.d.cts +250 -0
- package/dist/types/index.d.ts +250 -0
- package/package.json +98 -0
- package/src/theme.css +108 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
import { default as default_3 } from 'algosdk';
|
|
3
|
+
import { JSX } from 'react/jsx-runtime';
|
|
4
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
5
|
+
import { ReactElement } from 'react';
|
|
6
|
+
import { ReactNode } from 'react';
|
|
7
|
+
import { RefObject } from 'react';
|
|
8
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
9
|
+
import { Wallet } from '@txnlab/use-wallet-react';
|
|
10
|
+
|
|
11
|
+
export declare type ButtonSize = 'sm' | 'md' | 'lg';
|
|
12
|
+
|
|
13
|
+
export declare const ConnectedWalletButton: default_2.ForwardRefExoticComponent<ConnectedWalletButtonProps & default_2.RefAttributes<HTMLButtonElement>>;
|
|
14
|
+
|
|
15
|
+
declare interface ConnectedWalletButtonProps extends default_2.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
16
|
+
/** Size variant for the button */
|
|
17
|
+
size?: ButtonSize;
|
|
18
|
+
style?: default_2.CSSProperties;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare function ConnectedWalletMenu(props: ConnectedWalletMenuProps): JSX.Element;
|
|
22
|
+
|
|
23
|
+
declare interface ConnectedWalletMenuProps {
|
|
24
|
+
children?: RefableElement_2;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare const ConnectWalletButton: default_2.ForwardRefExoticComponent<ConnectWalletButtonProps & default_2.RefAttributes<HTMLButtonElement>>;
|
|
28
|
+
|
|
29
|
+
declare interface ConnectWalletButtonProps extends default_2.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
30
|
+
/** Size variant for the button */
|
|
31
|
+
size?: ButtonSize;
|
|
32
|
+
style?: default_2.CSSProperties;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export declare function ConnectWalletMenu({ children }: ConnectWalletMenuProps): JSX.Element;
|
|
36
|
+
|
|
37
|
+
declare interface ConnectWalletMenuProps {
|
|
38
|
+
children?: RefableElement;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Component for displaying NFD avatar images with automatic IPFS handling
|
|
43
|
+
* - Handles IPFS URLs by converting them to HTTPS
|
|
44
|
+
* - Checks availability on images.nf.domains and falls back to IPFS gateway if needed
|
|
45
|
+
* - Caches results using TanStack Query
|
|
46
|
+
*/
|
|
47
|
+
export declare function NfdAvatar({ nfd, alt, className, size, fallback, lightOnly, }: NfdAvatarProps): JSX.Element;
|
|
48
|
+
|
|
49
|
+
declare interface NfdAvatarProps {
|
|
50
|
+
/** NFD record containing avatar data */
|
|
51
|
+
nfd: NfdRecord | null | undefined;
|
|
52
|
+
/** Optional alt text for the image (defaults to NFD name or 'NFD Avatar') */
|
|
53
|
+
alt?: string;
|
|
54
|
+
/** Optional className for styling the image */
|
|
55
|
+
className?: string;
|
|
56
|
+
/** Optional size in pixels (defaults to 40px) */
|
|
57
|
+
size?: number;
|
|
58
|
+
/** Optional fallback element to show when no avatar is available */
|
|
59
|
+
fallback?: default_2.ReactNode;
|
|
60
|
+
/** Optional flag to show light only avatar */
|
|
61
|
+
lightOnly?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export declare type NfdLookupResponse = {
|
|
65
|
+
[address: string]: NfdRecord | null;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export declare type NfdRecord = {
|
|
69
|
+
name: string;
|
|
70
|
+
properties: {
|
|
71
|
+
verified: {
|
|
72
|
+
[key: string]: string;
|
|
73
|
+
};
|
|
74
|
+
userDefined: {
|
|
75
|
+
[key: string]: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
image?: string;
|
|
79
|
+
avatar?: {
|
|
80
|
+
url?: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
declare type NfdView = 'tiny' | 'thumbnail' | 'brief' | 'full';
|
|
85
|
+
|
|
86
|
+
declare type RefableElement = ReactElement & {
|
|
87
|
+
ref?: RefObject<HTMLElement> | ((instance: HTMLElement | null) => void);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
declare type RefableElement_2 = ReactElement & {
|
|
91
|
+
ref?: RefObject<HTMLElement> | ((instance: HTMLElement | null) => void);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export declare type ResolvedTheme = 'light' | 'dark';
|
|
95
|
+
|
|
96
|
+
export declare type Theme = 'light' | 'dark' | 'system';
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Custom hook to fetch account information for Algorand address
|
|
100
|
+
*
|
|
101
|
+
* @param options.enabled Whether to enable the account lookup (defaults to true)
|
|
102
|
+
* @returns Account information query result
|
|
103
|
+
*/
|
|
104
|
+
export declare function useAccountInfo(options?: {
|
|
105
|
+
enabled?: boolean;
|
|
106
|
+
}): UseQueryResult<default_3.modelsv2.Account | null>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Hook that returns the `onAfterSign` callback for use in wallet uiHooks configuration.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```tsx
|
|
113
|
+
* const { onAfterSign } = useAfterSignDialog()
|
|
114
|
+
*
|
|
115
|
+
* // Pass to wallet config:
|
|
116
|
+
* uiHooks: { onAfterSign }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function useAfterSignDialog(): {
|
|
120
|
+
onAfterSign: (success: boolean, errorMessage?: string) => void;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Hook that returns the `onBeforeSign` callback for use in wallet uiHooks configuration.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```tsx
|
|
128
|
+
* const { onBeforeSign } = useBeforeSignDialog()
|
|
129
|
+
*
|
|
130
|
+
* // Pass to wallet config:
|
|
131
|
+
* uiHooks: { onBeforeSign }
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function useBeforeSignDialog(): {
|
|
135
|
+
onBeforeSign: (txnGroup: default_3.Transaction[] | Uint8Array[], indexesToSign?: number[]) => Promise<void>;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Custom hook to fetch NFD data for an Algorand address
|
|
140
|
+
*
|
|
141
|
+
* @param options.enabled Whether to enable the NFD lookup (defaults to true)
|
|
142
|
+
* @param options.view The view type for the NFD lookup ('tiny', 'thumbnail', 'brief', 'full') (defaults to 'thumbnail')
|
|
143
|
+
* @returns NFD data query result
|
|
144
|
+
*/
|
|
145
|
+
export declare function useNfd(options?: {
|
|
146
|
+
enabled?: boolean;
|
|
147
|
+
view?: NfdView;
|
|
148
|
+
}): UseQueryResult<NfdRecord | null>;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Hook to resolve the actual theme value, handling 'system' preference detection.
|
|
152
|
+
* When theme is 'system', it listens to the user's OS/browser color scheme preference.
|
|
153
|
+
*
|
|
154
|
+
* @param theme - The theme setting: 'light', 'dark', or 'system'
|
|
155
|
+
* @returns The resolved theme: 'light' or 'dark'
|
|
156
|
+
*/
|
|
157
|
+
export declare function useResolvedTheme(theme: Theme): ResolvedTheme;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Hook to access the WalletUI context
|
|
161
|
+
* @throws Error if used outside of WalletUIProvider
|
|
162
|
+
*/
|
|
163
|
+
export declare function useWalletUI(): WalletUIContextType;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Hook that returns the `showWelcome` callback for displaying a welcome dialog.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```tsx
|
|
170
|
+
* const { showWelcome } = useWelcomeDialog()
|
|
171
|
+
*
|
|
172
|
+
* // Show welcome dialog for a new account:
|
|
173
|
+
* showWelcome({ algorandAddress: '...', evmAddress: '...' })
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export declare function useWelcomeDialog(): {
|
|
177
|
+
showWelcome: (account: WelcomeAccount) => void;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export declare function WalletButton({ size, className, style }: WalletButtonProps): JSX.Element;
|
|
181
|
+
|
|
182
|
+
declare interface WalletButtonProps {
|
|
183
|
+
/** Size variant for the button */
|
|
184
|
+
size?: ButtonSize;
|
|
185
|
+
/** Additional CSS classes to apply to the button */
|
|
186
|
+
className?: string;
|
|
187
|
+
/** Inline styles to apply to the button (can include CSS variable overrides) */
|
|
188
|
+
style?: default_2.CSSProperties;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export declare function WalletList({ wallets, handleWalletClick }: WalletListProps): JSX.Element;
|
|
192
|
+
|
|
193
|
+
declare interface WalletListProps {
|
|
194
|
+
wallets: Wallet[];
|
|
195
|
+
handleWalletClick: (wallet: Wallet) => Promise<void>;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
declare interface WalletUIContextType {
|
|
199
|
+
queryClient: QueryClient;
|
|
200
|
+
theme: Theme;
|
|
201
|
+
resolvedTheme: ResolvedTheme;
|
|
202
|
+
requestBeforeSign: (txnGroup: default_3.Transaction[] | Uint8Array[], indexesToSign?: number[]) => Promise<void>;
|
|
203
|
+
requestAfterSign: (success: boolean, errorMessage?: string) => void;
|
|
204
|
+
requestWelcome: (account: WelcomeAccount) => void;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Provider that enables wallet UI components to work with TanStack Query.
|
|
209
|
+
* It can use an existing QueryClient from the parent application or create its own.
|
|
210
|
+
* Also creates a QueryClientProvider if none exists in the parent tree.
|
|
211
|
+
*
|
|
212
|
+
* Automatically prefetches data for all accounts in connected wallets for smoother
|
|
213
|
+
* account switching experience.
|
|
214
|
+
*
|
|
215
|
+
* Supports theme configuration via the `theme` prop:
|
|
216
|
+
* - 'light': Always use light mode
|
|
217
|
+
* - 'dark': Always use dark mode
|
|
218
|
+
* - 'system': Follow the user's OS/browser preference (default)
|
|
219
|
+
*/
|
|
220
|
+
export declare function WalletUIProvider({ children, queryClient: externalQueryClient, enablePrefetching, prefetchNfdView, theme, }: WalletUIProviderProps): JSX.Element;
|
|
221
|
+
|
|
222
|
+
declare interface WalletUIProviderProps {
|
|
223
|
+
children: ReactNode;
|
|
224
|
+
queryClient?: QueryClient;
|
|
225
|
+
/**
|
|
226
|
+
* Whether to automatically prefetch data for all accounts in connected wallets (defaults to true)
|
|
227
|
+
*/
|
|
228
|
+
enablePrefetching?: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* NFD view type for prefetching (defaults to 'thumbnail')
|
|
231
|
+
*/
|
|
232
|
+
prefetchNfdView?: NfdView;
|
|
233
|
+
/**
|
|
234
|
+
* Theme setting for wallet UI components.
|
|
235
|
+
* - 'light': Always use light mode
|
|
236
|
+
* - 'dark': Always use dark mode
|
|
237
|
+
* - 'system': Follow the user's OS/browser preference (default)
|
|
238
|
+
*
|
|
239
|
+
* The library also respects the `.dark` class on ancestor elements (Tailwind convention),
|
|
240
|
+
* which will enable dark mode unless explicitly overridden with theme="light".
|
|
241
|
+
*/
|
|
242
|
+
theme?: Theme;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
declare interface WelcomeAccount {
|
|
246
|
+
algorandAddress: string;
|
|
247
|
+
evmAddress: string;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export { }
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
import { default as default_3 } from 'algosdk';
|
|
3
|
+
import { JSX } from 'react/jsx-runtime';
|
|
4
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
5
|
+
import { ReactElement } from 'react';
|
|
6
|
+
import { ReactNode } from 'react';
|
|
7
|
+
import { RefObject } from 'react';
|
|
8
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
9
|
+
import { Wallet } from '@txnlab/use-wallet-react';
|
|
10
|
+
|
|
11
|
+
export declare type ButtonSize = 'sm' | 'md' | 'lg';
|
|
12
|
+
|
|
13
|
+
export declare const ConnectedWalletButton: default_2.ForwardRefExoticComponent<ConnectedWalletButtonProps & default_2.RefAttributes<HTMLButtonElement>>;
|
|
14
|
+
|
|
15
|
+
declare interface ConnectedWalletButtonProps extends default_2.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
16
|
+
/** Size variant for the button */
|
|
17
|
+
size?: ButtonSize;
|
|
18
|
+
style?: default_2.CSSProperties;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare function ConnectedWalletMenu(props: ConnectedWalletMenuProps): JSX.Element;
|
|
22
|
+
|
|
23
|
+
declare interface ConnectedWalletMenuProps {
|
|
24
|
+
children?: RefableElement_2;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare const ConnectWalletButton: default_2.ForwardRefExoticComponent<ConnectWalletButtonProps & default_2.RefAttributes<HTMLButtonElement>>;
|
|
28
|
+
|
|
29
|
+
declare interface ConnectWalletButtonProps extends default_2.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
30
|
+
/** Size variant for the button */
|
|
31
|
+
size?: ButtonSize;
|
|
32
|
+
style?: default_2.CSSProperties;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export declare function ConnectWalletMenu({ children }: ConnectWalletMenuProps): JSX.Element;
|
|
36
|
+
|
|
37
|
+
declare interface ConnectWalletMenuProps {
|
|
38
|
+
children?: RefableElement;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Component for displaying NFD avatar images with automatic IPFS handling
|
|
43
|
+
* - Handles IPFS URLs by converting them to HTTPS
|
|
44
|
+
* - Checks availability on images.nf.domains and falls back to IPFS gateway if needed
|
|
45
|
+
* - Caches results using TanStack Query
|
|
46
|
+
*/
|
|
47
|
+
export declare function NfdAvatar({ nfd, alt, className, size, fallback, lightOnly, }: NfdAvatarProps): JSX.Element;
|
|
48
|
+
|
|
49
|
+
declare interface NfdAvatarProps {
|
|
50
|
+
/** NFD record containing avatar data */
|
|
51
|
+
nfd: NfdRecord | null | undefined;
|
|
52
|
+
/** Optional alt text for the image (defaults to NFD name or 'NFD Avatar') */
|
|
53
|
+
alt?: string;
|
|
54
|
+
/** Optional className for styling the image */
|
|
55
|
+
className?: string;
|
|
56
|
+
/** Optional size in pixels (defaults to 40px) */
|
|
57
|
+
size?: number;
|
|
58
|
+
/** Optional fallback element to show when no avatar is available */
|
|
59
|
+
fallback?: default_2.ReactNode;
|
|
60
|
+
/** Optional flag to show light only avatar */
|
|
61
|
+
lightOnly?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export declare type NfdLookupResponse = {
|
|
65
|
+
[address: string]: NfdRecord | null;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export declare type NfdRecord = {
|
|
69
|
+
name: string;
|
|
70
|
+
properties: {
|
|
71
|
+
verified: {
|
|
72
|
+
[key: string]: string;
|
|
73
|
+
};
|
|
74
|
+
userDefined: {
|
|
75
|
+
[key: string]: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
image?: string;
|
|
79
|
+
avatar?: {
|
|
80
|
+
url?: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
declare type NfdView = 'tiny' | 'thumbnail' | 'brief' | 'full';
|
|
85
|
+
|
|
86
|
+
declare type RefableElement = ReactElement & {
|
|
87
|
+
ref?: RefObject<HTMLElement> | ((instance: HTMLElement | null) => void);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
declare type RefableElement_2 = ReactElement & {
|
|
91
|
+
ref?: RefObject<HTMLElement> | ((instance: HTMLElement | null) => void);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export declare type ResolvedTheme = 'light' | 'dark';
|
|
95
|
+
|
|
96
|
+
export declare type Theme = 'light' | 'dark' | 'system';
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Custom hook to fetch account information for Algorand address
|
|
100
|
+
*
|
|
101
|
+
* @param options.enabled Whether to enable the account lookup (defaults to true)
|
|
102
|
+
* @returns Account information query result
|
|
103
|
+
*/
|
|
104
|
+
export declare function useAccountInfo(options?: {
|
|
105
|
+
enabled?: boolean;
|
|
106
|
+
}): UseQueryResult<default_3.modelsv2.Account | null>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Hook that returns the `onAfterSign` callback for use in wallet uiHooks configuration.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```tsx
|
|
113
|
+
* const { onAfterSign } = useAfterSignDialog()
|
|
114
|
+
*
|
|
115
|
+
* // Pass to wallet config:
|
|
116
|
+
* uiHooks: { onAfterSign }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function useAfterSignDialog(): {
|
|
120
|
+
onAfterSign: (success: boolean, errorMessage?: string) => void;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Hook that returns the `onBeforeSign` callback for use in wallet uiHooks configuration.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```tsx
|
|
128
|
+
* const { onBeforeSign } = useBeforeSignDialog()
|
|
129
|
+
*
|
|
130
|
+
* // Pass to wallet config:
|
|
131
|
+
* uiHooks: { onBeforeSign }
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function useBeforeSignDialog(): {
|
|
135
|
+
onBeforeSign: (txnGroup: default_3.Transaction[] | Uint8Array[], indexesToSign?: number[]) => Promise<void>;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Custom hook to fetch NFD data for an Algorand address
|
|
140
|
+
*
|
|
141
|
+
* @param options.enabled Whether to enable the NFD lookup (defaults to true)
|
|
142
|
+
* @param options.view The view type for the NFD lookup ('tiny', 'thumbnail', 'brief', 'full') (defaults to 'thumbnail')
|
|
143
|
+
* @returns NFD data query result
|
|
144
|
+
*/
|
|
145
|
+
export declare function useNfd(options?: {
|
|
146
|
+
enabled?: boolean;
|
|
147
|
+
view?: NfdView;
|
|
148
|
+
}): UseQueryResult<NfdRecord | null>;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Hook to resolve the actual theme value, handling 'system' preference detection.
|
|
152
|
+
* When theme is 'system', it listens to the user's OS/browser color scheme preference.
|
|
153
|
+
*
|
|
154
|
+
* @param theme - The theme setting: 'light', 'dark', or 'system'
|
|
155
|
+
* @returns The resolved theme: 'light' or 'dark'
|
|
156
|
+
*/
|
|
157
|
+
export declare function useResolvedTheme(theme: Theme): ResolvedTheme;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Hook to access the WalletUI context
|
|
161
|
+
* @throws Error if used outside of WalletUIProvider
|
|
162
|
+
*/
|
|
163
|
+
export declare function useWalletUI(): WalletUIContextType;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Hook that returns the `showWelcome` callback for displaying a welcome dialog.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```tsx
|
|
170
|
+
* const { showWelcome } = useWelcomeDialog()
|
|
171
|
+
*
|
|
172
|
+
* // Show welcome dialog for a new account:
|
|
173
|
+
* showWelcome({ algorandAddress: '...', evmAddress: '...' })
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export declare function useWelcomeDialog(): {
|
|
177
|
+
showWelcome: (account: WelcomeAccount) => void;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export declare function WalletButton({ size, className, style }: WalletButtonProps): JSX.Element;
|
|
181
|
+
|
|
182
|
+
declare interface WalletButtonProps {
|
|
183
|
+
/** Size variant for the button */
|
|
184
|
+
size?: ButtonSize;
|
|
185
|
+
/** Additional CSS classes to apply to the button */
|
|
186
|
+
className?: string;
|
|
187
|
+
/** Inline styles to apply to the button (can include CSS variable overrides) */
|
|
188
|
+
style?: default_2.CSSProperties;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export declare function WalletList({ wallets, handleWalletClick }: WalletListProps): JSX.Element;
|
|
192
|
+
|
|
193
|
+
declare interface WalletListProps {
|
|
194
|
+
wallets: Wallet[];
|
|
195
|
+
handleWalletClick: (wallet: Wallet) => Promise<void>;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
declare interface WalletUIContextType {
|
|
199
|
+
queryClient: QueryClient;
|
|
200
|
+
theme: Theme;
|
|
201
|
+
resolvedTheme: ResolvedTheme;
|
|
202
|
+
requestBeforeSign: (txnGroup: default_3.Transaction[] | Uint8Array[], indexesToSign?: number[]) => Promise<void>;
|
|
203
|
+
requestAfterSign: (success: boolean, errorMessage?: string) => void;
|
|
204
|
+
requestWelcome: (account: WelcomeAccount) => void;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Provider that enables wallet UI components to work with TanStack Query.
|
|
209
|
+
* It can use an existing QueryClient from the parent application or create its own.
|
|
210
|
+
* Also creates a QueryClientProvider if none exists in the parent tree.
|
|
211
|
+
*
|
|
212
|
+
* Automatically prefetches data for all accounts in connected wallets for smoother
|
|
213
|
+
* account switching experience.
|
|
214
|
+
*
|
|
215
|
+
* Supports theme configuration via the `theme` prop:
|
|
216
|
+
* - 'light': Always use light mode
|
|
217
|
+
* - 'dark': Always use dark mode
|
|
218
|
+
* - 'system': Follow the user's OS/browser preference (default)
|
|
219
|
+
*/
|
|
220
|
+
export declare function WalletUIProvider({ children, queryClient: externalQueryClient, enablePrefetching, prefetchNfdView, theme, }: WalletUIProviderProps): JSX.Element;
|
|
221
|
+
|
|
222
|
+
declare interface WalletUIProviderProps {
|
|
223
|
+
children: ReactNode;
|
|
224
|
+
queryClient?: QueryClient;
|
|
225
|
+
/**
|
|
226
|
+
* Whether to automatically prefetch data for all accounts in connected wallets (defaults to true)
|
|
227
|
+
*/
|
|
228
|
+
enablePrefetching?: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* NFD view type for prefetching (defaults to 'thumbnail')
|
|
231
|
+
*/
|
|
232
|
+
prefetchNfdView?: NfdView;
|
|
233
|
+
/**
|
|
234
|
+
* Theme setting for wallet UI components.
|
|
235
|
+
* - 'light': Always use light mode
|
|
236
|
+
* - 'dark': Always use dark mode
|
|
237
|
+
* - 'system': Follow the user's OS/browser preference (default)
|
|
238
|
+
*
|
|
239
|
+
* The library also respects the `.dark` class on ancestor elements (Tailwind convention),
|
|
240
|
+
* which will enable dark mode unless explicitly overridden with theme="light".
|
|
241
|
+
*/
|
|
242
|
+
theme?: Theme;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
declare interface WelcomeAccount {
|
|
246
|
+
algorandAddress: string;
|
|
247
|
+
evmAddress: string;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export { }
|
package/package.json
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@d13co/use-wallet-ui-react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "React components for use-wallet UI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/cjs/index.cjs",
|
|
7
|
+
"module": "dist/esm/index.js",
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/types/index.d.ts",
|
|
13
|
+
"default": "./dist/esm/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/types/index.d.cts",
|
|
17
|
+
"default": "./dist/cjs/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"./dist/style.css": "./dist/style.css",
|
|
21
|
+
"./theme.css": "./src/theme.css",
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"src/theme.css",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"keywords": [
|
|
30
|
+
"algorand",
|
|
31
|
+
"wallet",
|
|
32
|
+
"use-wallet",
|
|
33
|
+
"react",
|
|
34
|
+
"vue",
|
|
35
|
+
"solid",
|
|
36
|
+
"ui"
|
|
37
|
+
],
|
|
38
|
+
"author": "TxnLab Inc.",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/TxnLab/use-wallet-ui.git"
|
|
43
|
+
},
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/TxnLab/use-wallet-ui/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/TxnLab/use-wallet-ui#readme",
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=22",
|
|
53
|
+
"pnpm": ">=9"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@d13co/use-wallet-react": "^4.0.1",
|
|
57
|
+
"liquid-accounts-evm": ">=0.0.1",
|
|
58
|
+
"react": "^18 || ^19",
|
|
59
|
+
"react-dom": "^18 || ^19",
|
|
60
|
+
"@d13co/liquid-ui": "0.0.1"
|
|
61
|
+
},
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"@floating-ui/react": "0.27.17",
|
|
64
|
+
"@headlessui/react": "2.2.9",
|
|
65
|
+
"@tanstack/react-query": "5.90.21",
|
|
66
|
+
"@txnlab/utils-ts": "0.1.0",
|
|
67
|
+
"clsx": "2.1.1",
|
|
68
|
+
"tailwind-merge": "3.4.1"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"liquid-accounts-evm": "link:../../../evm-sdk",
|
|
72
|
+
"@tailwindcss/cli": "4.1.18",
|
|
73
|
+
"@types/react": "19.2.14",
|
|
74
|
+
"@types/react-dom": "19.2.3",
|
|
75
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
76
|
+
"algosdk": "3.5.2",
|
|
77
|
+
"publint": "0.3.17",
|
|
78
|
+
"react": "19.2.4",
|
|
79
|
+
"react-dom": "19.2.4",
|
|
80
|
+
"tailwindcss": "4.1.18",
|
|
81
|
+
"tsx": "4.21.0",
|
|
82
|
+
"vite": "6.4.1",
|
|
83
|
+
"vite-plugin-dts": "4.5.4",
|
|
84
|
+
"vite-tsconfig-paths": "5.1.4",
|
|
85
|
+
"vitest": "3.2.4"
|
|
86
|
+
},
|
|
87
|
+
"scripts": {
|
|
88
|
+
"build": "pnpm generate:css && vite build && publint --strict",
|
|
89
|
+
"dev": "vite build --watch",
|
|
90
|
+
"test": "vitest run",
|
|
91
|
+
"test:watch": "vitest",
|
|
92
|
+
"test:coverage": "vitest run --coverage",
|
|
93
|
+
"lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
|
|
94
|
+
"format": "prettier --write .",
|
|
95
|
+
"typecheck": "tsc --noEmit",
|
|
96
|
+
"generate:css": "npx @tailwindcss/cli -c ./tailwind.config.js -i ./src/input.css -o ./dist/style.css && node ./scripts/post-process-css.js"
|
|
97
|
+
}
|
|
98
|
+
}
|
package/src/theme.css
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Theme CSS custom properties for wallet UI components
|
|
3
|
+
Import this file in Tailwind projects to enable theming
|
|
4
|
+
|
|
5
|
+
Uses @layer wui-theme so consumer CSS can easily override values.
|
|
6
|
+
Consumer CSS (unlayered) automatically beats layered styles.
|
|
7
|
+
|
|
8
|
+
Example override:
|
|
9
|
+
[data-wallet-theme] {
|
|
10
|
+
--wui-color-primary: #8b5cf6;
|
|
11
|
+
}
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
@layer wui-theme {
|
|
15
|
+
/* Light mode (default) */
|
|
16
|
+
[data-wallet-theme] {
|
|
17
|
+
--wui-color-primary: #2d2df1;
|
|
18
|
+
--wui-color-primary-hover: #2929d9;
|
|
19
|
+
--wui-color-primary-text: #ffffff;
|
|
20
|
+
--wui-color-bg: #ffffff;
|
|
21
|
+
--wui-color-bg-secondary: #f9fafb;
|
|
22
|
+
--wui-color-bg-tertiary: #f3f4f6;
|
|
23
|
+
--wui-color-bg-hover: #e9e9fd;
|
|
24
|
+
--wui-color-text: #1f2937;
|
|
25
|
+
--wui-color-text-secondary: #6b7280;
|
|
26
|
+
--wui-color-text-tertiary: #9ca3af;
|
|
27
|
+
--wui-color-border: #e5e7eb;
|
|
28
|
+
--wui-color-link: rgba(45, 45, 241, 0.8);
|
|
29
|
+
--wui-color-link-hover: #2d2df1;
|
|
30
|
+
--wui-color-overlay: rgba(0, 0, 0, 0.3);
|
|
31
|
+
--wui-color-danger-bg: #fee2e2;
|
|
32
|
+
--wui-color-danger-bg-hover: #fecaca;
|
|
33
|
+
--wui-color-danger-text: #b91c1c;
|
|
34
|
+
--wui-color-avatar-bg: #e5e7eb;
|
|
35
|
+
--wui-color-avatar-icon: #9ca3af;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Dark mode via data-theme attribute (explicit) */
|
|
39
|
+
[data-wallet-theme][data-theme='dark'] {
|
|
40
|
+
--wui-color-primary: #bfbff9;
|
|
41
|
+
--wui-color-primary-hover: #d4d4fa;
|
|
42
|
+
--wui-color-primary-text: #001324;
|
|
43
|
+
--wui-color-bg: #001324;
|
|
44
|
+
--wui-color-bg-secondary: #101b29;
|
|
45
|
+
--wui-color-bg-tertiary: #192a39;
|
|
46
|
+
--wui-color-bg-hover: #192a39;
|
|
47
|
+
--wui-color-text: #e9e9fd;
|
|
48
|
+
--wui-color-text-secondary: #99a1a7;
|
|
49
|
+
--wui-color-text-tertiary: #6b7280;
|
|
50
|
+
--wui-color-border: #192a39;
|
|
51
|
+
--wui-color-link: #6c6cf1;
|
|
52
|
+
--wui-color-link-hover: #8080f3;
|
|
53
|
+
--wui-color-overlay: rgba(0, 0, 0, 0.5);
|
|
54
|
+
--wui-color-danger-bg: rgba(127, 29, 29, 0.4);
|
|
55
|
+
--wui-color-danger-bg-hover: rgba(127, 29, 29, 0.6);
|
|
56
|
+
--wui-color-danger-text: #fca5a5;
|
|
57
|
+
--wui-color-avatar-bg: #192a39;
|
|
58
|
+
--wui-color-avatar-icon: #6b7280;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Dark mode via .dark class on ancestor (Tailwind convention) */
|
|
62
|
+
.dark [data-wallet-theme]:not([data-theme='light']) {
|
|
63
|
+
--wui-color-primary: #bfbff9;
|
|
64
|
+
--wui-color-primary-hover: #d4d4fa;
|
|
65
|
+
--wui-color-primary-text: #001324;
|
|
66
|
+
--wui-color-bg: #001324;
|
|
67
|
+
--wui-color-bg-secondary: #101b29;
|
|
68
|
+
--wui-color-bg-tertiary: #192a39;
|
|
69
|
+
--wui-color-bg-hover: #192a39;
|
|
70
|
+
--wui-color-text: #e9e9fd;
|
|
71
|
+
--wui-color-text-secondary: #99a1a7;
|
|
72
|
+
--wui-color-text-tertiary: #6b7280;
|
|
73
|
+
--wui-color-border: #192a39;
|
|
74
|
+
--wui-color-link: #6c6cf1;
|
|
75
|
+
--wui-color-link-hover: #8080f3;
|
|
76
|
+
--wui-color-overlay: rgba(0, 0, 0, 0.5);
|
|
77
|
+
--wui-color-danger-bg: rgba(127, 29, 29, 0.4);
|
|
78
|
+
--wui-color-danger-bg-hover: rgba(127, 29, 29, 0.6);
|
|
79
|
+
--wui-color-danger-text: #fca5a5;
|
|
80
|
+
--wui-color-avatar-bg: #192a39;
|
|
81
|
+
--wui-color-avatar-icon: #6b7280;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Dark mode via system preference (when theme="system" or no explicit theme) */
|
|
85
|
+
@media (prefers-color-scheme: dark) {
|
|
86
|
+
[data-wallet-theme]:not([data-theme='light']):not([data-theme='dark']) {
|
|
87
|
+
--wui-color-primary: #bfbff9;
|
|
88
|
+
--wui-color-primary-hover: #d4d4fa;
|
|
89
|
+
--wui-color-primary-text: #001324;
|
|
90
|
+
--wui-color-bg: #001324;
|
|
91
|
+
--wui-color-bg-secondary: #101b29;
|
|
92
|
+
--wui-color-bg-tertiary: #192a39;
|
|
93
|
+
--wui-color-bg-hover: #192a39;
|
|
94
|
+
--wui-color-text: #e9e9fd;
|
|
95
|
+
--wui-color-text-secondary: #99a1a7;
|
|
96
|
+
--wui-color-text-tertiary: #6b7280;
|
|
97
|
+
--wui-color-border: #192a39;
|
|
98
|
+
--wui-color-link: #6c6cf1;
|
|
99
|
+
--wui-color-link-hover: #8080f3;
|
|
100
|
+
--wui-color-overlay: rgba(0, 0, 0, 0.5);
|
|
101
|
+
--wui-color-danger-bg: rgba(127, 29, 29, 0.4);
|
|
102
|
+
--wui-color-danger-bg-hover: rgba(127, 29, 29, 0.6);
|
|
103
|
+
--wui-color-danger-text: #fca5a5;
|
|
104
|
+
--wui-color-avatar-bg: #192a39;
|
|
105
|
+
--wui-color-avatar-icon: #6b7280;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|