@taskon/widget-react 0.0.1-beta.6 → 0.0.1-beta.7

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.
Files changed (32) hide show
  1. package/README.md +48 -43
  2. package/dist/EligibilityInfo.css +2 -33
  3. package/dist/TaskOnProvider.css +287 -0
  4. package/dist/ThemeProvider.css +227 -0
  5. package/dist/UserCenterWidget2.css +32 -290
  6. package/dist/WidgetShell.css +0 -227
  7. package/dist/chunks/{CommunityTaskList-Hde2OKHH.js → CommunityTaskList-D0uVD8wD.js} +37 -58
  8. package/dist/chunks/{EligibilityInfo-BV0Z2TgY.js → EligibilityInfo-Cf6hx9-a.js} +17 -209
  9. package/dist/chunks/{LeaderboardWidget-BNGRD5Bu.js → LeaderboardWidget-DyoiiNS6.js} +10 -9
  10. package/dist/chunks/{PageBuilder-C5DSHiW9.js → PageBuilder-DoAFPm6-.js} +5 -5
  11. package/dist/chunks/{Quest-DG9zfXJo.js → Quest-ySZlYd4u.js} +6 -11
  12. package/dist/chunks/TaskOnProvider-CxtFIs3n.js +2072 -0
  13. package/dist/chunks/{WidgetShell-D7yC894Y.js → ThemeProvider-CulHkqqY.js} +1354 -617
  14. package/dist/chunks/UserCenterWidget-BJsc_GSZ.js +3246 -0
  15. package/dist/chunks/{UserCenterWidget-D5ttw4hO.js → UserCenterWidget-STq8kpV4.js} +162 -365
  16. package/dist/chunks/WidgetShell-8xn-Jivw.js +659 -0
  17. package/dist/chunks/useIsMobile-D6Ybur-6.js +30 -0
  18. package/dist/chunks/useToast-BGJhd3BX.js +93 -0
  19. package/dist/community-task.js +1 -1
  20. package/dist/core.d.ts +9 -15
  21. package/dist/core.js +3 -3
  22. package/dist/index.d.ts +64 -15
  23. package/dist/index.js +15 -10
  24. package/dist/leaderboard.js +1 -1
  25. package/dist/page-builder.js +1 -1
  26. package/dist/quest.js +1 -1
  27. package/dist/user-center.js +1 -1
  28. package/package.json +1 -1
  29. package/dist/chunks/TaskOnProvider-BhamHIyY.js +0 -1260
  30. package/dist/chunks/ThemeProvider-mXLdLSkq.js +0 -1397
  31. package/dist/chunks/UserCenterWidget-jDO5zTN1.js +0 -3297
  32. package/dist/chunks/useToast-CaRkylKe.js +0 -304
@@ -0,0 +1,93 @@
1
+ import { useContext, createContext, useMemo, useState, useCallback } from "react";
2
+ const defaultWalletContext = {
3
+ // EVM state
4
+ evmAdapter: null,
5
+ evmAddress: null,
6
+ evmChainId: null,
7
+ isEvmConnected: false,
8
+ // Detection status
9
+ isDetecting: true,
10
+ // Actions (no-op by default)
11
+ connectEvm: async () => null,
12
+ disconnectEvm: async () => {
13
+ },
14
+ signEvmMessage: async () => null
15
+ };
16
+ const WalletContext = createContext(defaultWalletContext);
17
+ function useWallet() {
18
+ const context = useContext(WalletContext);
19
+ return context;
20
+ }
21
+ function useEvmWallet() {
22
+ const context = useWallet();
23
+ return useMemo(
24
+ () => ({
25
+ adapter: context.evmAdapter,
26
+ address: context.evmAddress,
27
+ chainId: context.evmChainId,
28
+ isConnected: context.isEvmConnected,
29
+ connect: context.connectEvm,
30
+ disconnect: context.disconnectEvm,
31
+ signMessage: context.signEvmMessage
32
+ }),
33
+ [
34
+ context.evmAdapter,
35
+ context.evmAddress,
36
+ context.evmChainId,
37
+ context.isEvmConnected,
38
+ context.connectEvm,
39
+ context.disconnectEvm,
40
+ context.signEvmMessage
41
+ ]
42
+ );
43
+ }
44
+ const ToastContext = createContext(null);
45
+ function useToast() {
46
+ const context = useContext(ToastContext);
47
+ if (!context) {
48
+ throw new Error("useToast must be used within TaskOnProvider");
49
+ }
50
+ return context;
51
+ }
52
+ let toastId = 0;
53
+ function generateId() {
54
+ return `toast-${++toastId}-${Date.now()}`;
55
+ }
56
+ function useToastState() {
57
+ const [toasts, setToasts] = useState([]);
58
+ const showToast = useCallback(
59
+ (message, type = "info", duration) => {
60
+ const newToast = {
61
+ id: generateId(),
62
+ message,
63
+ type,
64
+ duration
65
+ };
66
+ setToasts((prev) => [...prev, newToast]);
67
+ },
68
+ []
69
+ );
70
+ const removeToast = useCallback((id) => {
71
+ setToasts((prev) => prev.filter((t) => t.id !== id));
72
+ }, []);
73
+ const toast = {
74
+ success: (message, duration) => showToast(message, "success", duration),
75
+ error: (message, duration) => showToast(message, "error", duration),
76
+ warning: (message, duration) => showToast(message, "warning", duration),
77
+ info: (message, duration) => showToast(message, "info", duration)
78
+ };
79
+ return {
80
+ toasts,
81
+ showToast,
82
+ removeToast,
83
+ toast
84
+ };
85
+ }
86
+ export {
87
+ ToastContext as T,
88
+ WalletContext as W,
89
+ useEvmWallet as a,
90
+ useToastState as b,
91
+ useToast as c,
92
+ useWallet as u
93
+ };
@@ -1,4 +1,4 @@
1
- import { C } from "./chunks/CommunityTaskList-Hde2OKHH.js";
1
+ import { C } from "./chunks/CommunityTaskList-D0uVD8wD.js";
2
2
  export {
3
3
  C as CommunityTaskList
4
4
  };
package/dist/core.d.ts CHANGED
@@ -352,7 +352,7 @@ export declare interface TaskOnContextValue {
352
352
  */
353
353
  chains: ChainInfo[];
354
354
  /**
355
- * Community info (auto-loaded on init based on apiKey)
355
+ * Community info (auto-loaded on init based on clientId)
356
356
  * Used for displaying community logo and name in reward cards
357
357
  */
358
358
  communityInfo: CommunityInfo | null;
@@ -365,7 +365,7 @@ export declare interface TaskOnContextValue {
365
365
  * - TaskOn client management (based on @taskon/core)
366
366
  * - User authentication (login/logout)
367
367
  * - Locale configuration
368
- * - Wallet management (uses window.ethereum adapter)
368
+ * - Wallet management (host adapter or built-in wallet picker)
369
369
  * - Widget locale preloading (optional)
370
370
  * - Toast notifications (internal, user-transparent)
371
371
  */
@@ -376,10 +376,10 @@ export declare function TaskOnProvider({ config, children, preloadLocales, }: Ta
376
376
  */
377
377
  export declare interface TaskOnProviderConfig {
378
378
  /**
379
- * API Key for authentication (X-API-Key header)
380
- * Note: apiKey already contains community info, no need to configure communityId/communityKey separately
379
+ * Client ID for authentication (X-API-Key header)
380
+ * Note: clientId already contains community info, no need to configure communityId/communityKey separately
381
381
  */
382
- apiKey: string;
382
+ clientId: string;
383
383
  /**
384
384
  * API base URL (optional)
385
385
  * @default https://white-label-api.taskon.xyz
@@ -393,8 +393,8 @@ export declare interface TaskOnProviderConfig {
393
393
  /**
394
394
  * Wallet configuration for blockchain interactions
395
395
  *
396
- * When not provided, TaskOn will use built-in window.ethereum adapter
397
- * for EVM wallet connections (MetaMask, etc.)
396
+ * When not provided, TaskOn will use SDK built-in wallet picker adapter
397
+ * for EVM wallet connections.
398
398
  */
399
399
  walletConfig?: WalletConfig;
400
400
  /**
@@ -407,7 +407,7 @@ export declare interface TaskOnProviderConfig {
407
407
  * ```tsx
408
408
  * <TaskOnProvider
409
409
  * config={{
410
- * apiKey: 'your-api-key',
410
+ * clientId: 'your-client-id',
411
411
  * onRequestLogin: () => {
412
412
  * setShowLoginModal(true);
413
413
  * },
@@ -837,15 +837,9 @@ export declare interface WalletAdapter {
837
837
  export declare interface WalletConfig {
838
838
  /**
839
839
  * Custom EVM wallet adapter
840
- * If not provided, uses built-in window.ethereum adapter
840
+ * If not provided, uses SDK built-in wallet picker adapter
841
841
  */
842
842
  evmAdapter?: WalletAdapter;
843
- /**
844
- * Disable auto-detection of wallet providers
845
- * When true, only uses adapter explicitly provided above
846
- * @default false
847
- */
848
- disableAutoDetect?: boolean;
849
843
  }
850
844
 
851
845
  /**
package/dist/core.js CHANGED
@@ -1,7 +1,7 @@
1
- import { T, d, e, f, i, g, u, a, c, b } from "./chunks/ThemeProvider-mXLdLSkq.js";
1
+ import { T, d, e, f, i, g, u, a, c, b } from "./chunks/ThemeProvider-CulHkqqY.js";
2
2
  import { RewardType } from "@taskon/core";
3
- import { T as T2, u as u2 } from "./chunks/TaskOnProvider-BhamHIyY.js";
4
- import { a as a2, u as u3 } from "./chunks/useToast-CaRkylKe.js";
3
+ import { T as T2, u as u2 } from "./chunks/TaskOnProvider-CxtFIs3n.js";
4
+ import { a as a2, u as u3 } from "./chunks/useToast-BGJhd3BX.js";
5
5
  export {
6
6
  RewardType,
7
7
  T2 as TaskOnProvider,
package/dist/index.d.ts CHANGED
@@ -213,6 +213,30 @@ export declare function createLocaleLoader<T>(defaultMessages: T, imports: Local
213
213
  */
214
214
  export declare function createT<T extends Record<string, string>>(messages: T): <K extends keyof T>(key: K, params?: InterpolationParams) => string;
215
215
 
216
+ /**
217
+ * Ethereum Provider Interface (EIP-1193)
218
+ *
219
+ * Exported for scenarios where caller already owns a specific provider
220
+ * instance (e.g. wallet selection dialog) and needs to build an adapter
221
+ * around it.
222
+ */
223
+ declare interface EthereumProvider {
224
+ request: (args: {
225
+ method: string;
226
+ params?: unknown[];
227
+ }) => Promise<unknown>;
228
+ on?: (event: string, callback: (...args: unknown[]) => void) => void;
229
+ removeListener?: (event: string, callback: (...args: unknown[]) => void) => void;
230
+ }
231
+
232
+ export declare class EvmWalletSelectionCanceledError extends Error {
233
+ constructor(message?: string);
234
+ }
235
+
236
+ export declare class EvmWalletSelectionInProgressError extends Error {
237
+ constructor(message?: string);
238
+ }
239
+
216
240
  /**
217
241
  * Interpolate a string with parameters
218
242
  *
@@ -581,6 +605,19 @@ export declare interface SeedToken {
581
605
  spacingChangeUnit?: number;
582
606
  }
583
607
 
608
+ export declare function selectEvmWallet(options?: SelectEvmWalletOptions): Promise<SelectEvmWalletResult>;
609
+
610
+ export declare interface SelectEvmWalletOptions {
611
+ signal?: AbortSignal;
612
+ }
613
+
614
+ export declare interface SelectEvmWalletResult {
615
+ walletId: string;
616
+ walletName: string;
617
+ address: string;
618
+ provider: EthereumProvider;
619
+ }
620
+
584
621
  /**
585
622
  * Locales recognized by the widget i18n runtime.
586
623
  *
@@ -662,7 +699,7 @@ export declare interface TaskOnContextValue {
662
699
  */
663
700
  chains: ChainInfo[];
664
701
  /**
665
- * Community info (auto-loaded on init based on apiKey)
702
+ * Community info (auto-loaded on init based on clientId)
666
703
  * Used for displaying community logo and name in reward cards
667
704
  */
668
705
  communityInfo: CommunityInfo | null;
@@ -675,7 +712,7 @@ export declare interface TaskOnContextValue {
675
712
  * - TaskOn client management (based on @taskon/core)
676
713
  * - User authentication (login/logout)
677
714
  * - Locale configuration
678
- * - Wallet management (uses window.ethereum adapter)
715
+ * - Wallet management (host adapter or built-in wallet picker)
679
716
  * - Widget locale preloading (optional)
680
717
  * - Toast notifications (internal, user-transparent)
681
718
  */
@@ -686,10 +723,10 @@ export declare function TaskOnProvider({ config, children, preloadLocales, }: Ta
686
723
  */
687
724
  export declare interface TaskOnProviderConfig {
688
725
  /**
689
- * API Key for authentication (X-API-Key header)
690
- * Note: apiKey already contains community info, no need to configure communityId/communityKey separately
726
+ * Client ID for authentication (X-API-Key header)
727
+ * Note: clientId already contains community info, no need to configure communityId/communityKey separately
691
728
  */
692
- apiKey: string;
729
+ clientId: string;
693
730
  /**
694
731
  * API base URL (optional)
695
732
  * @default https://white-label-api.taskon.xyz
@@ -703,8 +740,8 @@ export declare interface TaskOnProviderConfig {
703
740
  /**
704
741
  * Wallet configuration for blockchain interactions
705
742
  *
706
- * When not provided, TaskOn will use built-in window.ethereum adapter
707
- * for EVM wallet connections (MetaMask, etc.)
743
+ * When not provided, TaskOn will use SDK built-in wallet picker adapter
744
+ * for EVM wallet connections.
708
745
  */
709
746
  walletConfig?: WalletConfig;
710
747
  /**
@@ -717,7 +754,7 @@ export declare interface TaskOnProviderConfig {
717
754
  * ```tsx
718
755
  * <TaskOnProvider
719
756
  * config={{
720
- * apiKey: 'your-api-key',
757
+ * clientId: 'your-client-id',
721
758
  * onRequestLogin: () => {
722
759
  * setShowLoginModal(true);
723
760
  * },
@@ -1197,15 +1234,9 @@ export declare interface WalletAdapter {
1197
1234
  export declare interface WalletConfig {
1198
1235
  /**
1199
1236
  * Custom EVM wallet adapter
1200
- * If not provided, uses built-in window.ethereum adapter
1237
+ * If not provided, uses SDK built-in wallet picker adapter
1201
1238
  */
1202
1239
  evmAdapter?: WalletAdapter;
1203
- /**
1204
- * Disable auto-detection of wallet providers
1205
- * When true, only uses adapter explicitly provided above
1206
- * @default false
1207
- */
1208
- disableAutoDetect?: boolean;
1209
1240
  }
1210
1241
 
1211
1242
  /**
@@ -1217,6 +1248,24 @@ declare interface WalletContextValue extends WalletState {
1217
1248
  signEvmMessage: (message: string) => Promise<string | null>;
1218
1249
  }
1219
1250
 
1251
+ export declare function WalletPickerDialog({ open, onOpenChange, onSelect, onError, }: WalletPickerDialogProps): default_2.ReactElement;
1252
+
1253
+ export declare function WalletPickerDialogHost(): default_2.ReactElement;
1254
+
1255
+ export declare interface WalletPickerDialogProps {
1256
+ open: boolean;
1257
+ onOpenChange: (open: boolean) => void;
1258
+ onSelect?: (selection: WalletPickerSelection) => Promise<void>;
1259
+ onError?: (error: string) => void;
1260
+ }
1261
+
1262
+ export declare interface WalletPickerSelection {
1263
+ walletId: string;
1264
+ walletName: string;
1265
+ address: string;
1266
+ provider: any;
1267
+ }
1268
+
1220
1269
  /**
1221
1270
  * Wallet state exposed through context
1222
1271
  */
package/dist/index.js CHANGED
@@ -1,15 +1,17 @@
1
- import { c } from "./chunks/WidgetShell-D7yC894Y.js";
2
- import { T, d, e, f, i, g, u, a, c as c2, b } from "./chunks/ThemeProvider-mXLdLSkq.js";
1
+ import { c } from "./chunks/WidgetShell-8xn-Jivw.js";
2
+ import { T, d, e, f, i, g, u, a, c as c2, b } from "./chunks/ThemeProvider-CulHkqqY.js";
3
3
  import { RewardType } from "@taskon/core";
4
- import { T as T2, u as u2 } from "./chunks/TaskOnProvider-BhamHIyY.js";
5
- import { a as a2, u as u3 } from "./chunks/useToast-CaRkylKe.js";
6
- import { C } from "./chunks/CommunityTaskList-Hde2OKHH.js";
7
- import { L } from "./chunks/LeaderboardWidget-BNGRD5Bu.js";
8
- import { Q, Q as Q2 } from "./chunks/Quest-DG9zfXJo.js";
9
- import { U } from "./chunks/UserCenterWidget-jDO5zTN1.js";
10
- import { P } from "./chunks/PageBuilder-C5DSHiW9.js";
4
+ import { E, b as b2, T as T2, W, a as a2, s, u as u2 } from "./chunks/TaskOnProvider-CxtFIs3n.js";
5
+ import { a as a3, u as u3 } from "./chunks/useToast-BGJhd3BX.js";
6
+ import { C } from "./chunks/CommunityTaskList-D0uVD8wD.js";
7
+ import { L } from "./chunks/LeaderboardWidget-DyoiiNS6.js";
8
+ import { Q, Q as Q2 } from "./chunks/Quest-ySZlYd4u.js";
9
+ import { U } from "./chunks/UserCenterWidget-BJsc_GSZ.js";
10
+ import { P } from "./chunks/PageBuilder-DoAFPm6-.js";
11
11
  export {
12
12
  C as CommunityTaskList,
13
+ E as EvmWalletSelectionCanceledError,
14
+ b2 as EvmWalletSelectionInProgressError,
13
15
  L as LeaderboardWidget,
14
16
  P as PageBuilder,
15
17
  Q as Quest,
@@ -18,14 +20,17 @@ export {
18
20
  T2 as TaskOnProvider,
19
21
  T as ThemeProvider,
20
22
  U as UserCenterWidget,
23
+ W as WalletPickerDialog,
24
+ a2 as WalletPickerDialogHost,
21
25
  d as clearLocaleCache,
22
26
  c as cloudThemeToReactTheme,
23
27
  e as createLocaleLoader,
24
28
  f as createT,
25
29
  i as interpolate,
26
30
  g as isSupportedLocale,
31
+ s as selectEvmWallet,
27
32
  u2 as useCommonLocale,
28
- a2 as useEvmWallet,
33
+ a3 as useEvmWallet,
29
34
  u as useTaskOnAuth,
30
35
  a as useTaskOnTheme,
31
36
  c2 as useTranslation,
@@ -1,4 +1,4 @@
1
- import { L } from "./chunks/LeaderboardWidget-BNGRD5Bu.js";
1
+ import { L } from "./chunks/LeaderboardWidget-DyoiiNS6.js";
2
2
  export {
3
3
  L as LeaderboardWidget
4
4
  };
@@ -1,4 +1,4 @@
1
- import { P } from "./chunks/PageBuilder-C5DSHiW9.js";
1
+ import { P } from "./chunks/PageBuilder-DoAFPm6-.js";
2
2
  export {
3
3
  P as PageBuilder
4
4
  };
package/dist/quest.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Q, Q as Q2 } from "./chunks/Quest-DG9zfXJo.js";
1
+ import { Q, Q as Q2 } from "./chunks/Quest-ySZlYd4u.js";
2
2
  export {
3
3
  Q as Quest,
4
4
  Q2 as QuestWidget
@@ -1,4 +1,4 @@
1
- import { U } from "./chunks/UserCenterWidget-jDO5zTN1.js";
1
+ import { U } from "./chunks/UserCenterWidget-BJsc_GSZ.js";
2
2
  export {
3
3
  U as UserCenterWidget
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taskon/widget-react",
3
- "version": "0.0.1-beta.6",
3
+ "version": "0.0.1-beta.7",
4
4
  "description": "TaskOn React Widget Library",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",