@tuwaio/nova-connect 1.0.0-fix-test-alpha.55.f5b462c → 1.0.0-fix-test-alpha.56.a984de3

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.
@@ -1,8 +1,35 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ToastPosition } from 'react-toastify';
3
- import { ISatelliteConnectStore } from '@tuwaio/satellite-core';
2
+ import { ComponentPropsWithoutRef, ComponentType, ReactNode } from 'react';
3
+ import { ToastContainer, toast, ToastPosition } from 'react-toastify';
4
+ import { OrbitAdapter } from '@tuwaio/orbit-core';
5
+ import { ISatelliteConnectStore, BaseWallet } from '@tuwaio/satellite-core';
4
6
  import { StoreApi } from 'zustand/index';
5
- import { ReactNode } from 'react';
7
+
8
+ /**
9
+ * @description
10
+ * This interface is intentionally left empty.
11
+ * Other packages (@tuwaio/satellite-*) will use module
12
+ * augmentation to add their specific wallet types here.
13
+ */
14
+ interface AllWallets {
15
+ }
16
+ /**
17
+ * @description
18
+ * This interface is intentionally left empty.
19
+ * It will be augmented by satellite packages.
20
+ */
21
+ interface AllConnectors {
22
+ }
23
+ /**
24
+ * Union type for all supported wallet types.
25
+ * It's created from the values of the AllWallets interface.
26
+ * e.g., { evm: EVMWallet, solana: SolanaWallet } -> EVMWallet | SolanaWallet
27
+ */
28
+ type Wallet = AllWallets[keyof AllWallets];
29
+ /**
30
+ * Union type for all supported connector types.
31
+ */
32
+ type Connector = AllConnectors[keyof AllConnectors];
6
33
 
7
34
  /**
8
35
  * Type definitions for NovaConnect component translations
@@ -101,39 +128,217 @@ type NovaConnectLabels = {
101
128
  impersonateAddressConnected: string;
102
129
  };
103
130
 
104
- /**
105
- * @description
106
- * This interface is intentionally left empty.
107
- * Other packages (@tuwaio/satellite-*) will use module
108
- * augmentation to add their specific wallet types here.
109
- */
110
- interface AllWallets {
131
+ type ButtonTxStatus = 'idle' | 'loading' | 'succeed' | 'failed' | 'replaced';
132
+ type ConnectContentType = 'network' | 'connectors' | 'about' | 'getWallet' | 'connecting' | 'impersonate';
133
+ type ConnectedContentType = 'main' | 'transactions' | 'chains';
134
+ interface NovaConnectProviderProps$1 {
135
+ store: StoreApi<ISatelliteConnectStore<Connector, Wallet>>;
136
+ children: React.ReactNode;
137
+ labels?: Partial<NovaConnectLabels>;
111
138
  }
112
- /**
113
- * @description
114
- * This interface is intentionally left empty.
115
- * It will be augmented by satellite packages.
116
- */
117
- interface AllConnectors {
139
+ interface NovaConnectProviderType {
140
+ activeWallet: BaseWallet | undefined;
141
+ walletConnectionError: string | undefined;
142
+ isConnectModalOpen: boolean;
143
+ setIsConnectModalOpen: (value: boolean) => void;
144
+ isConnectedModalOpen: boolean;
145
+ setIsConnectedModalOpen: (value: boolean) => void;
146
+ isChainsListOpen: boolean;
147
+ setIsChainsListOpen: (value: boolean) => void;
148
+ isChainsListOpenMobile: boolean;
149
+ setIsChainsListOpenMobile: (value: boolean) => void;
150
+ connectedButtonStatus: ButtonTxStatus;
151
+ setConnectedButtonStatus: (value: ButtonTxStatus) => void;
152
+ isConnected: boolean;
153
+ setIsConnected: (value: boolean) => void;
154
+ connectedModalContentType: ConnectedContentType;
155
+ setConnectedModalContentType: (value: ConnectedContentType) => void;
156
+ connectModalContentType: ConnectContentType;
157
+ setConnectModalContentType: (value: ConnectContentType) => void;
158
+ selectedAdapter: OrbitAdapter | undefined;
159
+ setSelectedAdapter: (value: OrbitAdapter | undefined) => void;
160
+ activeConnector: string | undefined;
161
+ setActiveConnector: (value: string | undefined) => void;
162
+ impersonatedAddress: string;
163
+ setImpersonatedAddress: (value: string) => void;
118
164
  }
165
+
166
+ type CustomIconProps = {
167
+ isCopied: boolean;
168
+ className?: string;
169
+ style?: React.CSSProperties;
170
+ 'aria-hidden'?: boolean;
171
+ };
172
+ type CustomTitleProps = {
173
+ title: string;
174
+ titleId: string;
175
+ className?: string;
176
+ style?: React.CSSProperties;
177
+ };
178
+ type CustomDescriptionProps = {
179
+ rawError: string;
180
+ descriptionId: string;
181
+ className?: string;
182
+ style?: React.CSSProperties;
183
+ };
184
+ type CustomButtonContentProps = {
185
+ icon: ReactNode;
186
+ isCopied: boolean;
187
+ copyLabel: string;
188
+ copiedLabel: string;
189
+ };
119
190
  /**
120
- * Union type for all supported wallet types.
121
- * It's created from the values of the AllWallets interface.
122
- * e.g., { evm: EVMWallet, solana: SolanaWallet } -> EVMWallet | SolanaWallet
191
+ * Customization options for ToastError component
123
192
  */
124
- type Wallet = AllWallets[keyof AllWallets];
193
+ type ToastErrorCustomization = {
194
+ /** Override container element props */
195
+ containerProps?: Partial<ComponentPropsWithoutRef<'div'>>;
196
+ /** Override button element props */
197
+ buttonProps?: Partial<ComponentPropsWithoutRef<'button'>>;
198
+ /** Custom components */
199
+ components?: {
200
+ /** Custom icon component */
201
+ Icon?: ComponentType<CustomIconProps>;
202
+ /** Custom title component */
203
+ Title?: ComponentType<CustomTitleProps>;
204
+ /** Custom description component */
205
+ Description?: ComponentType<CustomDescriptionProps>;
206
+ /** Custom button content component */
207
+ ButtonContent?: ComponentType<CustomButtonContentProps>;
208
+ };
209
+ /** Custom class name generators */
210
+ classNames?: {
211
+ /** Function to generate container classes */
212
+ container?: (params: {
213
+ hasTitle: boolean;
214
+ hasError: boolean;
215
+ }) => string;
216
+ /** Function to generate title classes */
217
+ title?: (params: {
218
+ title: string;
219
+ }) => string;
220
+ /** Function to generate description classes */
221
+ description?: (params: {
222
+ rawError: string;
223
+ }) => string;
224
+ /** Function to generate button classes */
225
+ button?: (params: {
226
+ isCopied: boolean;
227
+ disabled: boolean;
228
+ }) => string;
229
+ /** Function to generate icon classes */
230
+ icon?: (params: {
231
+ isCopied: boolean;
232
+ }) => string;
233
+ };
234
+ /** Custom style generators */
235
+ styles?: {
236
+ /** Function to generate container styles */
237
+ container?: (params: {
238
+ hasTitle: boolean;
239
+ hasError: boolean;
240
+ }) => React.CSSProperties;
241
+ /** Function to generate title styles */
242
+ title?: (params: {
243
+ title: string;
244
+ }) => React.CSSProperties;
245
+ /** Function to generate description styles */
246
+ description?: (params: {
247
+ rawError: string;
248
+ }) => React.CSSProperties;
249
+ /** Function to generate button styles */
250
+ button?: (params: {
251
+ isCopied: boolean;
252
+ disabled: boolean;
253
+ }) => React.CSSProperties;
254
+ /** Function to generate icon styles */
255
+ icon?: (params: {
256
+ isCopied: boolean;
257
+ }) => React.CSSProperties;
258
+ };
259
+ /** Custom event handlers */
260
+ handlers?: {
261
+ /** Custom click handler wrapper */
262
+ onClick?: (originalHandler: (event: React.MouseEvent<HTMLButtonElement>) => void, event: React.MouseEvent<HTMLButtonElement>) => void;
263
+ /** Custom keydown handler wrapper */
264
+ onKeyDown?: (originalHandler: (event: React.KeyboardEvent<HTMLButtonElement>) => void, event: React.KeyboardEvent<HTMLButtonElement>) => void;
265
+ };
266
+ };
267
+
268
+ type CustomToastErrorProps = {
269
+ title: string;
270
+ rawError: string;
271
+ onCopyComplete?: (success: boolean) => void;
272
+ errorType: 'wallet' | 'switch' | null;
273
+ isConnected: boolean;
274
+ };
275
+ type CustomContainerProps = ComponentPropsWithoutRef<typeof ToastContainer>;
125
276
  /**
126
- * Union type for all supported connector types.
277
+ * Customization options for ErrorsProvider component
127
278
  */
128
- type Connector = AllConnectors[keyof AllConnectors];
129
-
130
- interface NovaConnectProviderProps {
131
- store: StoreApi<ISatelliteConnectStore<Connector, Wallet>>;
132
- children: React.ReactNode;
133
- labels?: Partial<NovaConnectLabels>;
134
- }
135
-
136
- interface ErrorsProviderProps extends Pick<NovaConnectProviderProps, 'store'> {
279
+ type ErrorsProviderCustomization = {
280
+ /** Override ToastContainer element props */
281
+ containerProps?: Partial<ComponentPropsWithoutRef<typeof ToastContainer>>;
282
+ /** Custom components */
283
+ components?: {
284
+ /** Custom ToastError component */
285
+ ToastError?: ComponentType<CustomToastErrorProps>;
286
+ /** Custom ToastContainer component */
287
+ Container?: ComponentType<CustomContainerProps>;
288
+ };
289
+ /** Default ToastError customization (only used with default ToastError component) */
290
+ toastErrorCustomization?: ToastErrorCustomization;
291
+ /** Custom class name generators */
292
+ classNames?: {
293
+ /** Function to generate container classes */
294
+ container?: (params: {
295
+ hasErrors: boolean;
296
+ errorType: 'wallet' | 'switch' | null;
297
+ }) => string;
298
+ };
299
+ /** Custom style generators */
300
+ styles?: {
301
+ /** Function to generate container styles */
302
+ container?: (params: {
303
+ hasErrors: boolean;
304
+ errorType: 'wallet' | 'switch' | null;
305
+ }) => React.CSSProperties;
306
+ };
307
+ /** Custom toast options generators */
308
+ toastOptions?: {
309
+ /** Function to generate toast options */
310
+ error?: (params: {
311
+ title: string;
312
+ rawError: string;
313
+ errorType: 'wallet' | 'switch' | null;
314
+ isConnected: boolean;
315
+ }) => Partial<Parameters<typeof toast.error>[1]>;
316
+ };
317
+ /** Custom logic handlers */
318
+ handlers?: {
319
+ /** Custom error display logic */
320
+ showError?: (originalHandler: (title: string, rawError: string, errorKey: string) => void, params: {
321
+ title: string;
322
+ rawError: string;
323
+ errorKey: string;
324
+ errorType: 'wallet' | 'switch' | null;
325
+ }) => void;
326
+ /** Custom error dismissal logic */
327
+ dismissError?: (originalHandler: () => void) => void;
328
+ /** Custom copy complete handler */
329
+ onCopyComplete?: (success: boolean, rawError: string, errorType: 'wallet' | 'switch' | null) => void;
330
+ };
331
+ /** Custom error title generator - does NOT customize labels, just allows title modification */
332
+ errorTitle?: (defaultTitle: string, params: {
333
+ errorType: 'wallet' | 'switch' | null;
334
+ }) => string;
335
+ /** Custom error hash generator for deduplication */
336
+ errorHash?: (defaultHash: string | null, params: {
337
+ primaryError: string | null;
338
+ errorType: 'wallet' | 'switch' | null;
339
+ }) => string | null;
340
+ };
341
+ interface ErrorsProviderProps extends Pick<NovaConnectProviderProps$1, 'store'> {
137
342
  /** Custom container ID for toast notifications */
138
343
  containerId?: string;
139
344
  /** Custom position for toast notifications */
@@ -142,8 +347,14 @@ interface ErrorsProviderProps extends Pick<NovaConnectProviderProps, 'store'> {
142
347
  autoClose?: number | false;
143
348
  /** Whether to enable drag to dismiss */
144
349
  draggable?: boolean;
350
+ /** Customization options */
351
+ customization?: ErrorsProviderCustomization;
145
352
  }
146
- declare function ErrorsProvider({ store, containerId, position, autoClose, draggable, }: ErrorsProviderProps): react_jsx_runtime.JSX.Element;
353
+ /**
354
+ * A highly customizable error toast provider with extensive styling options and component replacement capabilities.
355
+ * Provides comprehensive customization for appearance, behavior, and error handling logic while maintaining accessibility.
356
+ */
357
+ declare function ErrorsProvider({ store, containerId, position, autoClose, draggable, customization, }: ErrorsProviderProps): react_jsx_runtime.JSX.Element;
147
358
  declare namespace ErrorsProvider {
148
359
  var displayName: string;
149
360
  }
@@ -185,6 +396,149 @@ declare namespace NovaConnectLabelsProvider {
185
396
  var displayName: string;
186
397
  }
187
398
 
188
- declare function NovaConnectProvider({ labels, store, children }: NovaConnectProviderProps): react_jsx_runtime.JSX.Element;
399
+ /**
400
+ * Props for custom NovaConnectLabelsProvider component
401
+ */
402
+ type CustomLabelsProviderProps = {
403
+ labels?: Partial<NovaConnectLabels>;
404
+ children: ReactNode;
405
+ };
406
+ /**
407
+ * Props for custom ErrorsProvider component
408
+ */
409
+ type CustomErrorsProviderProps = Pick<ErrorsProviderProps, 'store'> & {
410
+ customization?: ErrorsProviderCustomization;
411
+ };
412
+ /**
413
+ * Context data passed to custom provider components
414
+ */
415
+ type ProviderContext = {
416
+ /** Current wallet connection state */
417
+ isConnected: boolean;
418
+ /** Active wallet instance */
419
+ activeWallet: BaseWallet | undefined;
420
+ /** Current wallet connection error */
421
+ walletConnectionError: string | undefined;
422
+ /** All modal and UI states */
423
+ modalStates: {
424
+ isConnectModalOpen: boolean;
425
+ isConnectedModalOpen: boolean;
426
+ isChainsListOpen: boolean;
427
+ isChainsListOpenMobile: boolean;
428
+ };
429
+ /** Current content types for modals */
430
+ contentTypes: {
431
+ connectModal: ConnectContentType;
432
+ connectedModal: ConnectedContentType;
433
+ };
434
+ /** Button and transaction statuses */
435
+ statuses: {
436
+ connectedButton: ButtonTxStatus;
437
+ };
438
+ };
439
+ /**
440
+ * Comprehensive customization options for NovaConnectProvider
441
+ */
442
+ type NovaConnectProviderCustomization = {
443
+ /** Custom components */
444
+ components?: {
445
+ /** Custom labels provider component */
446
+ LabelsProvider?: ComponentType<CustomLabelsProviderProps>;
447
+ /** Custom errors provider component */
448
+ ErrorsProvider?: ComponentType<CustomErrorsProviderProps>;
449
+ };
450
+ /** Labels customization and merging strategy */
451
+ labels?: {
452
+ /** Custom labels merging function */
453
+ merge?: (defaultLabels: NovaConnectLabels, userLabels: Partial<NovaConnectLabels>) => NovaConnectLabels;
454
+ /** Transform final merged labels before use */
455
+ transform?: (mergedLabels: NovaConnectLabels, context: ProviderContext) => NovaConnectLabels;
456
+ };
457
+ /** ErrorsProvider customization - passed through to ErrorsProvider */
458
+ errors?: ErrorsProviderCustomization;
459
+ /** Custom initialization logic */
460
+ initialization?: {
461
+ /** Custom logic after store subscription setup */
462
+ onStoreSubscribed?: (context: ProviderContext) => void;
463
+ /** Custom logic when connection state changes */
464
+ onConnectionStateChange?: (isConnected: boolean, activeWallet: BaseWallet | undefined, context: ProviderContext) => void;
465
+ /** Custom logic when error state changes */
466
+ onErrorStateChange?: (error: string | undefined, context: ProviderContext) => void;
467
+ };
468
+ /** Custom context value transformation */
469
+ contextValue?: {
470
+ /** Transform context value before providing to children */
471
+ transform?: (defaultValue: NovaConnectProviderType, context: ProviderContext) => NovaConnectProviderType;
472
+ };
473
+ /** Custom rendering logic */
474
+ rendering?: {
475
+ /** Custom provider tree structure */
476
+ providerTree?: (defaultTree: ReactNode, components: {
477
+ ErrorsProvider: ReactNode;
478
+ LabelsProvider: ReactNode;
479
+ MainContent: ReactNode;
480
+ }, context: ProviderContext) => ReactNode;
481
+ };
482
+ };
483
+ /**
484
+ * Extended props for NovaConnectProvider with full customization capabilities
485
+ */
486
+ interface NovaConnectProviderProps extends NovaConnectProviderProps$1 {
487
+ /** Comprehensive customization options for the provider and its sub-components */
488
+ customization?: NovaConnectProviderCustomization;
489
+ }
490
+ /**
491
+ * Main NovaConnect provider component with comprehensive customization capabilities.
492
+ *
493
+ * This provider manages wallet connection state, error handling, internationalization,
494
+ * and modal states while offering extensive customization options for all sub-components
495
+ * and behaviors.
496
+ *
497
+ * Features:
498
+ * - Complete wallet connection state management
499
+ * - Customizable error handling through ErrorsProvider
500
+ * - Flexible internationalization system
501
+ * - Modal and UI state coordination
502
+ * - Extensive customization API for all aspects
503
+ * - Custom component replacement capabilities
504
+ * - Advanced initialization and lifecycle hooks
505
+ *
506
+ * @example Basic usage
507
+ * ```tsx
508
+ * <NovaConnectProvider store={store}>
509
+ * <App />
510
+ * </NovaConnectProvider>
511
+ * ```
512
+ *
513
+ * @example With customization
514
+ * ```tsx
515
+ * <NovaConnectProvider
516
+ * store={store}
517
+ * labels={customLabels}
518
+ * customization={{
519
+ * errors: {
520
+ * position: 'bottom-right',
521
+ * autoClose: 5000,
522
+ * components: {
523
+ * ToastError: CustomToastError
524
+ * }
525
+ * },
526
+ * initialization: {
527
+ * onConnectionStateChange: (isConnected, wallet) => {
528
+ * console.log('Connection state:', isConnected, wallet);
529
+ * }
530
+ * }
531
+ * }}
532
+ * >
533
+ * <App />
534
+ * </NovaConnectProvider>
535
+ * ```
536
+ *
537
+ * @param props - Provider configuration and customization options
538
+ */
539
+ declare function NovaConnectProvider({ labels, store, children, customization }: NovaConnectProviderProps): react_jsx_runtime.JSX.Element;
540
+ declare namespace NovaConnectProvider {
541
+ var displayName: string;
542
+ }
189
543
 
190
- export { ErrorsProvider, NovaConnectLabelsProvider, NovaConnectProvider };
544
+ export { ErrorsProvider, type ErrorsProviderCustomization, type ErrorsProviderProps, NovaConnectLabelsProvider, NovaConnectProvider, type NovaConnectProviderCustomization, type NovaConnectProviderProps };