@taskon/widget-react 0.0.1-beta.2 → 0.0.1-beta.4

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 (44) hide show
  1. package/README.md +56 -17
  2. package/dist/CommunityTaskList.css +1593 -1741
  3. package/dist/EligibilityInfo.css +1275 -582
  4. package/dist/LeaderboardWidget.css +355 -152
  5. package/dist/PageBuilder.css +0 -2
  6. package/dist/Quest.css +1140 -903
  7. package/dist/TaskOnProvider.css +50 -31
  8. package/dist/UserCenterWidget.css +108 -237
  9. package/dist/UserCenterWidget2.css +2016 -711
  10. package/dist/chunks/{CommunityTaskList-BlH1Wdd5.js → CommunityTaskList-C9Gv8KOF.js} +962 -827
  11. package/dist/chunks/{EligibilityInfo-C7GZ2G5u.js → EligibilityInfo-D-Fuy9GE.js} +1137 -449
  12. package/dist/chunks/{LeaderboardWidget-CmYfDeHV.js → LeaderboardWidget-BV2D2q1N.js} +15 -10
  13. package/dist/chunks/{PageBuilder-Bw0zSkFh.js → PageBuilder-DQoU4Mwf.js} +5 -5
  14. package/dist/chunks/{Quest-DKFZ-pPU.js → Quest-B5NyVr3o.js} +516 -325
  15. package/dist/chunks/{TaskOnProvider-BD6Vp2x8.js → TaskOnProvider-93UxARFo.js} +2 -207
  16. package/dist/chunks/{ThemeProvider-wnSXrNQb.js → ThemeProvider-CPI_roeh.js} +249 -57
  17. package/dist/chunks/{UserCenterWidget-Cw6h_5hT.js → UserCenterWidget-BRtigY_S.js} +206 -1002
  18. package/dist/chunks/UserCenterWidget-cADBSVg7.js +8358 -0
  19. package/dist/chunks/{WidgetShell-D_5OjvNZ.js → dynamic-import-helper-DwXlQC0S.js} +607 -40
  20. package/dist/chunks/useToast-CaRkylKe.js +304 -0
  21. package/dist/chunks/{usercenter-ja-uu-XfVF9.js → usercenter-ja-B2465c1O.js} +4 -10
  22. package/dist/chunks/{usercenter-ko-DYgUOVzd.js → usercenter-ko-xAEYxqLg.js} +4 -10
  23. package/dist/community-task.d.ts +34 -3
  24. package/dist/community-task.js +1 -1
  25. package/dist/core.d.ts +40 -3
  26. package/dist/core.js +9 -10
  27. package/dist/dynamic-import-helper.css +596 -289
  28. package/dist/index.d.ts +207 -10
  29. package/dist/index.js +21 -19
  30. package/dist/leaderboard.d.ts +8 -1
  31. package/dist/leaderboard.js +2 -2
  32. package/dist/page-builder.js +1 -1
  33. package/dist/quest.d.ts +8 -2
  34. package/dist/quest.js +1 -1
  35. package/dist/user-center.d.ts +20 -136
  36. package/dist/user-center.js +19 -236
  37. package/package.json +10 -2
  38. package/dist/TipPopover.css +0 -210
  39. package/dist/WidgetShell.css +0 -182
  40. package/dist/chunks/TipPopover-BrW8jo71.js +0 -2926
  41. package/dist/chunks/UserCenterWidget-BE329iS7.js +0 -3546
  42. package/dist/chunks/dynamic-import-helper-DxEFwm31.js +0 -537
  43. package/dist/chunks/useToast-B-wyO5zL.js +0 -93
  44. package/dist/chunks/useWidgetLocale-JDelxtt8.js +0 -74
@@ -1,10 +1,9 @@
1
1
  import * as React from "react";
2
2
  import React__default, { useState, useRef, useEffect, useMemo, useCallback } from "react";
3
- import { u as useWidgetLocale } from "./useWidgetLocale-JDelxtt8.js";
3
+ import { b as useWidgetLocale, e as createContextScope, f as useComposedRefs, g as createSlot, P as Primitive, B as Branch, h as useControllableState, j as Presence, k as composeEventHandlers, l as useCallbackRef, R as Root, m as Portal, n as dispatchDiscreteCustomEvent, o as useLayoutEffect2, p as TaskOnContext } from "./ThemeProvider-CPI_roeh.js";
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { createTaskOnClient, createUserApi, createChainApi, createCommunityTaskApi } from "@taskon/core";
6
- import { f as createContextScope, g as useComposedRefs, m as createSlot, P as Primitive, B as Branch, i as useControllableState, k as Presence, j as composeEventHandlers, h as useCallbackRef, R as Root, l as Portal, n as dispatchDiscreteCustomEvent, e as useLayoutEffect2, d as TaskOnContext } from "./ThemeProvider-wnSXrNQb.js";
7
- import { W as WalletContext, c as useToastState, T as ToastContext } from "./useToast-B-wyO5zL.js";
6
+ import { c as createEthereumAdapter, W as WalletContext, b as useToastState, T as ToastContext } from "./useToast-CaRkylKe.js";
8
7
  import * as ReactDOM from "react-dom";
9
8
  import '../TaskOnProvider.css';const TOKEN_STORAGE_KEY = "taskon_user_token";
10
9
  function isBrowser() {
@@ -316,210 +315,6 @@ function useAuth({
316
315
  }, [client, setUserInfo, setUserToken]);
317
316
  return { login, logout };
318
317
  }
319
- let ethersModule = null;
320
- const interfaceCache = /* @__PURE__ */ new Map();
321
- async function loadEthers() {
322
- if (ethersModule) {
323
- return ethersModule;
324
- }
325
- try {
326
- ethersModule = await import("ethers");
327
- return ethersModule;
328
- } catch {
329
- throw new Error(
330
- "ethers.js is required for contract invocation. Please install ethers@^6.0.0"
331
- );
332
- }
333
- }
334
- async function getInterface(abi) {
335
- const { ethers } = await loadEthers();
336
- const cacheKey = JSON.stringify(abi);
337
- let iface = interfaceCache.get(cacheKey);
338
- if (!iface) {
339
- iface = new ethers.Interface(abi);
340
- interfaceCache.set(cacheKey, iface);
341
- }
342
- return iface;
343
- }
344
- function getEthereumProvider() {
345
- if (typeof window === "undefined") return null;
346
- return window.ethereum ?? null;
347
- }
348
- function createEthereumAdapter() {
349
- const provider = getEthereumProvider();
350
- if (!provider) return null;
351
- let currentAddress = null;
352
- let currentChainId = null;
353
- const adapter = {
354
- /**
355
- * Connect wallet
356
- *
357
- * TODO: Current implementation directly calls window.ethereum, cannot show wallet selection modal
358
- * Future improvements needed to integrate Web3Modal or similar solutions to support:
359
- * 1. Multi-wallet selection (MetaMask, Coinbase, WalletConnect, etc.)
360
- * 2. Unified connection modal UI
361
- */
362
- connect: async () => {
363
- const accounts = await provider.request({
364
- method: "eth_requestAccounts"
365
- });
366
- if (!accounts || accounts.length === 0) {
367
- throw new Error("No accounts found");
368
- }
369
- const address = accounts[0];
370
- if (!address) {
371
- throw new Error("No accounts found");
372
- }
373
- currentAddress = address;
374
- const chainIdHex = await provider.request({
375
- method: "eth_chainId"
376
- });
377
- currentChainId = parseInt(chainIdHex, 16);
378
- return address;
379
- },
380
- /**
381
- * Disconnect from wallet
382
- * Note: Most wallets don't support programmatic disconnect, can only clear local state
383
- */
384
- disconnect: async () => {
385
- currentAddress = null;
386
- currentChainId = null;
387
- },
388
- /**
389
- * Sign message (personal_sign)
390
- */
391
- signMessage: async (message) => {
392
- if (!currentAddress) {
393
- throw new Error("Wallet not connected");
394
- }
395
- const signature = await provider.request({
396
- method: "personal_sign",
397
- params: [message, currentAddress]
398
- });
399
- return signature;
400
- },
401
- /**
402
- * Get current address
403
- */
404
- getAddress: () => currentAddress,
405
- /**
406
- * Get current chain ID
407
- */
408
- getChainId: () => currentChainId,
409
- /**
410
- * Switch network
411
- */
412
- switchNetwork: async (chainId) => {
413
- const chainIdHex = `0x${chainId.toString(16)}`;
414
- try {
415
- await provider.request({
416
- method: "wallet_switchEthereumChain",
417
- params: [{ chainId: chainIdHex }]
418
- });
419
- currentChainId = chainId;
420
- } catch (error2) {
421
- const err = error2;
422
- if (err.code === 4902) {
423
- throw new Error("Chain not found in wallet. Please add the network manually.");
424
- }
425
- throw error2;
426
- }
427
- },
428
- /**
429
- * Get wallet's native token balance (for gas estimation)
430
- * @returns Balance in ETH (string, formatted)
431
- */
432
- getBalance: async () => {
433
- if (!currentAddress) {
434
- throw new Error("Wallet not connected");
435
- }
436
- const balanceHex = await provider.request({
437
- method: "eth_getBalance",
438
- params: [currentAddress, "latest"]
439
- });
440
- const balanceWei = BigInt(balanceHex);
441
- const balanceEth = Number(balanceWei) / 1e18;
442
- return balanceEth.toString();
443
- },
444
- /**
445
- * Invoke a smart contract method
446
- *
447
- * 使用 ethers.js 编码合约调用,支持缓存优化:
448
- * - ethers 模块只加载一次
449
- * - 相同 ABI 的 Interface 实例会被缓存复用
450
- *
451
- * @param params - Contract invocation parameters
452
- * @returns Transaction hash
453
- */
454
- invokeContract: async (params) => {
455
- var _a;
456
- if (!currentAddress) {
457
- throw new Error("Wallet not connected");
458
- }
459
- const { contract, abi, method, params: methodParams, chainId, value } = params;
460
- if (chainId && currentChainId !== chainId) {
461
- await ((_a = adapter.switchNetwork) == null ? void 0 : _a.call(adapter, chainId));
462
- }
463
- let encodedData;
464
- try {
465
- const iface = await getInterface(abi);
466
- encodedData = iface.encodeFunctionData(method, methodParams);
467
- } catch (error2) {
468
- if (error2 instanceof Error && error2.message.includes("ethers.js is required")) {
469
- throw error2;
470
- }
471
- throw new Error(
472
- `Failed to encode contract call "${method}": ${error2 instanceof Error ? error2.message : String(error2)}`
473
- );
474
- }
475
- const txParams = {
476
- from: currentAddress,
477
- to: contract,
478
- data: encodedData
479
- };
480
- if (value) {
481
- txParams.value = `0x${BigInt(value).toString(16)}`;
482
- }
483
- const txHash = await provider.request({
484
- method: "eth_sendTransaction",
485
- params: [txParams]
486
- });
487
- return txHash;
488
- },
489
- /**
490
- * Listen to account changes
491
- */
492
- onAccountChange: (callback) => {
493
- var _a;
494
- const handler = (accounts) => {
495
- const accountList = accounts;
496
- currentAddress = accountList[0] ?? null;
497
- callback(currentAddress);
498
- };
499
- (_a = provider.on) == null ? void 0 : _a.call(provider, "accountsChanged", handler);
500
- return () => {
501
- var _a2;
502
- return (_a2 = provider.removeListener) == null ? void 0 : _a2.call(provider, "accountsChanged", handler);
503
- };
504
- },
505
- /**
506
- * Listen to chain changes
507
- */
508
- onChainChange: (callback) => {
509
- var _a;
510
- const handler = (chainIdHex) => {
511
- currentChainId = parseInt(chainIdHex, 16);
512
- callback(currentChainId);
513
- };
514
- (_a = provider.on) == null ? void 0 : _a.call(provider, "chainChanged", handler);
515
- return () => {
516
- var _a2;
517
- return (_a2 = provider.removeListener) == null ? void 0 : _a2.call(provider, "chainChanged", handler);
518
- };
519
- }
520
- };
521
- return adapter;
522
- }
523
318
  function WalletProvider({
524
319
  children,
525
320
  config
@@ -1,9 +1,10 @@
1
1
  import * as React from "react";
2
- import { createContext, useContext, useMemo, useState, useEffect } from "react";
3
- import { jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo, useState, useRef, useEffect } from "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import * as ReactDOM from "react-dom";
5
5
  import ReactDOM__default from "react-dom";
6
6
  const ThemeContext = createContext(null);
7
+ const ThemePortalContainerContext = createContext(void 0);
7
8
  function useTaskOnTheme() {
8
9
  const theme = useContext(ThemeContext);
9
10
  if (!theme) {
@@ -11,6 +12,16 @@ function useTaskOnTheme() {
11
12
  }
12
13
  return theme;
13
14
  }
15
+ function useTaskOnPortalContainer() {
16
+ const container = useContext(ThemePortalContainerContext);
17
+ if (container !== void 0) {
18
+ return container;
19
+ }
20
+ if (typeof document !== "undefined") {
21
+ return document.body;
22
+ }
23
+ return null;
24
+ }
14
25
  const TaskOnContext = createContext(null);
15
26
  function useTaskOnContext() {
16
27
  const context = useContext(TaskOnContext);
@@ -44,6 +55,73 @@ function useTaskOnAuth() {
44
55
  ]
45
56
  );
46
57
  }
58
+ function isSupportedLocale(locale) {
59
+ return locale === "en" || locale === "ko" || locale === "ja";
60
+ }
61
+ function warnUnsupportedLocale(locale, widgetId) {
62
+ if (process.env.NODE_ENV !== "production" && !isSupportedLocale(locale)) {
63
+ console.warn(
64
+ `[widget-react] Locale "${locale}" is not fully supported in ${widgetId}. Falling back to English. Supported locales: en, ko, ja`
65
+ );
66
+ }
67
+ }
68
+ const localeCache = /* @__PURE__ */ new Map();
69
+ const DEFAULT_LOCALE = "en";
70
+ function useWidgetLocale(options) {
71
+ const { widgetId, defaultMessages, loadMessages } = options;
72
+ const { locale } = useTaskOnContext();
73
+ const getInitialState = () => {
74
+ if (locale === DEFAULT_LOCALE) {
75
+ return { messages: defaultMessages, isLoading: false };
76
+ }
77
+ const cacheKey = `${widgetId}-${locale}`;
78
+ if (localeCache.has(cacheKey)) {
79
+ return { messages: localeCache.get(cacheKey), isLoading: false };
80
+ }
81
+ return { messages: defaultMessages, isLoading: true };
82
+ };
83
+ const [state, setState] = useState(getInitialState);
84
+ const loadMessagesRef = useRef(loadMessages);
85
+ loadMessagesRef.current = loadMessages;
86
+ const defaultMessagesRef = useRef(defaultMessages);
87
+ defaultMessagesRef.current = defaultMessages;
88
+ useEffect(() => {
89
+ if (locale === DEFAULT_LOCALE) {
90
+ setState({ messages: defaultMessagesRef.current, isLoading: false });
91
+ return;
92
+ }
93
+ warnUnsupportedLocale(locale, widgetId);
94
+ const cacheKey = `${widgetId}-${locale}`;
95
+ if (localeCache.has(cacheKey)) {
96
+ setState({ messages: localeCache.get(cacheKey), isLoading: false });
97
+ return;
98
+ }
99
+ let isMounted = true;
100
+ setState((prev) => ({ ...prev, isLoading: true }));
101
+ loadMessagesRef.current(locale).then((module) => {
102
+ if (isMounted) {
103
+ const loadedMessages = module.default;
104
+ localeCache.set(cacheKey, loadedMessages);
105
+ setState({ messages: loadedMessages, isLoading: false });
106
+ }
107
+ }).catch((error) => {
108
+ console.warn(
109
+ `[widget-react] Failed to load locale "${locale}" for ${widgetId}, falling back to English:`,
110
+ error
111
+ );
112
+ if (isMounted) {
113
+ setState({ messages: defaultMessagesRef.current, isLoading: false });
114
+ }
115
+ });
116
+ return () => {
117
+ isMounted = false;
118
+ };
119
+ }, [locale, widgetId]);
120
+ return state;
121
+ }
122
+ function clearLocaleCache() {
123
+ localeCache.clear();
124
+ }
47
125
  function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
48
126
  return function handleEvent(event) {
49
127
  originalEventHandler == null ? void 0 : originalEventHandler(event);
@@ -707,28 +785,38 @@ function isFunction(value) {
707
785
  }
708
786
  const lightDefaultTokens = {
709
787
  // Primary colors
710
- colorPrimary: "#6366f1",
711
- colorPrimaryHover: "#9197fe",
712
- colorPrimaryActive: "#4b49cb",
713
- colorPrimaryBg: "#f0f3ff",
788
+ colorPrimary: "#CBFF01",
789
+ colorPrimaryHover: "#daff2a",
790
+ colorPrimaryActive: "#a5d900",
791
+ colorPrimaryBg: "#fdffcd",
714
792
  // Secondary color
715
- colorSecondary: "#64748b",
793
+ colorSecondary: "#00FFA3",
716
794
  // Status colors
717
- colorSuccess: "#22c55e",
718
- colorWarning: "#f59e0b",
719
- colorError: "#ef4444",
720
- // Background colors
721
- colorBg: "#ffffff",
722
- colorBgElevated: "#ffffff",
723
- colorBgSpotlight: "#f8fafc",
795
+ colorSuccess: "#1FCBAF",
796
+ colorWarning: "#FFB800",
797
+ colorError: "#FF4D4D",
798
+ // Background colors (V2)
799
+ colorBgCanvas: "#FFFFFF",
800
+ colorBgSurface: "#fafafb",
801
+ colorBgSurfaceSubtle: "rgba(26, 29, 31, 0.04)",
802
+ colorBgSurfaceStrong: "rgba(26, 29, 31, 0.06)",
803
+ colorBgFloating: "#f4f4f4",
804
+ colorBgMask: "rgba(26, 29, 31, 0.45)",
805
+ colorBgInset: "#eaebeb",
806
+ colorSuccessBg: "#1fcbaf1a",
807
+ colorWarningBg: "#ffb8001a",
808
+ colorErrorBg: "#ff4d4d1a",
809
+ colorSecondaryBg: "#00ffa31a",
724
810
  // Text colors
725
- colorText: "#0f172a",
726
- colorTextSecondary: "#475569",
727
- colorTextTertiary: "#94a3b8",
728
- colorTextDisabled: "#cbd5e1",
811
+ colorText: "#1A1D1F",
812
+ colorTextSecondary: "rgba(26, 29, 31, 0.72)",
813
+ colorTextTertiary: "rgba(26, 29, 31, 0.6)",
814
+ colorTextDisabled: "rgba(26, 29, 31, 0.4)",
815
+ colorLink: "#58AFFF",
816
+ colorTextOnPrimary: "#000000",
729
817
  // Border colors
730
- colorBorder: "#e2e8f0",
731
- colorBorderSecondary: "#f1f5f9",
818
+ colorBorder: "rgba(26, 29, 31, 0.1)",
819
+ colorBorderSecondary: "rgba(26, 29, 31, 0.06)",
732
820
  // Border radius
733
821
  borderRadius: 8,
734
822
  borderRadiusSm: 4,
@@ -747,28 +835,38 @@ const lightDefaultTokens = {
747
835
  };
748
836
  const darkDefaultTokens = {
749
837
  // Primary colors
750
- colorPrimary: "#818cf8",
751
- colorPrimaryHover: "#adb8ff",
752
- colorPrimaryActive: "#6369d2",
753
- colorPrimaryBg: "#131525",
838
+ colorPrimary: "#CBFF01",
839
+ colorPrimaryHover: "#daff2a",
840
+ colorPrimaryActive: "#a5d900",
841
+ colorPrimaryBg: "#1e2600",
754
842
  // Secondary color
755
- colorSecondary: "#94a3b8",
843
+ colorSecondary: "#00FFA3",
756
844
  // Status colors
757
- colorSuccess: "#4ade80",
758
- colorWarning: "#fbbf24",
759
- colorError: "#f87171",
760
- // Background colors
761
- colorBg: "#0f172a",
762
- colorBgElevated: "#1e293b",
763
- colorBgSpotlight: "#334155",
845
+ colorSuccess: "#1FCBAF",
846
+ colorWarning: "#FFB800",
847
+ colorError: "#FF4D4D",
848
+ // Background colors (V2)
849
+ colorBgCanvas: "#1A1D1F",
850
+ colorBgSurface: "#282b2c",
851
+ colorBgSurfaceSubtle: "rgba(255, 255, 255, 0.04)",
852
+ colorBgSurfaceStrong: "rgba(255, 255, 255, 0.12)",
853
+ colorBgFloating: "#313435",
854
+ colorBgMask: "rgba(26, 29, 31, 0.6)",
855
+ colorBgInset: "#3a3d3e",
856
+ colorSuccessBg: "#1fcbaf26",
857
+ colorWarningBg: "#ffb80026",
858
+ colorErrorBg: "#ff4d4d26",
859
+ colorSecondaryBg: "#00ffa326",
764
860
  // Text colors
765
- colorText: "#f8fafc",
766
- colorTextSecondary: "#cbd5e1",
767
- colorTextTertiary: "#94a3b8",
768
- colorTextDisabled: "#64748b",
861
+ colorText: "#FFFFFF",
862
+ colorTextSecondary: "rgba(255, 255, 255, 0.72)",
863
+ colorTextTertiary: "rgba(255, 255, 255, 0.6)",
864
+ colorTextDisabled: "rgba(255, 255, 255, 0.4)",
865
+ colorLink: "#58AFFF",
866
+ colorTextOnPrimary: "#000000",
769
867
  // Border colors
770
- colorBorder: "#334155",
771
- colorBorderSecondary: "#1e293b",
868
+ colorBorder: "rgba(255, 255, 255, 0.1)",
869
+ colorBorderSecondary: "rgba(255, 255, 255, 0.06)",
772
870
  // Border radius
773
871
  borderRadius: 8,
774
872
  borderRadiusSm: 4,
@@ -962,6 +1060,11 @@ function mixColors(color1, color2, weight) {
962
1060
  b: rgb1.b + (rgb2.b - rgb1.b) * weight
963
1061
  });
964
1062
  }
1063
+ function withAlpha(color, alpha) {
1064
+ const rgb = hexToRgb(color);
1065
+ if (!rgb) return color;
1066
+ return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})`;
1067
+ }
965
1068
  function deriveTokens(seed, mode) {
966
1069
  const derived = {};
967
1070
  const isLight = mode === "light";
@@ -982,6 +1085,57 @@ function deriveTokens(seed, mode) {
982
1085
  if (seed.colorSuccess) derived.colorSuccess = seed.colorSuccess;
983
1086
  if (seed.colorWarning) derived.colorWarning = seed.colorWarning;
984
1087
  if (seed.colorError) derived.colorError = seed.colorError;
1088
+ if (seed.colorLink) derived.colorLink = seed.colorLink;
1089
+ if (seed.colorText) derived.colorText = seed.colorText;
1090
+ if (seed.colorTextOnPrimary) {
1091
+ derived.colorTextOnPrimary = seed.colorTextOnPrimary;
1092
+ }
1093
+ if (seed.colorText) {
1094
+ derived.colorTextSecondary = withAlpha(seed.colorText, 0.72);
1095
+ derived.colorTextTertiary = withAlpha(seed.colorText, 0.6);
1096
+ derived.colorTextDisabled = withAlpha(seed.colorText, 0.4);
1097
+ derived.colorBorder = withAlpha(seed.colorText, 0.1);
1098
+ derived.colorBorderSecondary = withAlpha(seed.colorText, 0.06);
1099
+ }
1100
+ if (seed.colorBgBase) {
1101
+ derived.colorBgCanvas = seed.colorBgBase;
1102
+ if (seed.colorText) {
1103
+ derived.colorBgSurface = mixColors(
1104
+ seed.colorBgBase,
1105
+ seed.colorText,
1106
+ 0.06
1107
+ );
1108
+ derived.colorBgSurfaceSubtle = withAlpha(seed.colorText, 0.04);
1109
+ derived.colorBgSurfaceStrong = withAlpha(seed.colorText, 0.12);
1110
+ derived.colorBgFloating = mixColors(
1111
+ seed.colorBgBase,
1112
+ seed.colorText,
1113
+ 0.1
1114
+ );
1115
+ derived.colorBgInset = mixColors(
1116
+ seed.colorBgBase,
1117
+ seed.colorText,
1118
+ 0.14
1119
+ );
1120
+ derived.colorBgMask = isLight ? withAlpha(seed.colorText, 0.45) : withAlpha(seed.colorBgBase, 0.6);
1121
+ } else {
1122
+ derived.colorBgSurface = seed.colorBgBase;
1123
+ derived.colorBgFloating = seed.colorBgBase;
1124
+ derived.colorBgInset = seed.colorBgBase;
1125
+ }
1126
+ }
1127
+ if (seed.colorSecondary) {
1128
+ derived.colorSecondaryBg = withAlpha(seed.colorSecondary, 0.15);
1129
+ }
1130
+ if (seed.colorSuccess) {
1131
+ derived.colorSuccessBg = withAlpha(seed.colorSuccess, 0.15);
1132
+ }
1133
+ if (seed.colorWarning) {
1134
+ derived.colorWarningBg = withAlpha(seed.colorWarning, 0.15);
1135
+ }
1136
+ if (seed.colorError) {
1137
+ derived.colorErrorBg = withAlpha(seed.colorError, 0.15);
1138
+ }
985
1139
  if (seed.borderRadius !== void 0) {
986
1140
  derived.borderRadius = seed.borderRadius;
987
1141
  derived.borderRadiusSm = Math.max(0, seed.borderRadius - 4);
@@ -992,6 +1146,21 @@ function deriveTokens(seed, mode) {
992
1146
  derived.fontSizeSm = seed.fontSize - 2;
993
1147
  derived.fontSizeLg = seed.fontSize + 2;
994
1148
  }
1149
+ if (seed.spacingBaseStep !== void 0 || seed.spacingChangeUnit !== void 0) {
1150
+ const base = Math.max(1, Number(seed.spacingBaseStep) || 1);
1151
+ const unit = Math.max(1, Number(seed.spacingChangeUnit) || 1);
1152
+ const spacingXs = base;
1153
+ const spacingSm = base + unit;
1154
+ const spacingMd = base + unit * 3;
1155
+ const spacingLg = base + unit * 5;
1156
+ const spacingXl = base + unit * 7;
1157
+ derived.spacing = spacingSm;
1158
+ derived.spacingXs = spacingXs;
1159
+ derived.spacingSm = spacingSm;
1160
+ derived.spacingMd = spacingMd;
1161
+ derived.spacingLg = spacingLg;
1162
+ derived.spacingXl = spacingXl;
1163
+ }
995
1164
  return derived;
996
1165
  }
997
1166
  function mergeTokens(defaults, derived, override) {
@@ -1008,9 +1177,9 @@ function getSystemThemeMode() {
1008
1177
  return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
1009
1178
  }
1010
1179
  const defaultTheme = {
1011
- mode: "light",
1180
+ mode: "dark",
1012
1181
  compact: false,
1013
- tokens: lightDefaultTokens
1182
+ tokens: darkDefaultTokens
1014
1183
  };
1015
1184
  function toKebabCase(str) {
1016
1185
  return str.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -1037,7 +1206,7 @@ function resolveTheme(config, systemMode) {
1037
1206
  } else if (config.mode) {
1038
1207
  resolvedMode = config.mode;
1039
1208
  } else {
1040
- resolvedMode = "light";
1209
+ resolvedMode = "dark";
1041
1210
  }
1042
1211
  const defaultTokens = resolvedMode === "light" ? lightDefaultTokens : darkDefaultTokens;
1043
1212
  const modeConfig = resolvedMode === "light" ? config.light : config.dark;
@@ -1061,6 +1230,9 @@ function ThemeProvider({
1061
1230
  theme: themeConfig,
1062
1231
  children
1063
1232
  }) {
1233
+ const [portalContainer, setPortalContainer] = useState(
1234
+ null
1235
+ );
1064
1236
  const [systemMode, setSystemMode] = useState(
1065
1237
  () => getSystemThemeMode()
1066
1238
  );
@@ -1084,14 +1256,30 @@ function ThemeProvider({
1084
1256
  () => tokensToCssVariables(resolvedTheme.tokens),
1085
1257
  [resolvedTheme.tokens]
1086
1258
  );
1087
- return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: resolvedTheme, children: /* @__PURE__ */ jsx(
1259
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: resolvedTheme, children: /* @__PURE__ */ jsx(ThemePortalContainerContext.Provider, { value: portalContainer, children: /* @__PURE__ */ jsxs(
1088
1260
  "div",
1089
1261
  {
1090
1262
  style: cssVariables,
1091
1263
  "data-taskon-theme": resolvedTheme.mode,
1092
- children
1264
+ children: [
1265
+ /* @__PURE__ */ jsx(
1266
+ "div",
1267
+ {
1268
+ ref: setPortalContainer,
1269
+ "aria-hidden": "true",
1270
+ style: {
1271
+ position: "absolute",
1272
+ top: 0,
1273
+ left: 0,
1274
+ width: 0,
1275
+ height: 0
1276
+ }
1277
+ }
1278
+ ),
1279
+ children
1280
+ ]
1093
1281
  }
1094
- ) });
1282
+ ) }) });
1095
1283
  }
1096
1284
  export {
1097
1285
  Branch as B,
@@ -1100,19 +1288,23 @@ export {
1100
1288
  Root as R,
1101
1289
  ThemeProvider as T,
1102
1290
  useTaskOnTheme as a,
1103
- useTaskOnContext as b,
1104
- composeRefs as c,
1105
- TaskOnContext as d,
1106
- useLayoutEffect2 as e,
1107
- createContextScope as f,
1108
- useComposedRefs as g,
1109
- useCallbackRef as h,
1110
- useControllableState as i,
1111
- composeEventHandlers as j,
1112
- Presence as k,
1113
- Portal as l,
1114
- createSlot as m,
1291
+ useWidgetLocale as b,
1292
+ clearLocaleCache as c,
1293
+ useTaskOnContext as d,
1294
+ createContextScope as e,
1295
+ useComposedRefs as f,
1296
+ createSlot as g,
1297
+ useControllableState as h,
1298
+ isSupportedLocale as i,
1299
+ Presence as j,
1300
+ composeEventHandlers as k,
1301
+ useCallbackRef as l,
1302
+ Portal as m,
1115
1303
  dispatchDiscreteCustomEvent as n,
1116
- createContext2 as o,
1304
+ useLayoutEffect2 as o,
1305
+ TaskOnContext as p,
1306
+ composeRefs as q,
1307
+ createContext2 as r,
1308
+ useTaskOnPortalContainer as s,
1117
1309
  useTaskOnAuth as u
1118
1310
  };