@particle-network/ui-react 0.5.1-beta.0 → 0.5.1-beta.10

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 (89) hide show
  1. package/dist/components/ProgressWrapper/index.d.ts +2 -2
  2. package/dist/components/ProgressWrapper/index.js +1 -1
  3. package/dist/components/UXAutocomplete/index.js +1 -2
  4. package/dist/components/UXButton/button-theme.js +38 -2
  5. package/dist/components/UXButton/button.js +1 -1
  6. package/dist/components/UXCheckbox/checkbox.extend.js +16 -13
  7. package/dist/components/UXChip/chip.extend.d.ts +2 -1
  8. package/dist/components/UXChip/index.d.ts +1 -1
  9. package/dist/components/UXColorPicker/color-fields.d.ts +3 -0
  10. package/dist/components/UXColorPicker/color-fields.js +142 -0
  11. package/dist/components/UXColorPicker/color-input.d.ts +7 -0
  12. package/dist/components/UXColorPicker/color-input.js +12 -0
  13. package/dist/components/UXColorPicker/color-picker.d.ts +3 -0
  14. package/dist/components/UXColorPicker/color-picker.js +228 -0
  15. package/dist/components/UXColorPicker/index.d.ts +5 -0
  16. package/dist/components/UXColorPicker/index.js +3 -0
  17. package/dist/components/UXColorPicker/types.d.ts +51 -0
  18. package/dist/components/UXColorPicker/types.js +0 -0
  19. package/dist/components/UXColorPicker/utils.d.ts +7 -0
  20. package/dist/components/UXColorPicker/utils.js +6 -0
  21. package/dist/components/UXCopy/index.js +2 -2
  22. package/dist/components/UXEmpty/index.js +2 -2
  23. package/dist/components/UXHint/index.js +1 -1
  24. package/dist/components/UXInput/index.d.ts +6 -6
  25. package/dist/components/UXInput/input.extend.d.ts +6 -6
  26. package/dist/components/UXRadio/radio.extend.js +3 -3
  27. package/dist/components/UXSlider/use-slider.d.ts +1 -1
  28. package/dist/components/UXSlider/use-slider.js +1 -1
  29. package/dist/components/UXSpinner/spinner.d.ts +1 -5
  30. package/dist/components/UXSpinner/spinner.js +3 -4
  31. package/dist/components/UXSwitch/index.d.ts +2 -2
  32. package/dist/components/UXSwitch/switch.extend.d.ts +2 -2
  33. package/dist/components/UXSwitch/switch.extend.js +6 -6
  34. package/dist/components/UXTabs/tabs.classes.js +4 -4
  35. package/dist/components/UXThemeSwitch/constants.d.ts +9 -0
  36. package/dist/components/UXThemeSwitch/constants.js +3 -0
  37. package/dist/components/UXThemeSwitch/custom-theme-config.d.ts +2 -0
  38. package/dist/components/UXThemeSwitch/custom-theme-config.js +171 -0
  39. package/dist/components/UXThemeSwitch/theme-item.js +94 -15
  40. package/dist/components/UXThemeSwitch/theme-switch.js +26 -5
  41. package/dist/components/UXThemeSwitch/use-color-scheme.js +11 -8
  42. package/dist/components/UXThemeSwitch/use-theme-color.d.ts +1 -22
  43. package/dist/components/UXThemeSwitch/use-theme-color.js +3 -7
  44. package/dist/components/UXThemeSwitch/use-theme-store.d.ts +5 -0
  45. package/dist/components/UXThemeSwitch/use-theme-store.js +9 -3
  46. package/dist/components/UXThemeSwitch/use-theme.d.ts +2 -0
  47. package/dist/components/UXThemeSwitch/use-theme.js +10 -53
  48. package/dist/components/UXThemeSwitch/utils.d.ts +28 -0
  49. package/dist/components/UXThemeSwitch/utils.js +222 -0
  50. package/dist/components/UXToast/index.js +4 -4
  51. package/dist/components/index.d.ts +1 -0
  52. package/dist/components/index.js +1 -0
  53. package/dist/components/layout/Box/box-theme.d.ts +2225 -0
  54. package/dist/components/layout/Box/box-theme.js +348 -0
  55. package/dist/components/layout/Box/box.d.ts +14 -0
  56. package/dist/components/layout/Box/box.js +99 -0
  57. package/dist/components/layout/Circle.js +2 -3
  58. package/dist/components/layout/Flex.d.ts +3 -27
  59. package/dist/components/layout/Flex.js +6 -19
  60. package/dist/components/layout/HStack.d.ts +1 -1
  61. package/dist/components/layout/Square.js +3 -3
  62. package/dist/components/layout/VStack.d.ts +1 -1
  63. package/dist/components/layout/VStack.js +2 -2
  64. package/dist/components/layout/index.d.ts +1 -0
  65. package/dist/components/layout/index.js +1 -0
  66. package/dist/components/typography/Text.js +22 -7
  67. package/dist/components/typography/Text.type.d.ts +3 -26
  68. package/dist/components/typography/Text.type.js +0 -47
  69. package/dist/components/typography/text-theme.d.ts +178 -0
  70. package/dist/components/typography/text-theme.js +79 -0
  71. package/dist/heroui/constants.d.ts +18 -0
  72. package/dist/heroui/constants.js +98 -0
  73. package/dist/heroui/types.d.ts +91 -0
  74. package/dist/heroui/types.js +0 -0
  75. package/dist/heroui/utils/colors.d.ts +34 -0
  76. package/dist/heroui/utils/colors.js +121 -0
  77. package/dist/heroui/utils/object.d.ts +1 -0
  78. package/dist/heroui/utils/object.js +17 -0
  79. package/dist/hooks/useI18n.d.ts +133 -25
  80. package/dist/hooks/useI18n.js +84 -2
  81. package/dist/hooks/useLang.d.ts +5 -1
  82. package/dist/hooks/useLang.js +13 -1
  83. package/dist/utils/cn.d.ts +2 -0
  84. package/dist/utils/cn.js +258 -0
  85. package/dist/utils/index.d.ts +1 -0
  86. package/dist/utils/index.js +2 -1
  87. package/dist/utils/input-classes.js +2 -2
  88. package/package.json +8 -5
  89. package/tailwind-preset.js +84 -160
@@ -0,0 +1,51 @@
1
+ import type { Color } from 'react-stately';
2
+ import type { UXPopoverProps } from '../UXPopover';
3
+ export interface UXColorPickerProps {
4
+ className?: string;
5
+ /**
6
+ * 颜色值(受控)
7
+ */
8
+ value?: string | Color;
9
+ /**
10
+ * 默认颜色值(非受控)
11
+ */
12
+ defaultValue?: string | Color;
13
+ /**
14
+ * 颜色变化回调(拖拽时调用)
15
+ */
16
+ onChange?: (color: Color) => void;
17
+ /**
18
+ * 颜色变化结束回调(释放时调用)
19
+ */
20
+ onChangeEnd?: (color: Color) => void;
21
+ /**
22
+ * HEX 格式颜色变化回调(拖拽时调用)
23
+ */
24
+ onValueChange?: (color: string) => void;
25
+ /**
26
+ * HEX 格式颜色变化结束回调(释放时调用)
27
+ */
28
+ onValueChangeEnd?: (color: string) => void;
29
+ /**
30
+ * 是否已改变(展示 reset 按钮)
31
+ */
32
+ isChanged?: boolean;
33
+ /**
34
+ * 重置回调
35
+ */
36
+ onReset?: () => void;
37
+ /**
38
+ * 是否禁用
39
+ */
40
+ isDisabled?: boolean;
41
+ /**
42
+ * Popover 位置
43
+ */
44
+ placement?: UXPopoverProps['placement'];
45
+ }
46
+ export interface ColorFieldsProps extends Pick<UXColorPickerProps, 'value' | 'defaultValue'> {
47
+ /**
48
+ * 颜色变化回调
49
+ */
50
+ onChange?: (color: Color | null) => void;
51
+ }
File without changes
@@ -0,0 +1,7 @@
1
+ import type { Color } from 'react-stately';
2
+ /**
3
+ * 将颜色值(string 或 Color)标准化为 Color 对象
4
+ * @param colorValue - 颜色值,可以是字符串或 Color 对象
5
+ * @returns Color 对象
6
+ */
7
+ export declare function normalizeColor(colorValue: string | Color | undefined | null): Color;
@@ -0,0 +1,6 @@
1
+ import { parseColor } from "react-aria-components";
2
+ function normalizeColor(colorValue) {
3
+ if (!colorValue) return parseColor('#000000');
4
+ return 'string' == typeof colorValue ? parseColor(colorValue) : colorValue;
5
+ }
6
+ export { normalizeColor };
@@ -1,9 +1,9 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import react from "react";
3
- import { cn } from "@heroui/theme";
4
3
  import CopyIcon from "@particle-network/icons/web/CopyIcon";
5
4
  import copy_to_clipboard from "copy-to-clipboard";
6
5
  import { useI18n } from "../../hooks/useI18n.js";
6
+ import { cn } from "../../utils/index.js";
7
7
  import { toast } from "../UXToast/index.js";
8
8
  import { UXTooltip } from "../UXTooltip/index.js";
9
9
  import { shortAddress } from "./utils.js";
@@ -39,7 +39,7 @@ const Address = ({ children, copyText = children, tooltipContent = children, sta
39
39
  toastText: `${i18n.copy.address}${children}`,
40
40
  ...props,
41
41
  children: /*#__PURE__*/ jsxs("div", {
42
- className: "flex items-center gap-1 hover:opacity-70 text-body2 font-medium",
42
+ className: "text-body2 flex items-center gap-1 font-medium hover:opacity-70",
43
43
  children: [
44
44
  startContent,
45
45
  shortAddress(children),
@@ -1,9 +1,9 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import { forwardRef } from "@heroui/system";
4
- import { cn } from "@heroui/theme";
5
4
  import EmptyIcon from "@particle-network/icons/web/EmptyIcon";
6
5
  import { useI18n } from "../../hooks/useI18n.js";
6
+ import { cn } from "../../utils/index.js";
7
7
  import { VStack } from "../layout/index.js";
8
8
  import { Text } from "../typography/Text.js";
9
9
  const UXEmpty = forwardRef((props, ref)=>{
@@ -13,7 +13,7 @@ const UXEmpty = forwardRef((props, ref)=>{
13
13
  ref: ref,
14
14
  center: true,
15
15
  gap: 1,
16
- className: cn('w-full h-full', className),
16
+ className: cn('h-full w-full', className),
17
17
  ...restProps,
18
18
  children: [
19
19
  /*#__PURE__*/ jsx(EmptyIcon, {
@@ -1,8 +1,8 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import "react";
3
- import { cn } from "@heroui/theme";
4
3
  import CircleQuestionIcon from "@particle-network/icons/web/CircleQuestionIcon";
5
4
  import { Center, UXPopover, UXPopoverContent, UXPopoverTrigger, UXTooltip } from "../index.js";
5
+ import { cn } from "../../utils/index.js";
6
6
  const UXHint = (props)=>{
7
7
  const { content, children, buttonClassName, iconClassName, triggerType = 'hover', ...restProps } = props;
8
8
  const renderTriggerContent = ()=>/*#__PURE__*/ jsx(Center, {
@@ -5,11 +5,11 @@ export declare const UXInput: React.ForwardRefExoticComponent<(Omit<Omit<import(
5
5
  as?: import("@heroui/system-rsc").As<any> | undefined;
6
6
  } & {
7
7
  variant?: "flat" | "bordered" | undefined;
8
- textAlign?: "center" | "left" | "right" | undefined;
8
+ textAlign?: "right" | "left" | "center" | undefined;
9
9
  isColorText?: boolean | undefined;
10
- color?: "default" | "success" | "secondary" | "primary" | "danger" | "warning" | "bullish" | "bearish" | undefined;
10
+ color?: "secondary" | "primary" | "success" | "warning" | "danger" | "bullish" | "bearish" | "default" | undefined;
11
11
  size?: "sm" | "md" | "lg" | undefined;
12
- radius?: "sm" | "md" | "lg" | "none" | "full" | undefined;
12
+ radius?: "full" | "sm" | "md" | "lg" | "none" | undefined;
13
13
  labelPlacement?: "inside" | undefined;
14
14
  fullWidth?: boolean | undefined;
15
15
  isClearable?: boolean | undefined;
@@ -21,11 +21,11 @@ export declare const UXInput: React.ForwardRefExoticComponent<(Omit<Omit<import(
21
21
  as?: import("@heroui/system-rsc").As<any> | undefined;
22
22
  } & {
23
23
  variant?: "flat" | "bordered" | undefined;
24
- textAlign?: "center" | "left" | "right" | undefined;
24
+ textAlign?: "right" | "left" | "center" | undefined;
25
25
  isColorText?: boolean | undefined;
26
- color?: "default" | "success" | "secondary" | "primary" | "danger" | "warning" | "bullish" | "bearish" | undefined;
26
+ color?: "secondary" | "primary" | "success" | "warning" | "danger" | "bullish" | "bearish" | "default" | undefined;
27
27
  size?: "sm" | "md" | "lg" | undefined;
28
- radius?: "sm" | "md" | "lg" | "none" | "full" | undefined;
28
+ radius?: "full" | "sm" | "md" | "lg" | "none" | undefined;
29
29
  labelPlacement?: "inside" | undefined;
30
30
  fullWidth?: boolean | undefined;
31
31
  isClearable?: boolean | undefined;
@@ -2,11 +2,11 @@ declare const ExtendedInput: import("react").ForwardRefExoticComponent<(Omit<imp
2
2
  as?: import("@heroui/system-rsc").As<any> | undefined;
3
3
  } & {
4
4
  variant?: "flat" | "bordered" | undefined;
5
- textAlign?: "center" | "left" | "right" | undefined;
5
+ textAlign?: "right" | "left" | "center" | undefined;
6
6
  isColorText?: boolean | undefined;
7
- color?: "default" | "success" | "secondary" | "primary" | "danger" | "warning" | "bullish" | "bearish" | undefined;
7
+ color?: "secondary" | "primary" | "success" | "warning" | "danger" | "bullish" | "bearish" | "default" | undefined;
8
8
  size?: "sm" | "md" | "lg" | undefined;
9
- radius?: "sm" | "md" | "lg" | "none" | "full" | undefined;
9
+ radius?: "full" | "sm" | "md" | "lg" | "none" | undefined;
10
10
  labelPlacement?: "inside" | undefined;
11
11
  fullWidth?: boolean | undefined;
12
12
  isClearable?: boolean | undefined;
@@ -18,11 +18,11 @@ declare const ExtendedInput: import("react").ForwardRefExoticComponent<(Omit<imp
18
18
  as?: import("@heroui/system-rsc").As<any> | undefined;
19
19
  } & {
20
20
  variant?: "flat" | "bordered" | undefined;
21
- textAlign?: "center" | "left" | "right" | undefined;
21
+ textAlign?: "right" | "left" | "center" | undefined;
22
22
  isColorText?: boolean | undefined;
23
- color?: "default" | "success" | "secondary" | "primary" | "danger" | "warning" | "bullish" | "bearish" | undefined;
23
+ color?: "secondary" | "primary" | "success" | "warning" | "danger" | "bullish" | "bearish" | "default" | undefined;
24
24
  size?: "sm" | "md" | "lg" | undefined;
25
- radius?: "sm" | "md" | "lg" | "none" | "full" | undefined;
25
+ radius?: "full" | "sm" | "md" | "lg" | "none" | undefined;
26
26
  labelPlacement?: "inside" | undefined;
27
27
  fullWidth?: boolean | undefined;
28
28
  isClearable?: boolean | undefined;
@@ -40,21 +40,21 @@ const ExtendedRadio = extendVariants(Radio, {
40
40
  sm: {
41
41
  wrapper: 'w-2.5 h-2.5 border-small',
42
42
  control: 'w-1.5 h-1.5',
43
- labelWrapper: 'ml-sm',
43
+ labelWrapper: 'ms-1',
44
44
  label: '!text-body3 font-medium',
45
45
  description: 'text-tiny text-foreground-100'
46
46
  },
47
47
  md: {
48
48
  wrapper: 'w-3 h-3 border-small',
49
49
  control: 'w-1.5 h-1.5',
50
- labelWrapper: 'ml-2',
50
+ labelWrapper: 'ms-1',
51
51
  label: '!text-body2 font-medium',
52
52
  description: 'text-tiny text-foreground-100'
53
53
  },
54
54
  lg: {
55
55
  wrapper: 'w-[14px] h-[14px] border-small',
56
56
  control: 'w-2 h-2',
57
- labelWrapper: 'ml-2',
57
+ labelWrapper: 'ms-1',
58
58
  label: '!text-body1 font-medium',
59
59
  description: 'text-small text-foreground-100'
60
60
  }
@@ -134,7 +134,7 @@ interface Props extends HTMLHeroUIProps {
134
134
  export type UseSliderProps = Omit<Props, keyof ValueBase<SliderValue>> & AriaSliderProps & SliderVariantProps;
135
135
  export declare function useSlider(originalProps: UseSliderProps): {
136
136
  Component: import("@heroui/system-rsc").As<any>;
137
- state: import("@react-stately/slider").SliderState;
137
+ state: import("react-stately").SliderState;
138
138
  value: any;
139
139
  domRef: React.RefObject<HTMLElement>;
140
140
  label: React.ReactNode;
@@ -2,11 +2,11 @@ import { useCallback, useMemo, useRef } from "react";
2
2
  import { filterDOMProps, useDOMRef } from "@heroui/react-utils";
3
3
  import { mergeProps, objectToDeps, warn } from "@heroui/shared-utils";
4
4
  import { mapPropsVariants, useProviderContext } from "@heroui/system";
5
- import { cn } from "@heroui/theme";
6
5
  import { useLocale, useNumberFormatter } from "@react-aria/i18n";
7
6
  import { useHover } from "@react-aria/interactions";
8
7
  import { useSlider } from "@react-aria/slider";
9
8
  import { useSliderState } from "@react-stately/slider";
9
+ import { cn } from "../../utils/index.js";
10
10
  import { slider } from "./slider-theme.js";
11
11
  function use_slider_useSlider(originalProps) {
12
12
  const globalContext = useProviderContext();
@@ -1,15 +1,11 @@
1
1
  import React from 'react';
2
- import { type UXForegroundColor } from '@particle-network/ui-shared';
3
2
  import { type SquareProps } from '../layout';
4
3
  export interface UXSpinnerProps extends SquareProps {
5
- /**
6
- * 颜色
7
- */
8
- color?: UXForegroundColor | 'currentColor';
9
4
  /**
10
5
  * 动画持续时间(毫秒)
11
6
  * @default 400
12
7
  */
13
8
  duration?: number;
9
+ iconClassName?: string;
14
10
  }
15
11
  export declare const UXSpinner: React.FC<UXSpinnerProps>;
@@ -1,13 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useRef, useState } from "react";
3
- import { cn } from "@heroui/theme";
4
- import { colorToClassName } from "@particle-network/ui-shared";
3
+ import { cn } from "../../utils/index.js";
5
4
  import { Square } from "../layout/index.js";
6
5
  import { SpinnerIcon } from "./SpinnerIcon.js";
7
- const UXSpinner = ({ size = 18, color = 'primary', duration = 400, className, style, ...restProps })=>{
6
+ const UXSpinner = ({ size = 18, duration = 400, className, iconClassName, style, ...restProps })=>{
8
7
  const [currentIndex, setCurrentIndex] = useState(0);
9
8
  const animationRef = useRef(null);
10
- const iconClassName = 'currentColor' === color ? void 0 : colorToClassName[color];
11
9
  useEffect(()=>{
12
10
  const stepDuration = duration / 12;
13
11
  const animate = ()=>{
@@ -23,6 +21,7 @@ const UXSpinner = ({ size = 18, color = 'primary', duration = 400, className, st
23
21
  ]);
24
22
  return /*#__PURE__*/ jsx(Square, {
25
23
  size: size,
24
+ color: "primary",
26
25
  className: cn('inline-flex', className),
27
26
  style: style,
28
27
  ...restProps,
@@ -4,14 +4,14 @@ export type UXSwitchProps = React.ComponentPropsWithRef<typeof ExtendedSwitch>;
4
4
  export declare const UXSwitch: React.ForwardRefExoticComponent<(Omit<Omit<import("@heroui/system-rsc").OmitCommonProps<Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, keyof import("@heroui/switch").SwitchProps> & import("@heroui/switch").SwitchProps & {
5
5
  as?: import("@heroui/system-rsc").As<any> | undefined;
6
6
  } & {
7
- color?: "success" | "primary" | "danger" | "warning" | "bullish" | "bearish" | "contrast" | undefined;
7
+ color?: "primary" | "success" | "warning" | "danger" | "bullish" | "bearish" | "contrast" | undefined;
8
8
  size?: "sm" | "md" | "lg" | undefined;
9
9
  isDisabled?: boolean | undefined;
10
10
  disableAnimation?: boolean | undefined;
11
11
  }, "ref"> & React.RefAttributes<HTMLInputElement>, "ref"> | Omit<Omit<import("@heroui/system-rsc").OmitCommonProps<Omit<Omit<any, "ref">, never>, keyof import("@heroui/switch").SwitchProps> & import("@heroui/switch").SwitchProps & {
12
12
  as?: import("@heroui/system-rsc").As<any> | undefined;
13
13
  } & {
14
- color?: "success" | "primary" | "danger" | "warning" | "bullish" | "bearish" | "contrast" | undefined;
14
+ color?: "primary" | "success" | "warning" | "danger" | "bullish" | "bearish" | "contrast" | undefined;
15
15
  size?: "sm" | "md" | "lg" | undefined;
16
16
  isDisabled?: boolean | undefined;
17
17
  disableAnimation?: boolean | undefined;
@@ -1,14 +1,14 @@
1
1
  declare const ExtendedSwitch: import("react").ForwardRefExoticComponent<(Omit<import("@heroui/system-rsc").OmitCommonProps<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, keyof import("@heroui/switch").SwitchProps> & import("@heroui/switch").SwitchProps & {
2
2
  as?: import("@heroui/system-rsc").As<any> | undefined;
3
3
  } & {
4
- color?: "success" | "primary" | "danger" | "warning" | "bullish" | "bearish" | "contrast" | undefined;
4
+ color?: "primary" | "success" | "warning" | "danger" | "bullish" | "bearish" | "contrast" | undefined;
5
5
  size?: "sm" | "md" | "lg" | undefined;
6
6
  isDisabled?: boolean | undefined;
7
7
  disableAnimation?: boolean | undefined;
8
8
  }, "ref"> | Omit<import("@heroui/system-rsc").OmitCommonProps<Omit<Omit<any, "ref">, never>, keyof import("@heroui/switch").SwitchProps> & import("@heroui/switch").SwitchProps & {
9
9
  as?: import("@heroui/system-rsc").As<any> | undefined;
10
10
  } & {
11
- color?: "success" | "primary" | "danger" | "warning" | "bullish" | "bearish" | "contrast" | undefined;
11
+ color?: "primary" | "success" | "warning" | "danger" | "bullish" | "bearish" | "contrast" | undefined;
12
12
  size?: "sm" | "md" | "lg" | undefined;
13
13
  isDisabled?: boolean | undefined;
14
14
  disableAnimation?: boolean | undefined;
@@ -48,9 +48,9 @@ const ExtendedSwitch = extendVariants(Switch, {
48
48
  },
49
49
  size: {
50
50
  sm: {
51
- wrapper: 'w-5 h-3 px-0.5',
51
+ wrapper: 'w-5 h-3 px-0.5 bg-cursor',
52
52
  thumb: [
53
- 'w-2 h-2 text-tiny',
53
+ 'w-2 h-2 text-tiny shadow-none',
54
54
  'group-data-[selected=true]:ms-2'
55
55
  ],
56
56
  endContent: 'text-tiny',
@@ -58,9 +58,9 @@ const ExtendedSwitch = extendVariants(Switch, {
58
58
  label: 'text-body3 font-medium ms-sm'
59
59
  },
60
60
  md: {
61
- wrapper: 'w-6 h-3.5 px-[3px]',
61
+ wrapper: 'w-6 h-3.5 px-[3px] bg-cursor',
62
62
  thumb: [
63
- 'w-2.5 h-2.5 text-small',
63
+ 'w-2.5 h-2.5 text-small shadow-none',
64
64
  'group-data-[selected=true]:ms-2'
65
65
  ],
66
66
  endContent: 'text-small',
@@ -68,9 +68,9 @@ const ExtendedSwitch = extendVariants(Switch, {
68
68
  label: 'text-body3 font-medium ms-sm'
69
69
  },
70
70
  lg: {
71
- wrapper: 'w-[34px] h-5 px-[3px]',
71
+ wrapper: 'w-[34px] h-5 px-[3px] bg-cursor',
72
72
  thumb: [
73
- 'w-3.5 h-3.5 text-medium',
73
+ 'w-3.5 h-3.5 text-medium shadow-none',
74
74
  'group-data-[selected=true]:ms-3.5'
75
75
  ],
76
76
  endContent: 'text-medium',
@@ -252,9 +252,9 @@ const tabsClasses = {
252
252
  color: 'default',
253
253
  class: {
254
254
  cursor: [
255
- 'bg-tertiary dark:bg-tertiary'
255
+ 'bg-cursor dark:bg-cursor'
256
256
  ],
257
- tabContent: 'group-data-[selected=true]:text-tertiary-foreground'
257
+ tabContent: 'group-data-[selected=true]:text-cursor-foreground'
258
258
  }
259
259
  },
260
260
  {
@@ -264,9 +264,9 @@ const tabsClasses = {
264
264
  color: 'default',
265
265
  class: {
266
266
  cursor: [
267
- 'bg-tertiary'
267
+ 'bg-cursor'
268
268
  ],
269
- tabContent: 'group-data-[selected=true]:text-tertiary-foreground'
269
+ tabContent: 'group-data-[selected=true]:text-cursor-foreground'
270
270
  }
271
271
  },
272
272
  {
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 默认字体
3
+ */
4
+ export declare const DEFAULT_FONT_FAMILY = "Inter,system-ui,sans-serif,\"Microsoft YaHei\"";
5
+ /**
6
+ * 预加载所有主题字体的 Google Fonts CSS
7
+ * 包含所有可能用到的字体,一次性加载,避免切换主题时重复加载
8
+ */
9
+ export declare const PRELOAD_FONTS_URL = "https://fonts.googleapis.com/css2?family=Geist:wght@100..900&family=IBM+Plex+Sans:ital,wght@0,100..700;1,100..700&display=swap";
@@ -0,0 +1,3 @@
1
+ const DEFAULT_FONT_FAMILY = 'Inter,system-ui,sans-serif,"Microsoft YaHei"';
2
+ const PRELOAD_FONTS_URL = 'https://fonts.googleapis.com/css2?family=Geist:wght@100..900&family=IBM+Plex+Sans:ital,wght@0,100..700;1,100..700&display=swap';
3
+ export { DEFAULT_FONT_FAMILY, PRELOAD_FONTS_URL };
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const CustomThemeConfig: React.FC;
@@ -0,0 +1,171 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { DEFAULT_THEME_ID, themeData } from "@particle-network/ui-shared";
4
+ import { produce } from "immer";
5
+ import { useI18n, useLang } from "../../hooks/index.js";
6
+ import { HStack, VStack } from "../layout/index.js";
7
+ import { Text } from "../typography/Text.js";
8
+ import { UXButton } from "../UXButton/index.js";
9
+ import { UXColorPicker } from "../UXColorPicker/index.js";
10
+ import { UXSelect, UXSelectItem } from "../UXSelect/index.js";
11
+ import { UXTab, UXTabs } from "../UXTabs/index.js";
12
+ import { useTheme } from "./use-theme.js";
13
+ const COLOR_CATEGORIES = {
14
+ basic: [
15
+ 'primary',
16
+ 'bullish',
17
+ 'bearish'
18
+ ],
19
+ background: [
20
+ 'bgDefault',
21
+ 'bg400',
22
+ 'bg300',
23
+ 'bg200',
24
+ 'cursor',
25
+ 'overlay',
26
+ 'divider'
27
+ ],
28
+ text: [
29
+ 'foreground',
30
+ 'secondary',
31
+ 'tertiary'
32
+ ],
33
+ candle: [
34
+ 'candleUp',
35
+ 'candleBorderUp',
36
+ 'candleWickUp',
37
+ 'candleDown',
38
+ 'candleBorderDown',
39
+ 'candleWickDown'
40
+ ],
41
+ signal: [
42
+ 'success',
43
+ 'danger',
44
+ 'warning',
45
+ 'alert',
46
+ 'blue'
47
+ ]
48
+ };
49
+ const CustomThemeConfig = ()=>{
50
+ const { lang } = useLang();
51
+ const i18n = useI18n();
52
+ const { theme, setTheme, setCustomTheme } = useTheme();
53
+ const baseThemes = useMemo(()=>themeData.filter((t)=>'custom' !== t.id), []);
54
+ const baseThemeId = theme.baseThemeId || DEFAULT_THEME_ID;
55
+ const baseTheme = useMemo(()=>themeData.find((t)=>t.id === baseThemeId) || themeData.find((t)=>t.id === DEFAULT_THEME_ID), [
56
+ baseThemeId
57
+ ]);
58
+ const handleBaseThemeChange = (themeId)=>{
59
+ const selectedBaseTheme = themeData.find((t)=>t.id === themeId);
60
+ if (selectedBaseTheme) {
61
+ const updatedTheme = {
62
+ ...theme,
63
+ baseThemeId: themeId,
64
+ colorScheme: selectedBaseTheme.colorScheme,
65
+ colorVariables: selectedBaseTheme.colorVariables
66
+ };
67
+ setTheme(updatedTheme);
68
+ setCustomTheme(updatedTheme);
69
+ }
70
+ };
71
+ const handleColorChange = (color, value)=>{
72
+ const updatedTheme = produce(theme, (draft)=>{
73
+ draft.colorVariables[color] = value;
74
+ });
75
+ setTheme(updatedTheme);
76
+ setCustomTheme(updatedTheme);
77
+ };
78
+ const handleSwapUpDown = ()=>{
79
+ const updatedTheme = produce(theme, (draft)=>{
80
+ const { bullish, bearish, candleUp, candleDown, candleWickUp, candleWickDown, candleBorderUp, candleBorderDown } = draft.colorVariables;
81
+ draft.colorVariables.bullish = bearish;
82
+ draft.colorVariables.bearish = bullish;
83
+ draft.colorVariables.candleUp = candleDown;
84
+ draft.colorVariables.candleDown = candleUp;
85
+ draft.colorVariables.candleWickUp = candleWickDown;
86
+ draft.colorVariables.candleWickDown = candleWickUp;
87
+ draft.colorVariables.candleBorderUp = candleBorderDown;
88
+ draft.colorVariables.candleBorderDown = candleBorderUp;
89
+ });
90
+ setTheme(updatedTheme);
91
+ setCustomTheme(updatedTheme);
92
+ };
93
+ const getColorValue = (color)=>theme.colorVariables[color] || baseTheme.colorVariables[color] || '#000000';
94
+ const renderColorItem = (color, label)=>{
95
+ const value = getColorValue(color);
96
+ const isCustomized = void 0 !== theme.colorVariables[color] && theme.colorVariables[color] !== baseTheme.colorVariables[color];
97
+ return /*#__PURE__*/ jsxs(HStack, {
98
+ justify: "between",
99
+ children: [
100
+ /*#__PURE__*/ jsx(Text, {
101
+ color: "secondary",
102
+ children: label
103
+ }),
104
+ /*#__PURE__*/ jsx(UXColorPicker, {
105
+ value: value,
106
+ isChanged: isCustomized,
107
+ onValueChange: (newValue)=>handleColorChange(color, newValue),
108
+ onReset: ()=>handleColorChange(color, baseTheme.colorVariables[color])
109
+ })
110
+ ]
111
+ }, color);
112
+ };
113
+ return /*#__PURE__*/ jsxs(VStack, {
114
+ gap: "lg",
115
+ children: [
116
+ /*#__PURE__*/ jsxs(HStack, {
117
+ justify: "between",
118
+ children: [
119
+ /*#__PURE__*/ jsx(Text, {
120
+ body1Bold: true,
121
+ children: i18n.theme.custom.title
122
+ }),
123
+ /*#__PURE__*/ jsx(UXButton, {
124
+ variant: "text",
125
+ color: "primary",
126
+ onPress: handleSwapUpDown,
127
+ children: i18n.theme.custom.swapUpDown
128
+ })
129
+ ]
130
+ }),
131
+ /*#__PURE__*/ jsxs(HStack, {
132
+ justify: "between",
133
+ children: [
134
+ /*#__PURE__*/ jsx(Text, {
135
+ color: "secondary",
136
+ children: i18n.theme.custom.preset
137
+ }),
138
+ /*#__PURE__*/ jsx(UXSelect, {
139
+ className: "min-w-48",
140
+ selectedKeys: [
141
+ baseThemeId
142
+ ],
143
+ onSelectionChange: (keys)=>{
144
+ const selectedKey = Array.from(keys)[0];
145
+ if (selectedKey) handleBaseThemeChange(selectedKey);
146
+ },
147
+ children: baseThemes.map((t)=>/*#__PURE__*/ jsx(UXSelectItem, {
148
+ children: 'zh' === lang ? t.zhName : t.enName
149
+ }, t.id))
150
+ })
151
+ ]
152
+ }),
153
+ /*#__PURE__*/ jsx(UXTabs, {
154
+ fullWidth: true,
155
+ variant: "switch",
156
+ children: Object.entries(COLOR_CATEGORIES).map(([category, colors])=>/*#__PURE__*/ jsx(UXTab, {
157
+ title: i18n.theme.custom.categories[category],
158
+ children: /*#__PURE__*/ jsx(VStack, {
159
+ gap: "md",
160
+ className: "pt-md",
161
+ children: colors.map((color)=>{
162
+ const label = i18n.colors[color] || color;
163
+ return renderColorItem(color, label);
164
+ })
165
+ })
166
+ }, category))
167
+ })
168
+ ]
169
+ });
170
+ };
171
+ export { CustomThemeConfig };