@taskon/widget-react 0.0.1

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 (37) hide show
  1. package/README.md +1064 -0
  2. package/dist/CommunityTaskList.css +5010 -0
  3. package/dist/EligibilityInfo.css +1966 -0
  4. package/dist/LeaderboardWidget.css +815 -0
  5. package/dist/Quest.css +4584 -0
  6. package/dist/Table.css +389 -0
  7. package/dist/TaskOnProvider.css +163 -0
  8. package/dist/WidgetShell.css +182 -0
  9. package/dist/chunks/CommunityTaskList-CrH6r4Av.js +6886 -0
  10. package/dist/chunks/EligibilityInfo-DesW9-k9.js +24900 -0
  11. package/dist/chunks/LeaderboardWidget-BSGpHKTk.js +1156 -0
  12. package/dist/chunks/Quest-uSIVq78I.js +8581 -0
  13. package/dist/chunks/Table-CWGf2FKV.js +449 -0
  14. package/dist/chunks/TaskOnProvider-QMwxGL44.js +1435 -0
  15. package/dist/chunks/ThemeProvider-Cs8IUVQj.js +1118 -0
  16. package/dist/chunks/WidgetShell-NlOgn1x5.js +1517 -0
  17. package/dist/chunks/common-ja-DWhTaFHb.js +23 -0
  18. package/dist/chunks/common-ko-80ezXsMG.js +23 -0
  19. package/dist/chunks/index-CwMvO_wZ.js +777 -0
  20. package/dist/chunks/leaderboardwidget-ja-Bj6gz6y1.js +119 -0
  21. package/dist/chunks/leaderboardwidget-ko-f1cLO9ic.js +119 -0
  22. package/dist/chunks/useToast-BGJhd3BX.js +93 -0
  23. package/dist/chunks/useWidgetLocale-BVcopbZS.js +74 -0
  24. package/dist/chunks/usercenter-ja-DBj_dtuz.js +329 -0
  25. package/dist/chunks/usercenter-ko-DYTkHAld.js +329 -0
  26. package/dist/community-task.d.ts +451 -0
  27. package/dist/community-task.js +9 -0
  28. package/dist/core.d.ts +803 -0
  29. package/dist/core.js +22 -0
  30. package/dist/index.css +3662 -0
  31. package/dist/index.d.ts +1627 -0
  32. package/dist/index.js +7372 -0
  33. package/dist/leaderboard.d.ts +547 -0
  34. package/dist/leaderboard.js +17 -0
  35. package/dist/quest.d.ts +389 -0
  36. package/dist/quest.js +8 -0
  37. package/package.json +97 -0
@@ -0,0 +1,1627 @@
1
+ import { CampaignStatusInfo } from '@taskon/core';
2
+ import { CampaignWinnerReward } from '@taskon/core';
3
+ import { ChainInfo } from '@taskon/core';
4
+ import { ChainType } from '@taskon/core';
5
+ import { CommunityInfo } from '@taskon/core';
6
+ import { CommunityTaskInfo } from '@taskon/core';
7
+ import { ComponentPropsWithoutRef } from 'react';
8
+ import { default as default_2 } from 'react';
9
+ import { ForwardRefExoticComponent } from 'react';
10
+ import { GtcUserTaskStatus } from '@taskon/core';
11
+ import { LeaderboardContentConfig } from '@taskon/core';
12
+ import { LoginResult } from '@taskon/core';
13
+ import { MeetCondition } from '@taskon/core';
14
+ import { QuestApi } from '@taskon/core';
15
+ import { QuestCampaignInfo } from '@taskon/core';
16
+ import { ReactNode } from 'react';
17
+ import { RecurrenceType } from '@taskon/core';
18
+ import { RefAttributes } from 'react';
19
+ import { RewardType } from '@taskon/core';
20
+ import { RewardValueInfo } from '@taskon/core';
21
+ import { SnsType } from '@taskon/core';
22
+ import { TaskOnClient } from '@taskon/core';
23
+ import { TaskReviewResult } from '@taskon/core';
24
+ import { UserCampaignStatusInfo } from '@taskon/core';
25
+ import { UserCenterConfig } from '@taskon/core';
26
+ import { UserCenterTabType } from '@taskon/core';
27
+ import { UserInfo } from '@taskon/core';
28
+
29
+ /**
30
+ * Button 通用按钮组件
31
+ *
32
+ * 基于 Radix UI Slot 实现,支持 asChild 模式
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * // 基础用法
37
+ * <Button>点击我</Button>
38
+ *
39
+ * // 不同变体
40
+ * <Button variant="primary">主要按钮</Button>
41
+ * <Button variant="secondary">次要按钮</Button>
42
+ * <Button variant="outline">描边按钮</Button>
43
+ * <Button variant="ghost">幽灵按钮</Button>
44
+ * <Button variant="danger">危险按钮</Button>
45
+ *
46
+ * // 不同尺寸
47
+ * <Button size="small">小按钮</Button>
48
+ * <Button size="medium">中等按钮</Button>
49
+ * <Button size="large">大按钮</Button>
50
+ *
51
+ * // 加载状态
52
+ * <Button loading>加载中</Button>
53
+ *
54
+ * // 带图标
55
+ * <Button leftIcon={<Icon />}>左侧图标</Button>
56
+ * <Button rightIcon={<Icon />}>右侧图标</Button>
57
+ *
58
+ * // 禁用状态
59
+ * <Button disabled>禁用按钮</Button>
60
+ *
61
+ * // asChild 模式(将 Button 样式应用到子元素)
62
+ * <Button asChild>
63
+ * <a href="/about">链接按钮</a>
64
+ * </Button>
65
+ * ```
66
+ */
67
+ export declare const Button: ForwardRefExoticComponent<ButtonProps & RefAttributes<HTMLButtonElement>>;
68
+
69
+ /**
70
+ * Button 组件属性
71
+ */
72
+ export declare interface ButtonProps extends ComponentPropsWithoutRef<"button"> {
73
+ /**
74
+ * 按钮尺寸
75
+ * @default "medium"
76
+ */
77
+ size?: ButtonSize;
78
+ /**
79
+ * 按钮变体
80
+ * @default "primary"
81
+ */
82
+ variant?: ButtonVariant;
83
+ /**
84
+ * 是否为加载状态
85
+ * @default false
86
+ */
87
+ loading?: boolean;
88
+ /**
89
+ * 图标位置
90
+ */
91
+ iconPosition?: "left" | "right" | "only";
92
+ /**
93
+ * 左侧图标
94
+ */
95
+ leftIcon?: ReactNode;
96
+ /**
97
+ * 右侧图标
98
+ */
99
+ rightIcon?: ReactNode;
100
+ /**
101
+ * 是否作为子元素渲染(使用 Radix Slot)
102
+ * 当为 true 时,Button 会将所有属性传递给第一个子元素
103
+ * @default false
104
+ */
105
+ asChild?: boolean;
106
+ /**
107
+ * 按钮内容
108
+ */
109
+ children?: ReactNode;
110
+ }
111
+
112
+ /**
113
+ * Button 尺寸类型
114
+ */
115
+ export declare type ButtonSize = "small" | "medium" | "large";
116
+
117
+ /**
118
+ * Button 变体类型
119
+ */
120
+ export declare type ButtonVariant = "primary" | "secondary" | "outline" | "ghost" | "danger";
121
+
122
+ /**
123
+ * CardSelector 组件
124
+ *
125
+ * @example
126
+ * ```tsx
127
+ * const options = [
128
+ * { value: 'all', label: 'All Tasks' },
129
+ * { value: 1, label: 'Daily Tasks' },
130
+ * { value: 2, label: 'Weekly Tasks' },
131
+ * ];
132
+ *
133
+ * <CardSelector
134
+ * options={options}
135
+ * value={selectedValue}
136
+ * onChange={setSelectedValue}
137
+ * allowDeselect
138
+ * />
139
+ * ```
140
+ */
141
+ export declare function CardSelector<T extends string | number = string | number>({ options, value, onChange, allowDeselect, className, itemClassName, }: CardSelectorProps<T>): default_2.ReactElement;
142
+
143
+ /**
144
+ * 选项配置
145
+ */
146
+ export declare interface CardSelectorOption<T = string | number> {
147
+ /** 选项的值 */
148
+ value: T;
149
+ /** 选项的显示文本 */
150
+ label: string;
151
+ }
152
+
153
+ /**
154
+ * CardSelector 组件属性
155
+ */
156
+ export declare interface CardSelectorProps<T = string | number> {
157
+ /** 选项列表 */
158
+ options: CardSelectorOption<T>[];
159
+ /** 当前选中的值 */
160
+ value?: T;
161
+ /** 值变化回调 */
162
+ onChange?: (value: T | undefined) => void;
163
+ /** 是否允许取消选择(点击已选中项取消选择)
164
+ * @default true
165
+ */
166
+ allowDeselect?: boolean;
167
+ /** 自定义根容器类名 */
168
+ className?: string;
169
+ /** 自定义选项类名 */
170
+ itemClassName?: string;
171
+ }
172
+
173
+ /**
174
+ * Clear the locale cache
175
+ * Useful for testing or when you need to force reload locales
176
+ */
177
+ export declare function clearLocaleCache(): void;
178
+
179
+ /**
180
+ * Common messages type definition
181
+ *
182
+ * These are shared messages used across multiple widgets.
183
+ * All language files must implement this interface.
184
+ */
185
+ export declare interface CommonMessages {
186
+ /** Loading state text */
187
+ loading: string;
188
+ /** Generic error message */
189
+ error: string;
190
+ /** Retry action text */
191
+ retry: string;
192
+ /** Success message */
193
+ success: string;
194
+ /** Cancel action text */
195
+ cancel: string;
196
+ /** Confirm action text */
197
+ confirm: string;
198
+ }
199
+
200
+ /**
201
+ * BaseTask 组件
202
+ * @description 基础任务卡片,职责:
203
+ * - 卡片布局(flex 容器)
204
+ * - 周期标签显示
205
+ * - 任务标题显示
206
+ * - 有效时间显示
207
+ * - 按钮区域管理
208
+ * - 完成状态样式
209
+ *
210
+ * @example
211
+ * ```tsx
212
+ * <BaseTask
213
+ * title="Follow @TaskOn_xyz"
214
+ * isWon={false}
215
+ * isCompleted={false}
216
+ * isPeriodic={true}
217
+ * recurrenceLabel="Daily"
218
+ * taskId={123}
219
+ * actionLabel="Follow"
220
+ * actionLink="https://twitter.com/TaskOn_xyz"
221
+ * reward={{ type: 'points', amount: 100, name: 'Points', icon: '/icon.png' }}
222
+ * onClick={() => console.log('卡片被点击')}
223
+ * onClaim={() => console.log('Claim 按钮被点击')}
224
+ * >
225
+ * <div>额外的任务描述内容</div>
226
+ * </BaseTask>
227
+ * ```
228
+ */
229
+ export declare function CommunityTask(props: CommunityTaskProps): default_2.ReactElement;
230
+
231
+ /**
232
+ * CommunityTaskList outer wrapper
233
+ *
234
+ * Handles cloud config loading + ThemeProvider wrapping via WidgetShell.
235
+ * Merges cloud function config with local props, then renders inner component.
236
+ */
237
+ export declare function CommunityTaskList(props: CommunityTaskListProps): default_2.ReactElement;
238
+
239
+ /**
240
+ * CommunityTaskList component props
241
+ */
242
+ export declare interface CommunityTaskListProps {
243
+ /**
244
+ * Widget ID - load configuration (theme + function) from cloud
245
+ * Cloud config includes display options, sector filtering, etc.
246
+ */
247
+ widgetId?: number;
248
+ /** Whether in preview mode */
249
+ isPreview?: boolean;
250
+ /** 社区信息(用于前置任务链接跳转) */
251
+ communityInfo?: {
252
+ community_key?: string;
253
+ dapp_domain?: string;
254
+ };
255
+ /**
256
+ * Initial task ID from URL (passed by host after parsing URL)
257
+ * Used to auto-open task dialog on page refresh or shared links
258
+ * @example
259
+ * ```tsx
260
+ * const searchParams = useSearchParams();
261
+ * <CommunityTaskList initialTaskId={Number(searchParams.get('task')) || undefined} />
262
+ * ```
263
+ */
264
+ initialTaskId?: number;
265
+ /**
266
+ * Callback when dialog opens (host can use to update URL params)
267
+ * @param taskId Currently opened task ID
268
+ * @example
269
+ * ```tsx
270
+ * onTaskOpen={(taskId) => router.replace(`?task=${taskId}`)}
271
+ * ```
272
+ */
273
+ onTaskOpen?: (taskId: number) => void;
274
+ /**
275
+ * Callback when dialog closes (host can use to clear URL params)
276
+ * @example
277
+ * ```tsx
278
+ * onTaskClose={() => router.replace(pathname)}
279
+ * ```
280
+ */
281
+ onTaskClose?: () => void;
282
+ /** Sector IDs to display; undefined means show all */
283
+ sectorIds?: number[];
284
+ /** Whether to show sector tab selector (default: true) */
285
+ showSectorTab?: boolean;
286
+ /** Whether to show sector name (default: true) */
287
+ showSectorName?: boolean;
288
+ /** Whether to show sector description (default: true) */
289
+ showSectorDescription?: boolean;
290
+ /** Whether to show sector reward (default: true) */
291
+ showSectorReward?: boolean;
292
+ }
293
+
294
+ /**
295
+ * 任务卡片基础 Props(最小知识原则)
296
+ * BaseTask 只需要知道这些信息
297
+ */
298
+ export declare interface CommunityTaskProps {
299
+ /** 任务名称/标题(字符串或自定义渲染节点) */
300
+ title: string | React.ReactNode;
301
+ /** 是否已中奖/完成 */
302
+ isWon: boolean;
303
+ /** 是否已提交(可能未中奖) */
304
+ isCompleted: boolean;
305
+ /** 是否是周期任务 */
306
+ isPeriodic: boolean;
307
+ /** 操作按钮文案(如 "Follow"、"Join") */
308
+ actionLabel?: string;
309
+ /** 操作按钮链接(默认在新标签页打开) */
310
+ actionLink?: string;
311
+ /** 点击操作按钮后是否自动验证 */
312
+ actionAutoVerify?: boolean;
313
+ /**
314
+ * 点击 Action 按钮时自动打开弹窗
315
+ * 用于 PowTask、InviteFriends 等需要在弹窗中填写内容的任务
316
+ */
317
+ actionAutoDialog?: boolean;
318
+ /** 是否总是显示操作按钮(即使已完成) */
319
+ alwaysShowAction?: boolean;
320
+ /**
321
+ * 标题跳转链接
322
+ * 如果提供,标题将变成可点击的链接,在新标签页打开
323
+ */
324
+ targetLink?: string;
325
+ /** 是否隐藏 Claim 按钮 */
326
+ noClaim?: boolean;
327
+ /**
328
+ * 是否需要验证后才能 Claim
329
+ * - true: 显示 "Verify & Claim"
330
+ * - false: 显示 "Claim"
331
+ */
332
+ verifyClaim?: boolean;
333
+ /**
334
+ * 点击 Claim 仅打开弹窗(不提交)
335
+ * 用于 QuizTask、SurveyTask 等需要在弹窗中选择答案的任务
336
+ */
337
+ claimDialog?: boolean;
338
+ /**
339
+ * 社交账号类型(用于 OAuth 绑定)
340
+ * 决定 Claim 时需要绑定哪种社交账号
341
+ */
342
+ snsType?: SnsType;
343
+ /**
344
+ * 链类型(用于钱包绑定)
345
+ * 决定 Claim 时需要绑定哪种链的钱包
346
+ */
347
+ chainType?: ChainType;
348
+ /** 周期标签文本(如 "Daily"、"Weekly") */
349
+ recurrenceLabel?: string;
350
+ /** 任务重复类型(用于 Claim 按钮文案逻辑) */
351
+ recurrence?: RecurrenceType;
352
+ /** 是否隐藏周期标签 */
353
+ noRecurrence?: boolean;
354
+ /**
355
+ * Unlimited 任务是否显示大的 Claim 按钮
356
+ * - true: 显示正常大小的 Claim 按钮
357
+ * - false: 显示小的 Update 按钮(已有积分)
358
+ * @default true
359
+ */
360
+ showUnlimitedClaim?: boolean;
361
+ /** 任务 ID */
362
+ taskId: number;
363
+ /** 有效时间相关 */
364
+ validTime?: {
365
+ /** 开始时间(格式化字符串) */
366
+ startTime?: string;
367
+ /** 结束时间(格式化字符串) */
368
+ endTime?: string;
369
+ /** 是否已过期 */
370
+ isExpired?: boolean;
371
+ };
372
+ /**
373
+ * 验证时间范围(OnChain 任务专用)
374
+ * 显示 "This task only verify action during {start} - {end}(UTC)"
375
+ */
376
+ validationTimeFrame?: {
377
+ /** 开始时间(毫秒或秒时间戳) */
378
+ start_time: number;
379
+ /** 结束时间(毫秒或秒时间戳) */
380
+ end_time: number;
381
+ };
382
+ /** 奖励信息 */
383
+ reward?: {
384
+ /** 奖励类型 */
385
+ type: "points" | "token" | "none";
386
+ /** 积分数量(points 类型,单次奖励) */
387
+ amount?: number;
388
+ /** 积分名称(points 类型) */
389
+ name?: string;
390
+ /** 积分图标(points 类型) */
391
+ icon?: string;
392
+ /** 累计积分(周期任务完成时显示) */
393
+ totalAmount?: number;
394
+ /** Token 信息(token 类型) */
395
+ token?: {
396
+ /** Token 名称 */
397
+ name: string;
398
+ /** 每次奖励数量 */
399
+ amount: string;
400
+ /** Token 图标 */
401
+ icon?: string;
402
+ /** 链名称 */
403
+ chain?: string;
404
+ /** 链图标 */
405
+ chainIcon?: string;
406
+ /** 总奖励单位数 */
407
+ totalUnit?: number;
408
+ /** 可用单位数 */
409
+ availableUnit?: number;
410
+ };
411
+ };
412
+ /** 卡片内容(由具体任务组件提供,用于展示任务特定内容) */
413
+ children?: React.ReactNode;
414
+ /**
415
+ * 自定义 Action 按钮区域
416
+ * 如果提供,将替换默认的 Action 按钮
417
+ * @example
418
+ * ```tsx
419
+ * <BaseTask
420
+ * actionSlot={<CustomActionButton onClick={handleAction} />}
421
+ * />
422
+ * ```
423
+ */
424
+ actionSlot?: React.ReactNode;
425
+ /**
426
+ * 自定义奖励展示(已完成状态)
427
+ * 如果提供,将替换默认的 Won 奖励显示
428
+ * @example
429
+ * ```tsx
430
+ * <BaseTask
431
+ * rewardSlot={<CustomRewardDisplay amount={100} />}
432
+ * />
433
+ * ```
434
+ */
435
+ rewardSlot?: React.ReactNode;
436
+ /**
437
+ * 是否已登录
438
+ * - true: 正常显示卡片
439
+ * - false/undefined: 显示登录遮层,点击触发 onLogin
440
+ * @default true
441
+ */
442
+ isLoggedIn?: boolean;
443
+ /** 点击卡片回调(用于打开弹窗) */
444
+ onClick?: () => void;
445
+ /**
446
+ * 点击 Claim 按钮回调
447
+ * @param token - 可选的 OAuth token(reAuth 成功后传入)
448
+ * @returns 可选返回 Promise,包含结果信息用于 reAuth 判断和 coolDown 更新
449
+ */
450
+ onClaim?: (token?: string) => void | Promise<{
451
+ successful: boolean;
452
+ errorCode?: string;
453
+ cool_down?: number;
454
+ }>;
455
+ /**
456
+ * 点击登录遮层回调
457
+ * 未登录时(isLoggedIn=false)点击卡片会触发此回调
458
+ */
459
+ onLogin?: () => void;
460
+ /** 是否正在提交 */
461
+ isSubmitting?: boolean;
462
+ /** 冷却时间(毫秒) */
463
+ coolDown?: number;
464
+ /** 冷却结束回调(用于重置 coolDown 状态) */
465
+ onCoolDownComplete?: () => void;
466
+ /** 是否禁用交互 */
467
+ disabled?: boolean;
468
+ /**
469
+ * 审核结果状态
470
+ * - Passed: 审核通过
471
+ * - Failed: 审核失败(显示 "Oops! Failed")
472
+ * - UnReviewed: 审核中(显示 "Under Review")
473
+ */
474
+ reviewResult?: TaskReviewResult;
475
+ /**
476
+ * CheckProgressTip 需要的社区信息
477
+ * 用于显示 "Contact {name} to check your progress"
478
+ */
479
+ communityInfo?: {
480
+ /** 社区名称 */
481
+ name?: string;
482
+ /** 社区联系链接(Discord/Telegram/Twitter) */
483
+ contactLink?: string;
484
+ };
485
+ /**
486
+ * 周期任务:当前周期是否已完成
487
+ * 配合 nextTime 用于显示 DoneCountdown
488
+ */
489
+ currentCompleted?: boolean;
490
+ /**
491
+ * 周期任务:下次可完成的时间戳(毫秒)
492
+ * 用于显示 DoneCountdown 倒计时
493
+ */
494
+ nextTime?: number;
495
+ }
496
+
497
+ /**
498
+ * Create a locale loader function for a widget
499
+ *
500
+ * @template T - The shape of the messages object
501
+ * @param defaultMessages - English messages (used as fallback)
502
+ * @param imports - Map of locale codes to dynamic import functions
503
+ * @returns A function that loads messages for a given locale
504
+ *
505
+ * @example
506
+ * ```ts
507
+ * import enMessages from './locales/en';
508
+ *
509
+ * const loadMessages = createLocaleLoader(enMessages, {
510
+ * ko: () => import('./locales/ko'),
511
+ * ja: () => import('./locales/ja'),
512
+ * });
513
+ * ```
514
+ */
515
+ export declare function createLocaleLoader<T>(defaultMessages: T, imports: LocaleImportMap<T>): (locale: Locale) => Promise<{
516
+ default: T;
517
+ }>;
518
+
519
+ /**
520
+ * Create a translation function from a messages object
521
+ *
522
+ * @param messages - Object containing translation strings
523
+ * @returns A function that retrieves and interpolates translations
524
+ *
525
+ * @example
526
+ * ```ts
527
+ * const messages = {
528
+ * greeting: 'Hello, {name}!',
529
+ * points: 'You have {count} points',
530
+ * };
531
+ *
532
+ * const t = createT(messages);
533
+ *
534
+ * t('greeting', { name: 'John' }) // => 'Hello, John!'
535
+ * t('points', { count: 100 }) // => 'You have 100 points'
536
+ * t('greeting') // => 'Hello, {name}!' (no params)
537
+ * ```
538
+ */
539
+ export declare function createT<T extends Record<string, string>>(messages: T): <K extends keyof T>(key: K, params?: InterpolationParams) => string;
540
+
541
+ /**
542
+ * Interpolate a string with parameters
543
+ *
544
+ * @param template - String template with {key} placeholders
545
+ * @param params - Object containing values to replace placeholders
546
+ * @returns Interpolated string
547
+ *
548
+ * @example
549
+ * ```ts
550
+ * interpolate('Hello, {name}!', { name: 'John' })
551
+ * // => 'Hello, John!'
552
+ *
553
+ * interpolate('You have {count} points', { count: 100 })
554
+ * // => 'You have 100 points'
555
+ *
556
+ * interpolate('{a} + {b} = {result}', { a: 1, b: 2, result: 3 })
557
+ * // => '1 + 2 = 3'
558
+ * ```
559
+ */
560
+ export declare function interpolate(template: string, params?: InterpolationParams): string;
561
+
562
+ /**
563
+ * interpolate - Simple string interpolation utility
564
+ *
565
+ * Replaces placeholders in the format {key} with values from the params object.
566
+ * This is a lightweight alternative to full i18n libraries when only simple
567
+ * variable replacement is needed.
568
+ */
569
+ /**
570
+ * Params object type for interpolation
571
+ */
572
+ export declare type InterpolationParams = Record<string, string | number | undefined>;
573
+
574
+ /**
575
+ * Parameters for contract invocation
576
+ */
577
+ declare interface InvokeContractParams {
578
+ /** Contract address */
579
+ contract: string;
580
+ /** Contract ABI (Application Binary Interface) */
581
+ abi: unknown[];
582
+ /** Method name to call */
583
+ method: string;
584
+ /** Method parameters */
585
+ params: unknown[];
586
+ /** Target chain ID (optional, will switch network if needed) */
587
+ chainId?: number;
588
+ /** Transaction value in wei (for payable methods) */
589
+ value?: string;
590
+ }
591
+
592
+ /**
593
+ * Check if a locale has full translation support
594
+ */
595
+ export declare function isSupportedLocale(locale: Locale): locale is SupportedLocale;
596
+
597
+ /**
598
+ * 排行榜 Widget 外层组件
599
+ *
600
+ * Handles cloud config loading + ThemeProvider wrapping via WidgetShell.
601
+ * Merges cloud function config with local props, then renders inner component.
602
+ *
603
+ * @example
604
+ * ```tsx
605
+ * // Pure props mode
606
+ * <LeaderboardWidget config={config} />
607
+ *
608
+ * // Pure widgetId mode (config from cloud)
609
+ * <LeaderboardWidget widgetId={456} />
610
+ *
611
+ * // Mixed mode (props override cloud)
612
+ * <LeaderboardWidget widgetId={456} defaultTabId="sprint-1" />
613
+ * ```
614
+ */
615
+ export declare function LeaderboardWidget(props: LeaderboardWidgetProps): default_2.ReactElement | null;
616
+
617
+ /**
618
+ * LeaderboardWidget 组件 Props
619
+ */
620
+ export declare interface LeaderboardWidgetProps {
621
+ /**
622
+ * Widget ID - load configuration (theme + function) from cloud
623
+ * Cloud config provides leaderboard tabs, display options, etc.
624
+ */
625
+ widgetId?: number;
626
+ /**
627
+ * 排行榜配置
628
+ * 包含所有 Tab 的配置和显示选项
629
+ * 如果传入 widgetId,可从云端获取;如果同时传入则 props 优先
630
+ */
631
+ config?: LeaderboardContentConfig;
632
+ /** 默认激活的 Tab ID(不传则默认第一个) */
633
+ defaultTabId?: string;
634
+ /** Tab 切换回调 */
635
+ onTabChange?: (tabId: string) => void;
636
+ /** 用户点击回调 */
637
+ onUserClick?: (userId: number, userName: string) => void;
638
+ /** 自定义类名 */
639
+ className?: string;
640
+ /** 自定义样式 */
641
+ style?: default_2.CSSProperties;
642
+ }
643
+
644
+ export declare type Locale = "en" | "ko" | "ja" | "ru" | "es";
645
+
646
+ /**
647
+ * Locale import map type
648
+ * Maps supported locales to their dynamic import functions
649
+ */
650
+ export declare type LocaleImportMap<T> = {
651
+ [K in Exclude<SupportedLocale, "en">]?: () => Promise<{
652
+ default: T;
653
+ }>;
654
+ };
655
+
656
+ /**
657
+ * Supported login methods
658
+ */
659
+ export declare type LoginMethod = "evm_wallet" | "email" | "discord" | "twitter" | "telegram";
660
+
661
+ /**
662
+ * Unified login parameters
663
+ */
664
+ export declare interface LoginParams {
665
+ /** Login method */
666
+ method: LoginMethod;
667
+ /** Value: wallet address / email / OAuth token */
668
+ value: string;
669
+ /** Signature from backend */
670
+ sign: string;
671
+ /** Timestamp used for signing (seconds) */
672
+ timestamp: number;
673
+ }
674
+
675
+ export { LoginResult }
676
+
677
+ /**
678
+ * Map Token - Can override derived values
679
+ */
680
+ export declare interface MapToken {
681
+ colorPrimary?: string;
682
+ colorPrimaryHover?: string;
683
+ colorPrimaryActive?: string;
684
+ colorPrimaryBg?: string;
685
+ colorSecondary?: string;
686
+ colorSuccess?: string;
687
+ colorWarning?: string;
688
+ colorError?: string;
689
+ colorBg?: string;
690
+ colorBgElevated?: string;
691
+ colorBgSpotlight?: string;
692
+ colorText?: string;
693
+ colorTextSecondary?: string;
694
+ colorTextTertiary?: string;
695
+ colorTextDisabled?: string;
696
+ colorBorder?: string;
697
+ colorBorderSecondary?: string;
698
+ borderRadius?: number;
699
+ borderRadiusSm?: number;
700
+ borderRadiusLg?: number;
701
+ fontSize?: number;
702
+ fontSizeSm?: number;
703
+ fontSizeLg?: number;
704
+ spacing?: number;
705
+ spacingXs?: number;
706
+ spacingSm?: number;
707
+ spacingMd?: number;
708
+ spacingLg?: number;
709
+ spacingXl?: number;
710
+ }
711
+
712
+ /**
713
+ * Mode-specific configuration
714
+ */
715
+ declare interface ModeThemeConfig {
716
+ seed?: SeedToken;
717
+ map?: MapToken;
718
+ }
719
+
720
+ /**
721
+ * Quest Widget 主组件
722
+ *
723
+ * @description
724
+ * 将 taskon-website 中的 Quest (Campaign) 详情页迁移为 React Widget 组件
725
+ * 供第三方项目嵌入使用
726
+ *
727
+ * 架构原则:只在根组件访问 context,子组件通过 props 接收数据
728
+ *
729
+ * @example
730
+ * ```tsx
731
+ * import { QuestWidget } from '@taskon/widget-react';
732
+ *
733
+ * function App() {
734
+ * return (
735
+ * <TaskOnProvider config={{ ... }}>
736
+ * <QuestWidget
737
+ * campaignId={123}
738
+ * showBanner={true}
739
+ * onLoaded={(campaign) => console.log('Quest loaded:', campaign.name)}
740
+ * onSubmitSuccess={() => console.log('Quest completed!')}
741
+ * />
742
+ * </TaskOnProvider>
743
+ * );
744
+ * }
745
+ * ```
746
+ */
747
+ declare function QuestWidget(props: QuestWidgetProps): default_2.ReactElement;
748
+ export { QuestWidget as Quest }
749
+ export { QuestWidget }
750
+
751
+ /**
752
+ * Quest Widget 主组件 Props
753
+ */
754
+ export declare interface QuestWidgetProps {
755
+ /**
756
+ * Widget ID - 传入后从云端加载配置(theme + function)
757
+ * 云端配置包含 campaignId、显示选项、自定义分享文案等
758
+ */
759
+ widgetId?: number;
760
+ /**
761
+ * Campaign ID
762
+ * - 如果传入 widgetId,campaignId 可从云端配置获取
763
+ * - 如果同时传入 widgetId 和 campaignId,本地 props 优先
764
+ */
765
+ campaignId?: number;
766
+ /** 渠道标识(可选) */
767
+ channel?: string;
768
+ /** KOL 标识(可选) */
769
+ kolHandle?: string;
770
+ /** 邀请码(可选) */
771
+ inviteCode?: string;
772
+ /** Boost ID(可选) */
773
+ boostId?: number;
774
+ /** 是否为预览模式 */
775
+ isPreview?: boolean;
776
+ /** 是否显示 Banner */
777
+ showBanner?: boolean;
778
+ /** 是否显示标题 */
779
+ showTitle?: boolean;
780
+ /** 是否显示描述 */
781
+ showDescription?: boolean;
782
+ /** 加载完成回调 */
783
+ onLoaded?: (campaign: QuestCampaignInfo) => void;
784
+ /** 任务完成回调 */
785
+ onTaskCompleted?: (taskId: number) => void;
786
+ /** Quest 提交成功回调 */
787
+ onSubmitSuccess?: () => void;
788
+ /** 错误回调 */
789
+ onError?: (error: Error) => void;
790
+ /** 连接钱包回调(未登录时触发) */
791
+ onConnectWallet?: () => void;
792
+ /** 领取 NFT 回调 (NFT/MintedNft/Cap) */
793
+ onClaimNft?: (reward: RewardValueInfo, layer: CampaignWinnerReward) => Promise<void>;
794
+ /** 领取 Discord 角色回调 */
795
+ onClaimDiscordRole?: (reward: RewardValueInfo, layer: CampaignWinnerReward) => Promise<void>;
796
+ /**
797
+ * @deprecated 绑定现在由 Widget 内部处理,此回调不再使用
798
+ * 需要绑定链地址时的回调
799
+ */
800
+ onBindChainRequired?: (chainTypes: ChainType[]) => void;
801
+ /**
802
+ * @deprecated 绑定现在由 Widget 内部处理,此回调不再使用
803
+ * 需要绑定 SNS 时的回调
804
+ */
805
+ onBindSnsRequired?: (snsTypes: SnsType[]) => void;
806
+ /** 分享链接(配置后显示分享按钮) */
807
+ shareUrl?: string;
808
+ /** Twitter 分享文案(可选,有默认文案) */
809
+ shareText?: string;
810
+ }
811
+
812
+ export { RewardType }
813
+
814
+ /**
815
+ * Seed Token - Input values that auto-derive other tokens
816
+ */
817
+ export declare interface SeedToken {
818
+ /** Primary color */
819
+ colorPrimary?: string;
820
+ /** Secondary color */
821
+ colorSecondary?: string;
822
+ /** Success color */
823
+ colorSuccess?: string;
824
+ /** Warning color */
825
+ colorWarning?: string;
826
+ /** Error color */
827
+ colorError?: string;
828
+ /** Base border radius */
829
+ borderRadius?: number;
830
+ /** Base font size */
831
+ fontSize?: number;
832
+ }
833
+
834
+ /**
835
+ * Locales that have full translation support in all widgets
836
+ * Other locales in the Locale type will fallback to English
837
+ */
838
+ export declare type SupportedLocale = "en" | "ko" | "ja";
839
+
840
+ /**
841
+ * TaskOn Context value
842
+ */
843
+ export declare interface TaskOnContextValue {
844
+ /**
845
+ * Provider configuration
846
+ */
847
+ config: TaskOnProviderConfig;
848
+ /**
849
+ * TaskOn client instance from @taskon/core
850
+ */
851
+ client: TaskOnClient | null;
852
+ /**
853
+ * Whether the provider is initializing
854
+ */
855
+ isInitializing: boolean;
856
+ /**
857
+ * Resolved locale
858
+ */
859
+ locale: Locale;
860
+ /**
861
+ * TaskOn user ID, null if not logged in
862
+ */
863
+ userId: number | null;
864
+ /**
865
+ * Current user info, null if not logged in
866
+ */
867
+ userInfo: UserInfo | null;
868
+ /**
869
+ * Current user token, null if not logged in
870
+ */
871
+ userToken: string | null;
872
+ /**
873
+ * Whether user is logged in
874
+ */
875
+ isLoggedIn: boolean;
876
+ /**
877
+ * Unified login method
878
+ */
879
+ login: (params: LoginParams) => Promise<void>;
880
+ /**
881
+ * Logout current user
882
+ */
883
+ logout: () => void;
884
+ /**
885
+ * Request login callback
886
+ * Triggers config.onRequestLogin if provided
887
+ */
888
+ requestLogin: () => void;
889
+ /**
890
+ * Refresh user info from server
891
+ * Call this after binding social accounts to update userInfo
892
+ */
893
+ refreshUserInfo: () => Promise<void>;
894
+ /**
895
+ * Chain info list (loaded on init)
896
+ * Used for determining chain types for wallet binding
897
+ */
898
+ chains: ChainInfo[];
899
+ /**
900
+ * Community info (auto-loaded on init based on apiKey)
901
+ * Used for displaying community logo and name in reward cards
902
+ */
903
+ communityInfo: CommunityInfo | null;
904
+ }
905
+
906
+ /**
907
+ * TaskOn Provider Component
908
+ *
909
+ * Root component for TaskOn Widget, providing:
910
+ * - TaskOn client management (based on @taskon/core)
911
+ * - User authentication (login/logout)
912
+ * - Locale configuration
913
+ * - Wallet management (uses window.ethereum adapter)
914
+ * - Widget locale preloading (optional)
915
+ * - Toast notifications (internal, user-transparent)
916
+ */
917
+ export declare function TaskOnProvider({ config, children, preloadLocales, }: TaskOnProviderProps): ReactNode;
918
+
919
+ /**
920
+ * TaskOn Provider configuration
921
+ */
922
+ export declare interface TaskOnProviderConfig {
923
+ /**
924
+ * API Key for authentication (X-API-Key header)
925
+ * Note: apiKey already contains community info, no need to configure communityId/communityKey separately
926
+ */
927
+ apiKey: string;
928
+ /**
929
+ * API base URL (optional)
930
+ * @default https://white-label-api.taskon.xyz
931
+ */
932
+ baseURL?: string;
933
+ /**
934
+ * Locale setting for internationalization
935
+ * @default auto-detect from browser
936
+ */
937
+ locale?: Locale;
938
+ /**
939
+ * Wallet configuration for blockchain interactions
940
+ *
941
+ * When not provided, TaskOn will use built-in window.ethereum adapter
942
+ * for EVM wallet connections (MetaMask, etc.)
943
+ */
944
+ walletConfig?: WalletConfig;
945
+ /**
946
+ * Callback when user requests to login
947
+ *
948
+ * This is triggered when user clicks on login overlay in widgets.
949
+ * Use this to show your login modal or redirect to login page.
950
+ *
951
+ * @example
952
+ * ```tsx
953
+ * <TaskOnProvider
954
+ * config={{
955
+ * apiKey: 'your-api-key',
956
+ * onRequestLogin: () => {
957
+ * setShowLoginModal(true);
958
+ * },
959
+ * }}
960
+ * >
961
+ * ```
962
+ */
963
+ onRequestLogin?: () => void;
964
+ /**
965
+ * OAuth tool URL for social account binding
966
+ *
967
+ * When users need to bind Twitter/Discord/Telegram accounts,
968
+ * this URL will be used to open the OAuth authorization popup.
969
+ *
970
+ * @default https://generalauthservice.com (main environment)
971
+ *
972
+ * For stage/test environment, use: https://stage.generalauthservice.com
973
+ */
974
+ oauthToolUrl?: string;
975
+ /**
976
+ * WalletConnect Project ID
977
+ *
978
+ * Required for WalletConnect functionality.
979
+ * Get your project ID at https://cloud.walletconnect.com
980
+ *
981
+ * If not provided, WalletConnect option will be disabled in the wallet dialog.
982
+ */
983
+ walletConnectProjectId?: string;
984
+ }
985
+
986
+ export declare interface TaskOnProviderProps {
987
+ /**
988
+ * TaskOn configuration object
989
+ */
990
+ config: TaskOnProviderConfig;
991
+ /**
992
+ * Child components
993
+ */
994
+ children: ReactNode;
995
+ /**
996
+ * List of widgets to preload locales for
997
+ */
998
+ preloadLocales?: WidgetName[];
999
+ }
1000
+
1001
+ /**
1002
+ * Resolved theme object (returned by useTaskOnTheme)
1003
+ */
1004
+ export declare interface TaskOnTheme {
1005
+ /** Current mode (resolved, never "auto") */
1006
+ mode: "light" | "dark";
1007
+ /** Whether compact mode is enabled */
1008
+ compact: boolean;
1009
+ /** All tokens (resolved) */
1010
+ tokens: Required<MapToken>;
1011
+ }
1012
+
1013
+ /**
1014
+ * Theme configuration
1015
+ */
1016
+ export declare interface TaskOnThemeConfig {
1017
+ /** Theme mode */
1018
+ mode?: ThemeMode;
1019
+ /** Compact mode */
1020
+ compact?: boolean;
1021
+ /** Seed tokens */
1022
+ seed?: SeedToken;
1023
+ /** Map tokens (override derived values) */
1024
+ map?: MapToken;
1025
+ /** Light mode specific configuration */
1026
+ light?: ModeThemeConfig;
1027
+ /** Dark mode specific configuration */
1028
+ dark?: ModeThemeConfig;
1029
+ }
1030
+
1031
+ /**
1032
+ * TemplateTask 组件
1033
+ *
1034
+ * @description 通用模版任务组件,负责:
1035
+ * - 解析 task.template.params 获取任务参数
1036
+ * - 使用 BaseTask 展示任务卡片
1037
+ * - 渲染描述字段(desc、desc_fields)
1038
+ * - 处理 Action 按钮(action_label、action_link)
1039
+ *
1040
+ * @example
1041
+ * ```tsx
1042
+ * <TemplateTask
1043
+ * task={taskInfo}
1044
+ * userStatus={userStatus}
1045
+ * onClick={() => console.log('卡片点击')}
1046
+ * onClaim={() => console.log('Claim 点击')}
1047
+ * />
1048
+ * ```
1049
+ */
1050
+ export declare function TemplateTask({ task, userStatus, meetConditions, communityInfo, disabled, onClick, onClaim, onUpdate, onEligTaskClick, coolDown: sharedCoolDown, onCoolDownComplete: sharedOnCoolDownComplete, }: TemplateTaskProps): default_2.ReactElement;
1051
+
1052
+ /**
1053
+ * TemplateTask 组件属性
1054
+ */
1055
+ export declare interface TemplateTaskProps {
1056
+ /** 任务信息 */
1057
+ task: CommunityTaskInfo;
1058
+ /** 用户状态 */
1059
+ userStatus?: GtcUserTaskStatus;
1060
+ /** 资格条件列表(有值时显示遮罩) */
1061
+ meetConditions?: MeetCondition[];
1062
+ /** 社区信息(用于前置任务链接跳转) */
1063
+ communityInfo?: {
1064
+ community_key?: string;
1065
+ dapp_domain?: string;
1066
+ };
1067
+ /** 是否禁用交互 */
1068
+ disabled?: boolean;
1069
+ /** 点击卡片回调 */
1070
+ onClick?: () => void;
1071
+ /**
1072
+ * 点击 Claim 回调
1073
+ * @param token 可选的 OAuth token(reAuth 成功后传入)
1074
+ */
1075
+ onClaim?: (token?: string) => void | Promise<{
1076
+ successful: boolean;
1077
+ errorCode?: string;
1078
+ cool_down?: number;
1079
+ }>;
1080
+ /** 任务更新回调(完成/验证成功后) */
1081
+ onUpdate?: () => void;
1082
+ /** 点击资格条件中的前置任务回调(用于打开任务弹窗) */
1083
+ onEligTaskClick?: (taskId: number) => void;
1084
+ /** 共享的 coolDown 值(来自父组件) */
1085
+ coolDown?: number;
1086
+ /** coolDown 倒计时结束回调 */
1087
+ onCoolDownComplete?: () => void;
1088
+ }
1089
+
1090
+ /**
1091
+ * Translation function type
1092
+ */
1093
+ export declare type TFunction<T> = <K extends keyof T>(key: K, params?: InterpolationParams) => string;
1094
+
1095
+ /**
1096
+ * Theme mode
1097
+ * - light: Light mode
1098
+ * - dark: Dark mode
1099
+ * - auto: Follow system preference
1100
+ */
1101
+ export declare type ThemeMode = "light" | "dark" | "auto";
1102
+
1103
+ /**
1104
+ * Theme Provider Component
1105
+ *
1106
+ * Provides theme configuration with support for:
1107
+ * - light/dark/auto modes
1108
+ * - Seed token derivation
1109
+ * - Map token overrides
1110
+ *
1111
+ * @example
1112
+ * ```tsx
1113
+ * <ThemeProvider theme={{ mode: 'dark', seed: { colorPrimary: '#6366f1' } }}>
1114
+ * <App />
1115
+ * </ThemeProvider>
1116
+ * ```
1117
+ */
1118
+ export declare function ThemeProvider({ theme: themeConfig, children, }: ThemeProviderProps): ReactNode;
1119
+
1120
+ /**
1121
+ * ThemeProvider Props
1122
+ */
1123
+ export declare interface ThemeProviderProps {
1124
+ /** Theme configuration */
1125
+ theme?: TaskOnThemeConfig;
1126
+ /** Child components */
1127
+ children: React.ReactNode;
1128
+ }
1129
+
1130
+ /**
1131
+ * Hook for loading common locale messages
1132
+ *
1133
+ * @returns Object containing common messages and loading state
1134
+ *
1135
+ * @example
1136
+ * ```tsx
1137
+ * function MyWidget() {
1138
+ * const { messages: common, isLoading } = useCommonLocale();
1139
+ *
1140
+ * if (isLoading) return <div>{common.loading}</div>;
1141
+ *
1142
+ * return <button onClick={retry}>{common.retry}</button>;
1143
+ * }
1144
+ * ```
1145
+ */
1146
+ export declare function useCommonLocale(): UseWidgetLocaleResult<CommonMessages>;
1147
+
1148
+ /**
1149
+ * Hook to access EVM wallet
1150
+ */
1151
+ export declare function useEvmWallet(): {
1152
+ adapter: WalletAdapter | null;
1153
+ address: string | null;
1154
+ chainId: number | null;
1155
+ isConnected: boolean;
1156
+ connect: () => Promise<string | null>;
1157
+ disconnect: () => Promise<void>;
1158
+ signMessage: (message: string) => Promise<string | null>;
1159
+ };
1160
+
1161
+ /**
1162
+ * 获取 Quest 详情 Hook
1163
+ *
1164
+ * @param options Hook 配置(包含从根组件传入的 api 实例)
1165
+ * @returns Quest 详情、加载状态、错误信息、重新加载方法
1166
+ */
1167
+ export declare function useQuestDetail(options: UseQuestDetailOptions): UseQuestDetailReturn;
1168
+
1169
+ /**
1170
+ * useQuestDetail Hook 参数
1171
+ */
1172
+ declare interface UseQuestDetailOptions {
1173
+ /** Quest API 实例(从根组件传入) */
1174
+ api: QuestApi | null;
1175
+ /** Campaign ID */
1176
+ campaignId: number;
1177
+ /** 渠道标识(可选) */
1178
+ channel?: string;
1179
+ /** KOL 标识(可选) */
1180
+ kolHandle?: string;
1181
+ /** 邀请码(可选) */
1182
+ inviteCode?: string;
1183
+ /** Boost ID(可选) */
1184
+ boostId?: number;
1185
+ /** 是否启用(默认 true) */
1186
+ enabled?: boolean;
1187
+ }
1188
+
1189
+ /**
1190
+ * useQuestDetail Hook 返回值
1191
+ */
1192
+ declare interface UseQuestDetailReturn {
1193
+ /** Campaign 详情数据 */
1194
+ data: QuestCampaignInfo | null;
1195
+ /** 是否加载中 */
1196
+ isLoading: boolean;
1197
+ /** 错误信息 */
1198
+ error: string | null;
1199
+ /** 重新加载 */
1200
+ refetch: () => void;
1201
+ }
1202
+
1203
+ /**
1204
+ * 获取 Quest 状态信息 Hook
1205
+ *
1206
+ * @param options Hook 配置(包含从根组件传入的 api 实例)
1207
+ * @returns Quest 状态、加载状态、错误信息、重新加载方法
1208
+ */
1209
+ export declare function useQuestStatus(options: UseQuestStatusOptions): UseQuestStatusReturn;
1210
+
1211
+ /**
1212
+ * useQuestStatus Hook 参数
1213
+ */
1214
+ declare interface UseQuestStatusOptions {
1215
+ /** Quest API 实例(从根组件传入) */
1216
+ api: QuestApi | null;
1217
+ /** Campaign ID */
1218
+ campaignId: number;
1219
+ /** 渠道标识 */
1220
+ channel?: string;
1221
+ /** KOL 句柄 */
1222
+ kolHandle?: string;
1223
+ /** 是否启用(默认 true) */
1224
+ enabled?: boolean;
1225
+ }
1226
+
1227
+ /**
1228
+ * useQuestStatus Hook 返回值
1229
+ */
1230
+ declare interface UseQuestStatusReturn {
1231
+ /** Campaign 状态数据 */
1232
+ data: CampaignStatusInfo | null;
1233
+ /** 是否加载中 */
1234
+ isLoading: boolean;
1235
+ /** 错误信息 */
1236
+ error: string | null;
1237
+ /** 重新加载 */
1238
+ refetch: () => void;
1239
+ }
1240
+
1241
+ /**
1242
+ * 获取用户 Quest 状态 Hook
1243
+ *
1244
+ * @param options Hook 配置(包含从根组件传入的 api 实例)
1245
+ * @returns 用户状态、加载状态、错误信息、重新加载方法
1246
+ */
1247
+ export declare function useQuestUserStatus(options: UseQuestUserStatusOptions): UseQuestUserStatusReturn;
1248
+
1249
+ /**
1250
+ * useQuestUserStatus Hook 参数
1251
+ */
1252
+ declare interface UseQuestUserStatusOptions {
1253
+ /** Quest API 实例(从根组件传入) */
1254
+ api: QuestApi | null;
1255
+ /** Campaign ID */
1256
+ campaignId: number;
1257
+ /** 渠道标识(可选) */
1258
+ channel?: string;
1259
+ /** KOL 标识(可选) */
1260
+ kolHandle?: string;
1261
+ /** 是否启用(默认 true) */
1262
+ enabled?: boolean;
1263
+ }
1264
+
1265
+ /**
1266
+ * useQuestUserStatus Hook 返回值
1267
+ */
1268
+ declare interface UseQuestUserStatusReturn {
1269
+ /** 用户状态数据 */
1270
+ data: UserCampaignStatusInfo | null;
1271
+ /** 是否加载中 */
1272
+ isLoading: boolean;
1273
+ /** 错误信息 */
1274
+ error: string | null;
1275
+ /** 重新加载 */
1276
+ refetch: () => void;
1277
+ /**
1278
+ * 立即更新指定任务的本地状态(乐观更新)
1279
+ * @param taskId 任务 ID
1280
+ * @param isAsync 是否为异步任务(异步任务只更新 is_submitter)
1281
+ */
1282
+ updateTaskStatus: (taskId: number, isAsync?: boolean) => void;
1283
+ }
1284
+
1285
+ /**
1286
+ * UserCenterWidget 外层组件
1287
+ *
1288
+ * Handles cloud config loading + ThemeProvider wrapping via WidgetShell.
1289
+ * Merges cloud function config with local props, then renders inner component.
1290
+ *
1291
+ * @example
1292
+ * ```tsx
1293
+ * // Pure props mode (existing behavior)
1294
+ * <UserCenterWidget config={tabConfig} />
1295
+ *
1296
+ * // Pure widgetId mode (config from cloud)
1297
+ * <UserCenterWidget widgetId={456} />
1298
+ *
1299
+ * // Mixed mode (props override cloud)
1300
+ * <UserCenterWidget widgetId={456} defaultTab={UserCenterTabType.Identity} />
1301
+ * ```
1302
+ */
1303
+ export declare function UserCenterWidget(props: UserCenterWidgetProps): default_2.ReactElement;
1304
+
1305
+ /**
1306
+ * UserCenterWidget 属性
1307
+ */
1308
+ export declare interface UserCenterWidgetProps {
1309
+ /**
1310
+ * Widget ID - load configuration (theme + function) from cloud
1311
+ * Cloud config provides tab options, display settings, etc.
1312
+ */
1313
+ widgetId?: number;
1314
+ /** Widget 配置 */
1315
+ config?: UserCenterConfig;
1316
+ /** 默认选中的 Tab */
1317
+ defaultTab?: UserCenterTabType;
1318
+ /** Tab 切换回调 */
1319
+ onTabChange?: (tab: UserCenterTabType) => void;
1320
+ /** 自定义类名 */
1321
+ className?: string;
1322
+ /** 自定义样式 */
1323
+ style?: default_2.CSSProperties;
1324
+ }
1325
+
1326
+ export { UserInfo }
1327
+
1328
+ /**
1329
+ * Public hook for TaskOn authentication
1330
+ *
1331
+ * @example
1332
+ * ```tsx
1333
+ * const { login, logout, userId, isLoggedIn, requestLogin } = useTaskOnAuth();
1334
+ *
1335
+ * // EVM wallet login
1336
+ * await login({ method: 'evm_wallet', value: '0x...', sign, timestamp });
1337
+ *
1338
+ * // Email login
1339
+ * await login({ method: 'email', value: 'user@example.com', sign, timestamp });
1340
+ *
1341
+ * // Discord login
1342
+ * await login({ method: 'discord', value: oauthToken, sign, timestamp });
1343
+ *
1344
+ * // Request login (triggers config.onRequestLogin)
1345
+ * requestLogin();
1346
+ * ```
1347
+ */
1348
+ export declare function useTaskOnAuth(): {
1349
+ userId: number | null;
1350
+ isLoggedIn: boolean;
1351
+ isInitializing: boolean;
1352
+ login: (params: LoginParams) => Promise<void>;
1353
+ logout: () => void;
1354
+ requestLogin: () => void;
1355
+ };
1356
+
1357
+ /**
1358
+ * Get current theme
1359
+ * Must be used within a ThemeProvider
1360
+ */
1361
+ export declare function useTaskOnTheme(): TaskOnTheme;
1362
+
1363
+ /**
1364
+ * Hook for widget translations with interpolation support
1365
+ *
1366
+ * This is a higher-level hook that wraps useWidgetLocale and adds
1367
+ * a `t` function for convenient string interpolation.
1368
+ *
1369
+ * @template T - The shape of the messages object
1370
+ * @param options - Same options as useWidgetLocale
1371
+ * @returns Object containing t function, messages, and loading state
1372
+ *
1373
+ * @example
1374
+ * ```tsx
1375
+ * // messages/en.ts
1376
+ * export default {
1377
+ * greeting: 'Hello, {name}!',
1378
+ * points: 'You have {count} points',
1379
+ * title: 'Task Widget',
1380
+ * };
1381
+ *
1382
+ * // Component
1383
+ * function TaskWidget() {
1384
+ * const { t, isLoading } = useTranslation({
1385
+ * widgetId: 'TaskWidget',
1386
+ * defaultMessages: enMessages,
1387
+ * loadMessages,
1388
+ * });
1389
+ *
1390
+ * if (isLoading) return <div>Loading...</div>;
1391
+ *
1392
+ * return (
1393
+ * <div>
1394
+ * <h1>{t('title')}</h1>
1395
+ * <p>{t('greeting', { name: 'John' })}</p>
1396
+ * <p>{t('points', { count: 100 })}</p>
1397
+ * </div>
1398
+ * );
1399
+ * }
1400
+ * ```
1401
+ */
1402
+ export declare function useTranslation<T>(options: UseWidgetLocaleOptions<T>): UseTranslationResult<T>;
1403
+
1404
+ /**
1405
+ * Return type for useTranslation hook
1406
+ */
1407
+ export declare interface UseTranslationResult<T> {
1408
+ /**
1409
+ * Translation function with interpolation support
1410
+ *
1411
+ * @example
1412
+ * ```ts
1413
+ * t('greeting', { name: 'John' }) // => 'Hello, John!'
1414
+ * t('points', { count: 100 }) // => 'You have 100 points'
1415
+ * ```
1416
+ */
1417
+ t: TFunction<T>;
1418
+ /**
1419
+ * Raw messages object (without interpolation)
1420
+ * Useful when you need direct access to message strings
1421
+ */
1422
+ messages: T;
1423
+ /**
1424
+ * Whether translations are currently loading
1425
+ */
1426
+ isLoading: boolean;
1427
+ }
1428
+
1429
+ /**
1430
+ * Hook to access wallet context
1431
+ * Returns wallet state and actions for EVM
1432
+ *
1433
+ * @example
1434
+ * ```tsx
1435
+ * const { evmAddress, isEvmConnected, connectEvm, signEvmMessage } = useWallet();
1436
+ *
1437
+ * // Connect EVM wallet
1438
+ * const address = await connectEvm();
1439
+ *
1440
+ * // Sign message
1441
+ * const signature = await signEvmMessage("Hello World");
1442
+ * ```
1443
+ */
1444
+ export declare function useWallet(): WalletContextValue;
1445
+
1446
+ /**
1447
+ * Hook for loading widget-specific locale messages
1448
+ *
1449
+ * @template T - The shape of the messages object
1450
+ * @param options - Configuration options
1451
+ * @param options.defaultMessages - English messages (inlined, no loading needed)
1452
+ * @param options.loadMessages - Function to dynamically import other locales
1453
+ * @returns Object containing messages and loading state
1454
+ *
1455
+ * @example
1456
+ * ```tsx
1457
+ * import enMessages from './locales/en';
1458
+ *
1459
+ * function TaskWidget() {
1460
+ * const { messages, isLoading } = useWidgetLocale({
1461
+ * defaultMessages: enMessages,
1462
+ * loadMessages: (locale) => import(`./locales/${locale}.ts`),
1463
+ * });
1464
+ *
1465
+ * if (isLoading) return <div>Loading...</div>;
1466
+ *
1467
+ * return <button>{messages.claim}</button>;
1468
+ * }
1469
+ * ```
1470
+ */
1471
+ export declare function useWidgetLocale<T>(options: UseWidgetLocaleOptions<T>): UseWidgetLocaleResult<T>;
1472
+
1473
+ /**
1474
+ * Options for useWidgetLocale hook
1475
+ *
1476
+ * @template T - The shape of the messages object
1477
+ */
1478
+ export declare interface UseWidgetLocaleOptions<T> {
1479
+ /**
1480
+ * Unique identifier for this widget
1481
+ * Used as cache key prefix to avoid conflicts between widgets
1482
+ *
1483
+ * @example "TaskWidget", "WalletWidget"
1484
+ */
1485
+ widgetId: string;
1486
+ /**
1487
+ * Default messages (English) - inlined in bundle
1488
+ * These are used immediately without any loading
1489
+ */
1490
+ defaultMessages: T;
1491
+ /**
1492
+ * Function to dynamically load messages for other locales
1493
+ * Should return a dynamic import promise
1494
+ *
1495
+ * @example
1496
+ * ```ts
1497
+ * loadMessages: (locale) => import(`./locales/${locale}.ts`)
1498
+ * ```
1499
+ */
1500
+ loadMessages: (locale: Locale) => Promise<{
1501
+ default: T;
1502
+ }>;
1503
+ }
1504
+
1505
+ /**
1506
+ * Return type for useWidgetLocale hook
1507
+ *
1508
+ * @template T - The shape of the messages object
1509
+ */
1510
+ export declare interface UseWidgetLocaleResult<T> {
1511
+ /**
1512
+ * Current messages object based on active locale
1513
+ * Falls back to default (English) messages if loading fails
1514
+ */
1515
+ messages: T;
1516
+ /**
1517
+ * Whether the locale messages are currently loading
1518
+ * Only true when switching to a non-default locale
1519
+ */
1520
+ isLoading: boolean;
1521
+ }
1522
+
1523
+ /**
1524
+ * Wallet adapter interface for blockchain interactions
1525
+ *
1526
+ * This interface abstracts wallet operations, allowing widgets to work with
1527
+ * different wallet providers (custom implementations or built-in adapters)
1528
+ */
1529
+ export declare interface WalletAdapter {
1530
+ /**
1531
+ * Connect to wallet and return the connected address
1532
+ * Should open wallet selection UI if needed
1533
+ */
1534
+ connect: () => Promise<string>;
1535
+ /**
1536
+ * Disconnect from wallet
1537
+ */
1538
+ disconnect: () => Promise<void>;
1539
+ /**
1540
+ * Sign a message with the connected wallet
1541
+ * @param message - The message to sign
1542
+ * @returns The signature
1543
+ */
1544
+ signMessage: (message: string) => Promise<string>;
1545
+ /**
1546
+ * Get the currently connected address
1547
+ * @returns The address or null if not connected
1548
+ */
1549
+ getAddress: () => string | null;
1550
+ /**
1551
+ * Get the current chain ID
1552
+ * @returns The chain ID or null if not available
1553
+ */
1554
+ getChainId?: () => number | null;
1555
+ /**
1556
+ * Switch to a different network
1557
+ * @param chainId - The target chain ID
1558
+ */
1559
+ switchNetwork?: (chainId: number) => Promise<void>;
1560
+ /**
1561
+ * Invoke a smart contract method
1562
+ * @param params - Contract invocation parameters
1563
+ * @returns Transaction hash
1564
+ */
1565
+ invokeContract?: (params: InvokeContractParams) => Promise<string>;
1566
+ /**
1567
+ * Get wallet's native token balance (for gas estimation)
1568
+ * @returns Balance in wei (string)
1569
+ */
1570
+ getBalance?: () => Promise<string>;
1571
+ /**
1572
+ * Subscribe to account changes
1573
+ * @param callback - Called when account changes
1574
+ * @returns Unsubscribe function
1575
+ */
1576
+ onAccountChange?: (callback: (address: string | null) => void) => () => void;
1577
+ /**
1578
+ * Subscribe to chain/network changes
1579
+ * @param callback - Called when chain changes
1580
+ * @returns Unsubscribe function
1581
+ */
1582
+ onChainChange?: (callback: (chainId: number) => void) => () => void;
1583
+ }
1584
+
1585
+ /**
1586
+ * Wallet configuration for TaskOnProvider
1587
+ */
1588
+ export declare interface WalletConfig {
1589
+ /**
1590
+ * Custom EVM wallet adapter
1591
+ * If not provided, uses built-in window.ethereum adapter
1592
+ */
1593
+ evmAdapter?: WalletAdapter;
1594
+ /**
1595
+ * Disable auto-detection of wallet providers
1596
+ * When true, only uses adapter explicitly provided above
1597
+ * @default false
1598
+ */
1599
+ disableAutoDetect?: boolean;
1600
+ }
1601
+
1602
+ /**
1603
+ * Wallet context value type
1604
+ */
1605
+ declare interface WalletContextValue extends WalletState {
1606
+ connectEvm: () => Promise<string | null>;
1607
+ disconnectEvm: () => Promise<void>;
1608
+ signEvmMessage: (message: string) => Promise<string | null>;
1609
+ }
1610
+
1611
+ /**
1612
+ * Wallet state exposed through context
1613
+ */
1614
+ export declare interface WalletState {
1615
+ evmAdapter: WalletAdapter | null;
1616
+ evmAddress: string | null;
1617
+ evmChainId: number | null;
1618
+ isEvmConnected: boolean;
1619
+ isDetecting: boolean;
1620
+ }
1621
+
1622
+ /**
1623
+ * Supported widget names for preloading
1624
+ */
1625
+ export declare type WidgetName = "CommunityTask";
1626
+
1627
+ export { }