@taskon/widget-react 0.0.1-beta.5 → 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 (65) hide show
  1. package/README.md +61 -47
  2. package/dist/CommunityTaskList.css +9 -1
  3. package/dist/EligibilityInfo.css +48 -75
  4. package/dist/LeaderboardWidget.css +73 -71
  5. package/dist/PageBuilder.css +5 -0
  6. package/dist/Quest.css +18 -14
  7. package/dist/TaskOnProvider.css +289 -0
  8. package/dist/ThemeProvider.css +227 -0
  9. package/dist/UserCenterWidget.css +6 -6
  10. package/dist/UserCenterWidget2.css +1388 -1621
  11. package/dist/{dynamic-import-helper.css → WidgetShell.css} +0 -227
  12. package/dist/chunks/{CommunityTaskList-CrMvOB8w.js → CommunityTaskList-D0uVD8wD.js} +393 -208
  13. package/dist/chunks/{EligibilityInfo-Beww12QX.js → EligibilityInfo-Cf6hx9-a.js} +459 -679
  14. package/dist/chunks/{LeaderboardWidget-DwuSpVl0.js → LeaderboardWidget-DyoiiNS6.js} +274 -252
  15. package/dist/chunks/{PageBuilder-DsX6Tv0N.js → PageBuilder-DoAFPm6-.js} +5 -5
  16. package/dist/chunks/{Quest-CuD2LElS.js → Quest-ySZlYd4u.js} +74 -57
  17. package/dist/chunks/TaskOnProvider-CxtFIs3n.js +2072 -0
  18. package/dist/chunks/{dynamic-import-helper-WmIF58Sb.js → ThemeProvider-CulHkqqY.js} +1282 -555
  19. package/dist/chunks/UserCenterWidget-BJsc_GSZ.js +3246 -0
  20. package/dist/chunks/{UserCenterWidget-CvU6K4AC.js → UserCenterWidget-STq8kpV4.js} +1174 -1386
  21. package/dist/chunks/WidgetShell-8xn-Jivw.js +659 -0
  22. package/dist/chunks/communitytask-es-CBNnS4o2.js +521 -0
  23. package/dist/chunks/communitytask-ja-GRf9cbdx.js +521 -0
  24. package/dist/chunks/communitytask-ko-Bf24PQKI.js +521 -0
  25. package/dist/chunks/{communitytask-ru-DhySaZL8.js → communitytask-ru-CZm2CPoV.js} +211 -1
  26. package/dist/chunks/leaderboardwidget-es-vKjrjQaz.js +146 -0
  27. package/dist/chunks/leaderboardwidget-ja-Q6u0HxKG.js +146 -0
  28. package/dist/chunks/leaderboardwidget-ko-CG6SWgxf.js +146 -0
  29. package/dist/chunks/leaderboardwidget-ru-DCcHcJGz.js +146 -0
  30. package/dist/chunks/{quest-es-D-b5xcme.js → quest-es-Dyyy0zaw.js} +8 -93
  31. package/dist/chunks/{quest-ja-Dxd2vqBF.js → quest-ja-Depog33y.js} +8 -93
  32. package/dist/chunks/{quest-ko-CSmRWgK_.js → quest-ko-BMu3uRQJ.js} +8 -93
  33. package/dist/chunks/{quest-ru-CkEKv1_F.js → quest-ru-xne814Rw.js} +8 -93
  34. package/dist/chunks/useIsMobile-D6Ybur-6.js +30 -0
  35. package/dist/chunks/useToast-BGJhd3BX.js +93 -0
  36. package/dist/chunks/usercenter-es-Dz3Wp2vV.js +512 -0
  37. package/dist/chunks/usercenter-ja-CKE4DJC6.js +512 -0
  38. package/dist/chunks/usercenter-ko-Dtpkn2qb.js +512 -0
  39. package/dist/chunks/usercenter-ru-DnBGee45.js +512 -0
  40. package/dist/community-task.d.ts +0 -390
  41. package/dist/community-task.js +2 -7
  42. package/dist/core.d.ts +38 -20
  43. package/dist/core.js +9 -10
  44. package/dist/index.d.ts +86 -709
  45. package/dist/index.js +22 -28
  46. package/dist/leaderboard.d.ts +0 -498
  47. package/dist/leaderboard.js +2 -16
  48. package/dist/page-builder.js +1 -1
  49. package/dist/quest.d.ts +0 -971
  50. package/dist/quest.js +2 -7
  51. package/dist/user-center.d.ts +0 -1610
  52. package/dist/user-center.js +2 -494
  53. package/package.json +2 -2
  54. package/dist/chunks/TaskOnProvider-xUeP2Nro.js +0 -1243
  55. package/dist/chunks/ThemeProvider-Bt4UZ33y.js +0 -1334
  56. package/dist/chunks/UserCenterWidget-CB0hnj-L.js +0 -3230
  57. package/dist/chunks/communitytask-es-1zawvXEX.js +0 -311
  58. package/dist/chunks/communitytask-ja-CmW6nP-L.js +0 -311
  59. package/dist/chunks/communitytask-ko-BD0hzQSi.js +0 -311
  60. package/dist/chunks/createLocaleLoader-BameiEhU.js +0 -65
  61. package/dist/chunks/leaderboardwidget-ja-Bj6gz6y1.js +0 -119
  62. package/dist/chunks/leaderboardwidget-ko-f1cLO9ic.js +0 -119
  63. package/dist/chunks/useToast-CaRkylKe.js +0 -304
  64. package/dist/chunks/usercenter-ja-B2465c1O.js +0 -326
  65. package/dist/chunks/usercenter-ko-xAEYxqLg.js +0 -326
@@ -1,11 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useState, useEffect, useMemo, useRef } from "react";
3
3
  import { DEFAULT_PAGE_BUILDER_CONFIG, createPageBuilderApi, parsePageBuilderConfig, SectionLayoutType, WidgetTypeEnum, SECTION_LAYOUT_RATIOS } from "@taskon/core";
4
- import { Q as QuestWidget } from "./Quest-CuD2LElS.js";
5
- import { a as CommunityTaskList } from "./CommunityTaskList-CrMvOB8w.js";
6
- import { L as LeaderboardWidget } from "./LeaderboardWidget-DwuSpVl0.js";
7
- import { U as UserCenterWidget } from "./UserCenterWidget-CB0hnj-L.js";
8
- import { d as useTaskOnContext } from "./ThemeProvider-Bt4UZ33y.js";
4
+ import { Q as QuestWidget } from "./Quest-ySZlYd4u.js";
5
+ import { C as CommunityTaskList } from "./CommunityTaskList-D0uVD8wD.js";
6
+ import { L as LeaderboardWidget } from "./LeaderboardWidget-DyoiiNS6.js";
7
+ import { U as UserCenterWidget } from "./UserCenterWidget-BJsc_GSZ.js";
8
+ import { h as useTaskOnContext } from "./ThemeProvider-CulHkqqY.js";
9
9
  import '../PageBuilder.css';function usePageBuilderConfig(pageId, localConfig) {
10
10
  const { client } = useTaskOnContext();
11
11
  const [config, setConfig] = useState(
@@ -1,11 +1,11 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import React__default, { useState, useMemo, useCallback, useEffect, useRef } from "react";
3
3
  import { RewardType, UserEligibleStatus, EligibilityTemplateId, SnsType, ChainType, QuestAutomaticallyWinnerDrawType, QuestWinnerDrawType, QuestWinnerRangeType, createQuestApi, QuestRewardsDistributeType, QuestRewardType, createLeaderboardApi, MediaType, RewardDistributedByType, ApiError, ErrorCode, CampaignType } from "@taskon/core";
4
- import { t as useTaskOnPortalContainer, d as useTaskOnContext } from "./ThemeProvider-Bt4UZ33y.js";
5
- import { f as useTaskWidgetLocale, d as TaskItem, u as useQuestLocale, I as I18nT, g as EligibilityList, h as getDefaultExportFromCjs, s as sanitizeHtml, R as RewardModuleDialog, C as ConfirmNoticeDialog, a as useBindWallet, c as useNftClaimFlow, E as EligibilityInfo, B as BlindBoxDialog } from "./EligibilityInfo-Beww12QX.js";
6
- import { D as Dialog, B as Button, T as Table, P as Pagination, a as useResolvedWidgetConfig, W as WidgetShell } from "./dynamic-import-helper-WmIF58Sb.js";
7
- import { d as useToast } from "./useToast-CaRkylKe.js";
8
- import { R as Root2, o as Trigger, p as Portal, q as Content2, v as InfoIcon, r as Arrow2, s as TipPopover, g as useBindSocialAccount } from "./UserCenterWidget-CvU6K4AC.js";
4
+ import { D as Dialog, E as useTaskOnPortalContainer, h as useTaskOnContext } from "./ThemeProvider-CulHkqqY.js";
5
+ import { d as useTaskWidgetLocale, b as TaskItem, e as useQuestLocale, I as I18nT, f as EligibilityList, g as getDefaultExportFromCjs, s as sanitizeHtml, R as RewardModuleDialog, h as ConfirmNoticeDialog, u as useBindWallet, a as useNftClaimFlow, E as EligibilityInfo, B as BlindBoxDialog } from "./EligibilityInfo-Cf6hx9-a.js";
6
+ import { B as Button, T as Table, P as Pagination, u as useResolvedWidgetConfig, W as WidgetShell } from "./WidgetShell-8xn-Jivw.js";
7
+ import { c as useToast } from "./useToast-BGJhd3BX.js";
8
+ import { R as Root2, h as Trigger, i as Portal, C as Content2, q as InfoIcon, j as Arrow2, p as TipPopover, a as useBindSocialAccount } from "./UserCenterWidget-STq8kpV4.js";
9
9
  import '../Quest.css';function ButtonTabs({
10
10
  items,
11
11
  activeKey,
@@ -143,6 +143,7 @@ function GreenCheckIcon() {
143
143
  function CompletedCount({
144
144
  current,
145
145
  total,
146
+ completedLabel = "Completed",
146
147
  className
147
148
  }) {
148
149
  const isAllCompleted = current >= total && total > 0;
@@ -153,7 +154,8 @@ function CompletedCount({
153
154
  /* @__PURE__ */ jsx("span", { className: current > 0 ? "taskon-completed-count-em" : "", children: current }),
154
155
  "/",
155
156
  total,
156
- ") Completed"
157
+ ") ",
158
+ completedLabel
157
159
  ] })
158
160
  ] });
159
161
  }
@@ -225,7 +227,8 @@ function TaskList({
225
227
  CompletedCount,
226
228
  {
227
229
  current: completionStatus.mandatoryCompleted,
228
- total: completionStatus.mandatoryTotal
230
+ total: completionStatus.mandatoryTotal,
231
+ completedLabel: t("completed")
229
232
  }
230
233
  )
231
234
  ] }),
@@ -281,7 +284,8 @@ function TaskList({
281
284
  CompletedCount,
282
285
  {
283
286
  current: completionStatus.optionalCompleted,
284
- total: completionStatus.optionalTotal
287
+ total: completionStatus.optionalTotal,
288
+ completedLabel: t("completed")
285
289
  }
286
290
  )
287
291
  ] }),
@@ -804,7 +808,14 @@ function useQuestDetail(options) {
804
808
  }
805
809
  function useQuestUserStatus(options) {
806
810
  const { t } = useQuestLocale();
807
- const { api, campaignId, channel, kolHandle, enabled = true } = options;
811
+ const {
812
+ api,
813
+ campaignId,
814
+ channel,
815
+ kolHandle,
816
+ enabled = true,
817
+ authToken
818
+ } = options;
808
819
  const [data, setData] = useState(null);
809
820
  const [isLoading, setIsLoading] = useState(false);
810
821
  const [error, setError] = useState(null);
@@ -830,7 +841,7 @@ function useQuestUserStatus(options) {
830
841
  } finally {
831
842
  setIsLoading(false);
832
843
  }
833
- }, [enabled, api, campaignId, channel, kolHandle, t]);
844
+ }, [enabled, api, campaignId, channel, kolHandle, authToken, t]);
834
845
  const updateTaskStatus = useCallback(
835
846
  (taskId, isAsync = false) => {
836
847
  setData((prev) => {
@@ -7507,7 +7518,7 @@ function CompleteButton({
7507
7518
  if (!client) return null;
7508
7519
  return createQuestApi(client);
7509
7520
  }, [client]);
7510
- const buttonText = hasPointProportionally2 ? t("complete_qualify_rewards") : t("complete_2");
7521
+ const buttonText = hasPointProportionally2 ? t("complete_qualify_rewards") : t("complete");
7511
7522
  const handleComplete = useCallback(async () => {
7512
7523
  if (!api || isLoading || disabled) {
7513
7524
  return;
@@ -7650,7 +7661,7 @@ function OperateFooter(props) {
7650
7661
  {
7651
7662
  className: "taskon-quest-footer-connect-btn",
7652
7663
  onClick: onConnectWallet,
7653
- children: t("connect_wallet_participate")
7664
+ children: t("start_to_earn")
7654
7665
  }
7655
7666
  ) });
7656
7667
  const handleCompleteError = useCallback(
@@ -8194,7 +8205,7 @@ function ArrowUpRightIcon() {
8194
8205
  }
8195
8206
  function formatDateShort(timestamp) {
8196
8207
  const date = new Date(timestamp);
8197
- return new Intl.DateTimeFormat(void 0, {
8208
+ return new Intl.DateTimeFormat("en-US", {
8198
8209
  month: "short",
8199
8210
  day: "2-digit"
8200
8211
  }).format(date);
@@ -8241,9 +8252,9 @@ function WinnersStatus({
8241
8252
  if (discordLink) return discordLink;
8242
8253
  return void 0;
8243
8254
  }, [discordLink]);
8244
- const handleWinnersVisibleChange = (visible) => {
8255
+ const handleWinnersVisibleChange = useCallback((visible) => {
8245
8256
  setHasWinners(visible);
8246
- };
8257
+ }, []);
8247
8258
  return /* @__PURE__ */ jsxs("div", { className: `taskon-winners ${className}`, children: [
8248
8259
  isWaitingReviewPow && (powReviewLink ? /* @__PURE__ */ jsxs(
8249
8260
  "a",
@@ -8501,7 +8512,15 @@ function QuestWidgetInner(props) {
8501
8512
  rewardDisplayMode,
8502
8513
  rewardRedirectUrl
8503
8514
  } = props;
8504
- const { client, chains, isLoggedIn, userInfo, requestLogin, communityInfo } = useTaskOnContext();
8515
+ const {
8516
+ client,
8517
+ chains,
8518
+ isLoggedIn,
8519
+ userInfo,
8520
+ userToken,
8521
+ requestLogin,
8522
+ communityInfo
8523
+ } = useTaskOnContext();
8505
8524
  const { toast } = useToast();
8506
8525
  const questNftClaimMessages = useMemo(
8507
8526
  () => createQuestNftClaimMessages(t),
@@ -8525,9 +8544,7 @@ function QuestWidgetInner(props) {
8525
8544
  const { bindAndWait: bindChainAndWait } = useBindWallet({
8526
8545
  onFailed: (error2) => {
8527
8546
  toast.error(error2);
8528
- },
8529
- // 当没有 adapter 时触发外部弹窗(如果配置了的话)
8530
- onNeedWalletDialog: onConnectWallet
8547
+ }
8531
8548
  });
8532
8549
  const {
8533
8550
  data: campaign,
@@ -8553,7 +8570,8 @@ function QuestWidgetInner(props) {
8553
8570
  campaignId,
8554
8571
  channel,
8555
8572
  kolHandle,
8556
- enabled: !isPreview
8573
+ enabled: !isPreview,
8574
+ authToken: userToken
8557
8575
  });
8558
8576
  const {
8559
8577
  data: questStatus,
@@ -8581,9 +8599,6 @@ function QuestWidgetInner(props) {
8581
8599
  },
8582
8600
  onClaimError: (error2) => {
8583
8601
  toast.error(error2.message || t("failed_claim_nft"));
8584
- },
8585
- onWalletError: (errorMessage) => {
8586
- toast.error(errorMessage);
8587
8602
  }
8588
8603
  });
8589
8604
  const handleQuestClaimNft = useCallback(
@@ -8655,6 +8670,17 @@ function QuestWidgetInner(props) {
8655
8670
  const [blindBoxEmptyReward, setBlindBoxEmptyReward] = useState();
8656
8671
  const [blindBoxTokenPrice, setBlindBoxTokenPrice] = useState();
8657
8672
  const [isClaimingBlindBox, setIsClaimingBlindBox] = useState(false);
8673
+ const [hasCompletedBlindBoxClaim, setHasCompletedBlindBoxClaim] = useState(false);
8674
+ const closeBlindBoxModal = useCallback(() => {
8675
+ setBlindBoxDialogVisible(false);
8676
+ setBlindBoxRewardVisible(false);
8677
+ }, []);
8678
+ const handleBlindBoxDialogOpenChange = useCallback((open) => {
8679
+ setBlindBoxDialogVisible(open);
8680
+ if (!open) {
8681
+ setBlindBoxRewardVisible(false);
8682
+ }
8683
+ }, []);
8658
8684
  const buildBlindBoxRewardValue = useCallback(
8659
8685
  (amount) => {
8660
8686
  if (!blindBoxTokenReward) {
@@ -8689,8 +8715,8 @@ function QuestWidgetInner(props) {
8689
8715
  [blindBoxTokenReward]
8690
8716
  );
8691
8717
  const handleOpenBlindBox = useCallback(() => {
8692
- setBlindBoxRewardVisible(false);
8693
8718
  setBlindBoxDialogVisible(true);
8719
+ setBlindBoxRewardVisible(false);
8694
8720
  }, []);
8695
8721
  const handleBlindBoxOpened = useCallback(async () => {
8696
8722
  var _a2;
@@ -8713,7 +8739,7 @@ function QuestWidgetInner(props) {
8713
8739
  }
8714
8740
  refetchUserStatus();
8715
8741
  refetchStatus();
8716
- setBlindBoxDialogVisible(false);
8742
+ setHasCompletedBlindBoxClaim(true);
8717
8743
  setBlindBoxRewardVisible(true);
8718
8744
  } catch (error2) {
8719
8745
  console.error("Claim blind box error:", error2);
@@ -8734,15 +8760,19 @@ function QuestWidgetInner(props) {
8734
8760
  toast
8735
8761
  ]);
8736
8762
  useEffect(() => {
8737
- if (userBlindBoxStatus === "wait-claim" && !isBlindBoxDialogVisible && !isBlindBoxRewardVisible) {
8763
+ if (userBlindBoxStatus === "wait-claim" && !isBlindBoxDialogVisible && !isBlindBoxRewardVisible && !hasCompletedBlindBoxClaim) {
8738
8764
  handleOpenBlindBox();
8739
8765
  }
8740
8766
  }, [
8741
8767
  userBlindBoxStatus,
8742
8768
  isBlindBoxDialogVisible,
8743
8769
  isBlindBoxRewardVisible,
8770
+ hasCompletedBlindBoxClaim,
8744
8771
  handleOpenBlindBox
8745
8772
  ]);
8773
+ useEffect(() => {
8774
+ setHasCompletedBlindBoxClaim(false);
8775
+ }, [campaignId]);
8746
8776
  const isLoading = isDetailLoading || isUserStatusLoading || isStatusLoading;
8747
8777
  const error = detailError || userStatusError || statusError;
8748
8778
  useEffect(() => {
@@ -8965,7 +8995,8 @@ function QuestWidgetInner(props) {
8965
8995
  {
8966
8996
  className: "taskon-quest-tasks-progress",
8967
8997
  current: mandatoryCompleted + optionalCompleted,
8968
- total: mandatoryTotal + optionalTotal
8998
+ total: mandatoryTotal + optionalTotal,
8999
+ completedLabel: t("completed")
8969
9000
  }
8970
9001
  ),
8971
9002
  /* @__PURE__ */ jsx(
@@ -9086,38 +9117,27 @@ function QuestWidgetInner(props) {
9086
9117
  Dialog,
9087
9118
  {
9088
9119
  open: isBlindBoxDialogVisible,
9089
- onOpenChange: setBlindBoxDialogVisible,
9090
- title: t("open_blind_box"),
9091
- showCloseButton: false,
9092
- closeOnOverlayClick: false,
9093
- closeOnEscapeKey: false,
9094
- contentClassName: "taskon-quest-blindbox-dialog-wrapper",
9095
- children: /* @__PURE__ */ jsx(
9096
- BlindBoxDialog,
9097
- {
9098
- ref: blindBoxDialogRef,
9099
- onClose: () => setBlindBoxDialogVisible(false),
9100
- onOpened: handleBlindBoxOpened
9101
- }
9102
- )
9103
- }
9104
- ),
9105
- /* @__PURE__ */ jsx(
9106
- Dialog,
9107
- {
9108
- open: isBlindBoxRewardVisible,
9109
- onOpenChange: setBlindBoxRewardVisible,
9110
- title: t("blind_box_reward"),
9111
- showCloseButton: true,
9112
- contentClassName: "taskon-quest-blindbox-reward-wrapper",
9113
- children: /* @__PURE__ */ jsx(
9120
+ onOpenChange: handleBlindBoxDialogOpenChange,
9121
+ title: isBlindBoxRewardVisible ? t("blind_box_reward") : t("open_blind_box"),
9122
+ showCloseButton: isBlindBoxRewardVisible,
9123
+ closeOnOverlayClick: isBlindBoxRewardVisible,
9124
+ closeOnEscapeKey: isBlindBoxRewardVisible,
9125
+ contentClassName: `taskon-quest-blindbox-dialog-wrapper${isBlindBoxRewardVisible ? " taskon-quest-blindbox-dialog-wrapper--result" : ""}`,
9126
+ children: isBlindBoxRewardVisible ? /* @__PURE__ */ jsx(
9114
9127
  BlindBoxRewardDialog,
9115
9128
  {
9116
9129
  rewards: blindBoxWinnerRewards,
9117
9130
  emptyReward: blindBoxEmptyReward,
9118
9131
  tokenPrice: blindBoxTokenPrice,
9119
9132
  loading: isClaimingBlindBox,
9120
- onClose: () => setBlindBoxRewardVisible(false)
9133
+ onClose: closeBlindBoxModal
9134
+ }
9135
+ ) : /* @__PURE__ */ jsx(
9136
+ BlindBoxDialog,
9137
+ {
9138
+ ref: blindBoxDialogRef,
9139
+ onClose: closeBlindBoxModal,
9140
+ onOpened: handleBlindBoxOpened
9121
9141
  }
9122
9142
  )
9123
9143
  }
@@ -9211,8 +9231,5 @@ function QuestWidgetInner(props) {
9211
9231
  ] });
9212
9232
  }
9213
9233
  export {
9214
- QuestWidget as Q,
9215
- useQuestUserStatus as a,
9216
- useQuestStatus as b,
9217
- useQuestDetail as u
9234
+ QuestWidget as Q
9218
9235
  };