@particle-network/ui-react 0.3.0-beta.8 → 0.3.0
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.
- package/dist/components/UXButton/button-theme.js +9 -9
- package/dist/components/UXCopy/index.d.ts +21 -0
- package/dist/components/UXCopy/index.js +54 -0
- package/dist/components/UXCopy/utils.d.ts +1 -0
- package/dist/components/UXCopy/utils.js +5 -0
- package/dist/components/UXSpinner/spinner.d.ts +1 -1
- package/dist/components/UXSpinner/spinner.js +4 -6
- package/dist/components/UXToast/index.d.ts +16 -1
- package/dist/components/UXToast/index.js +105 -1
- package/dist/components/UXTooltip/index.js +10 -1
- package/dist/components/UXTooltip/tooltip.extend.d.ts +15 -15
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/typography/Text.js +4 -1
- package/dist/components/typography/Text.type.d.ts +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useI18n.d.ts +6 -0
- package/dist/hooks/useI18n.js +12 -0
- package/dist/hooks/useLang.js +19 -18
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/detect.d.ts +2 -0
- package/dist/utils/detect.js +7 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/input-classes.js +11 -11
- package/package.json +4 -2
|
@@ -33,11 +33,11 @@ const button_theme_button = tv({
|
|
|
33
33
|
text: 'bg-transparent min-w-0 w-auto h-auto px-0'
|
|
34
34
|
},
|
|
35
35
|
size: {
|
|
36
|
-
xs: 'gap-2 rounded-
|
|
37
|
-
sm: 'gap-2 rounded-
|
|
38
|
-
md: 'gap-2 rounded-
|
|
39
|
-
lg: 'gap-2 rounded-
|
|
40
|
-
auto: 'min-w-min rounded-
|
|
36
|
+
xs: 'gap-2 rounded-[6px] !text-body3 min-w-min font-medium [&_[aria-label="Loading"]>div]:size-3',
|
|
37
|
+
sm: 'gap-2 rounded-[6px] !text-body3 min-w-min font-medium [&_[aria-label="Loading"]>div]:size-3',
|
|
38
|
+
md: 'gap-2 rounded-[6px] text-tiny min-w-min font-medium [&_[aria-label="Loading"]>div]:size-4',
|
|
39
|
+
lg: 'gap-2 rounded-[10px] text-medium min-w-min font-medium [&_[aria-label="Loading"]>div]:size-6',
|
|
40
|
+
auto: 'min-w-min rounded-[10px]'
|
|
41
41
|
},
|
|
42
42
|
color: {
|
|
43
43
|
default: '',
|
|
@@ -52,10 +52,10 @@ const button_theme_button = tv({
|
|
|
52
52
|
},
|
|
53
53
|
radius: {
|
|
54
54
|
none: 'rounded-none',
|
|
55
|
-
xs: 'rounded-
|
|
56
|
-
sm: 'rounded-
|
|
57
|
-
md: 'rounded-
|
|
58
|
-
lg: 'rounded-
|
|
55
|
+
xs: 'rounded-[4px]',
|
|
56
|
+
sm: 'rounded-[6px]',
|
|
57
|
+
md: 'rounded-[10px]',
|
|
58
|
+
lg: 'rounded-[14px]',
|
|
59
59
|
full: 'rounded-full'
|
|
60
60
|
},
|
|
61
61
|
fullWidth: {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface CommonProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
copyText?: string | number;
|
|
5
|
+
toastText?: string;
|
|
6
|
+
withTooltip?: boolean;
|
|
7
|
+
tooltipContent?: string;
|
|
8
|
+
}
|
|
9
|
+
interface UXCopyProps extends CommonProps {
|
|
10
|
+
children: React.ReactElement;
|
|
11
|
+
}
|
|
12
|
+
interface AddressProps extends CommonProps {
|
|
13
|
+
startContent?: React.ReactNode;
|
|
14
|
+
withCopyIcon?: boolean;
|
|
15
|
+
children: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const UXCopy: React.FC<UXCopyProps> & {
|
|
18
|
+
Address: React.FC<AddressProps>;
|
|
19
|
+
};
|
|
20
|
+
export declare const Address: React.FC<AddressProps>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import react from "react";
|
|
3
|
+
import { cn } from "@heroui/theme";
|
|
4
|
+
import CopyIcon from "@particle-network/icons/web/CopyIcon";
|
|
5
|
+
import copy_to_clipboard from "copy-to-clipboard";
|
|
6
|
+
import { useI18n } from "../../hooks/useI18n.js";
|
|
7
|
+
import { toast } from "../UXToast/index.js";
|
|
8
|
+
import { UXTooltip } from "../UXTooltip/index.js";
|
|
9
|
+
import { shortAddress } from "./utils.js";
|
|
10
|
+
const UXCopy = ({ className, copyText, toastText, withTooltip, tooltipContent, children })=>{
|
|
11
|
+
const i18n = useI18n();
|
|
12
|
+
const handleCopy = ()=>{
|
|
13
|
+
try {
|
|
14
|
+
copy_to_clipboard(String(copyText));
|
|
15
|
+
toast.success(toastText || i18n.copy.success);
|
|
16
|
+
} catch (error) {
|
|
17
|
+
toast.error(`${i18n.copy.error}${error instanceof Error ? error.message : String(error)}`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const childrenWithProps = /*#__PURE__*/ react.cloneElement(children, {
|
|
21
|
+
onClick: handleCopy
|
|
22
|
+
});
|
|
23
|
+
return /*#__PURE__*/ jsx(UXTooltip, {
|
|
24
|
+
isDisabled: !withTooltip,
|
|
25
|
+
content: tooltipContent || i18n.copy.copy,
|
|
26
|
+
placement: "bottom",
|
|
27
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
28
|
+
className: cn('cursor-pointer', className),
|
|
29
|
+
children: childrenWithProps
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
const Address = ({ children, copyText = children, tooltipContent = children, startContent, withCopyIcon, ...props })=>{
|
|
34
|
+
const i18n = useI18n();
|
|
35
|
+
return /*#__PURE__*/ jsx(UXCopy, {
|
|
36
|
+
tooltipContent: tooltipContent,
|
|
37
|
+
copyText: copyText,
|
|
38
|
+
toastText: `${i18n.copy.address}${children}`,
|
|
39
|
+
...props,
|
|
40
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
41
|
+
className: "flex items-center gap-1 hover:opacity-70 text-body2 font-medium",
|
|
42
|
+
children: [
|
|
43
|
+
startContent,
|
|
44
|
+
shortAddress(children),
|
|
45
|
+
withCopyIcon && /*#__PURE__*/ jsx(CopyIcon, {
|
|
46
|
+
size: 14
|
|
47
|
+
})
|
|
48
|
+
]
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
UXCopy.displayName = 'UXCopy';
|
|
53
|
+
UXCopy.Address = Address;
|
|
54
|
+
export { Address, UXCopy };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const shortAddress: (address: string | undefined | null, chars?: number, endChars?: number) => string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { cn } from "@heroui/theme";
|
|
4
|
-
import {
|
|
4
|
+
import { colorToClassName } from "@particle-network/ui-shared";
|
|
5
5
|
import { Square } from "../layout/index.js";
|
|
6
6
|
import { SpinnerIcon } from "./SpinnerIcon.js";
|
|
7
|
-
const UXSpinner = ({ size = 18, color = 'primary', duration =
|
|
7
|
+
const UXSpinner = ({ size = 18, color = 'primary', duration = 400, className, style, ...restProps })=>{
|
|
8
8
|
const [currentIndex, setCurrentIndex] = useState(0);
|
|
9
9
|
const animationRef = useRef(null);
|
|
10
|
-
const
|
|
10
|
+
const iconClassName = 'currentColor' === color ? void 0 : colorToClassName[color];
|
|
11
11
|
useEffect(()=>{
|
|
12
12
|
const stepDuration = duration / 12;
|
|
13
13
|
const animate = ()=>{
|
|
@@ -29,9 +29,7 @@ const UXSpinner = ({ size = 18, color = 'primary', duration = 1000, className, s
|
|
|
29
29
|
children: /*#__PURE__*/ jsx(SpinnerIcon, {
|
|
30
30
|
width: size,
|
|
31
31
|
height: size,
|
|
32
|
-
|
|
33
|
-
color: actualColor
|
|
34
|
-
},
|
|
32
|
+
className: iconClassName,
|
|
35
33
|
currentIndex: currentIndex
|
|
36
34
|
})
|
|
37
35
|
});
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ToastProps } from '@heroui/toast';
|
|
2
|
+
export type UXToastType = 'success' | 'error' | 'loading';
|
|
3
|
+
export type UXToastProps = Partial<ToastProps> & {
|
|
4
|
+
type: UXToastType;
|
|
5
|
+
};
|
|
6
|
+
export declare const UXToastProvider: () => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const toast: {
|
|
8
|
+
success: (message: string, props?: Partial<ToastProps>) => string | null;
|
|
9
|
+
error: (message: string, props?: Partial<ToastProps>) => string | null;
|
|
10
|
+
loading: (message: string, props?: Partial<ToastProps>) => string | null;
|
|
11
|
+
show: (props?: Partial<ToastProps> & {
|
|
12
|
+
type: UXToastType;
|
|
13
|
+
}) => string | null;
|
|
14
|
+
closeAll: () => void;
|
|
15
|
+
close: (key: string) => void;
|
|
16
|
+
};
|
|
@@ -1 +1,105 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ToastProvider, addToast, closeAll, closeToast } from "@heroui/toast";
|
|
3
|
+
import CircleCheckIcon from "@particle-network/icons/web/CircleCheckIcon";
|
|
4
|
+
import CircleCloseIcon from "@particle-network/icons/web/CircleCloseIcon";
|
|
5
|
+
import CloseIcon from "@particle-network/icons/web/CloseIcon";
|
|
6
|
+
import { hasLongWord } from "../../utils/index.js";
|
|
7
|
+
import { UXSpinner } from "../UXSpinner/index.js";
|
|
8
|
+
const UXToastProvider = ()=>/*#__PURE__*/ jsx(ToastProvider, {
|
|
9
|
+
disableAnimation: true,
|
|
10
|
+
placement: "top-center",
|
|
11
|
+
maxVisibleToasts: 4,
|
|
12
|
+
toastOffset: 40,
|
|
13
|
+
toastProps: {
|
|
14
|
+
timeout: 4000
|
|
15
|
+
},
|
|
16
|
+
regionProps: {
|
|
17
|
+
className: 'items-center py-10'
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const getIcon = (type)=>{
|
|
21
|
+
if ('success' === type) return /*#__PURE__*/ jsx(CircleCheckIcon, {
|
|
22
|
+
size: 18
|
|
23
|
+
});
|
|
24
|
+
if ('error' === type) return /*#__PURE__*/ jsx(CircleCloseIcon, {
|
|
25
|
+
size: 18
|
|
26
|
+
});
|
|
27
|
+
if ('loading' === type) return /*#__PURE__*/ jsx(UXSpinner, {
|
|
28
|
+
size: 18
|
|
29
|
+
});
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
32
|
+
const show = (props)=>{
|
|
33
|
+
const { type, hideCloseButton, variant, classNames, description, ...toastProps } = props ?? {};
|
|
34
|
+
const { base, description: descriptionClassName, icon, loadingComponent, content, closeButton, ...restClassNames } = classNames ?? {};
|
|
35
|
+
return addToast({
|
|
36
|
+
classNames: {
|
|
37
|
+
base: [
|
|
38
|
+
'bg-tertiary rounded-xl px-3.5 py-3 shadow-none border-none !w-fit max-w-[90vw] md:max-w-[400px]',
|
|
39
|
+
!hideCloseButton && 'pr-12',
|
|
40
|
+
'flat' === variant && 'success' === type && 'bg-[#0E3728]',
|
|
41
|
+
'flat' === variant && 'error' === type && 'bg-[#501D1D]',
|
|
42
|
+
base
|
|
43
|
+
],
|
|
44
|
+
description: [
|
|
45
|
+
'text-foreground text-xs font-medium me-0 leading-4 line-clamp-4',
|
|
46
|
+
'flat' === variant && 'text-white',
|
|
47
|
+
hasLongWord(description) && 'break-all',
|
|
48
|
+
descriptionClassName
|
|
49
|
+
],
|
|
50
|
+
icon: [
|
|
51
|
+
'shrink-0 h-5 w-5',
|
|
52
|
+
'success' === type && 'text-success',
|
|
53
|
+
'error' === type && 'text-danger',
|
|
54
|
+
'loading' === type && 'text-primary',
|
|
55
|
+
icon
|
|
56
|
+
],
|
|
57
|
+
loadingComponent: [
|
|
58
|
+
'text-primary h-5 w-5',
|
|
59
|
+
loadingComponent
|
|
60
|
+
],
|
|
61
|
+
content: [
|
|
62
|
+
'gap-x-2.5',
|
|
63
|
+
content
|
|
64
|
+
],
|
|
65
|
+
closeButton: [
|
|
66
|
+
'absolute right-3 top-1/2 -translate-y-1/2',
|
|
67
|
+
hideCloseButton ? 'opacity-0' : 'opacity-100',
|
|
68
|
+
closeButton
|
|
69
|
+
],
|
|
70
|
+
...restClassNames
|
|
71
|
+
},
|
|
72
|
+
description,
|
|
73
|
+
icon: getIcon(type),
|
|
74
|
+
closeIcon: /*#__PURE__*/ jsx(CloseIcon, {
|
|
75
|
+
className: 'flat' === variant ? 'text-white' : 'text-foreground'
|
|
76
|
+
}),
|
|
77
|
+
loadingComponent: /*#__PURE__*/ jsx(UXSpinner, {
|
|
78
|
+
size: 18
|
|
79
|
+
}),
|
|
80
|
+
timeout: 'loading' === type ? 1 / 0 : 3000,
|
|
81
|
+
...toastProps
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const toast = {
|
|
85
|
+
success: (message, props)=>show({
|
|
86
|
+
type: 'success',
|
|
87
|
+
description: message,
|
|
88
|
+
...props
|
|
89
|
+
}),
|
|
90
|
+
error: (message, props)=>show({
|
|
91
|
+
type: 'error',
|
|
92
|
+
description: message,
|
|
93
|
+
...props
|
|
94
|
+
}),
|
|
95
|
+
loading: (message, props)=>show({
|
|
96
|
+
type: 'loading',
|
|
97
|
+
description: message,
|
|
98
|
+
timeout: 1 / 0,
|
|
99
|
+
...props
|
|
100
|
+
}),
|
|
101
|
+
show,
|
|
102
|
+
closeAll: closeAll,
|
|
103
|
+
close: closeToast
|
|
104
|
+
};
|
|
105
|
+
export { UXToastProvider, toast };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
+
import { hasLongWord } from "../../utils/index.js";
|
|
3
4
|
import tooltip_extend from "./tooltip.extend.js";
|
|
4
5
|
const renderContent = (content)=>{
|
|
5
6
|
if (!content) return null;
|
|
@@ -13,9 +14,17 @@ const renderContent = (content)=>{
|
|
|
13
14
|
]);
|
|
14
15
|
};
|
|
15
16
|
const UXTooltip = (props)=>{
|
|
16
|
-
const { content, ...restProps } = props;
|
|
17
|
+
const { content, classNames, ...restProps } = props;
|
|
18
|
+
const { content: contentClassName, ...restClassNames } = classNames ?? {};
|
|
17
19
|
return /*#__PURE__*/ jsx(tooltip_extend, {
|
|
18
20
|
content: renderContent(content),
|
|
21
|
+
classNames: {
|
|
22
|
+
content: [
|
|
23
|
+
hasLongWord(content) && 'break-all',
|
|
24
|
+
contentClassName
|
|
25
|
+
],
|
|
26
|
+
...restClassNames
|
|
27
|
+
},
|
|
19
28
|
...restProps
|
|
20
29
|
});
|
|
21
30
|
};
|
|
@@ -290,25 +290,25 @@ declare const ExtendedTooltip: import("react").ForwardRefExoticComponent<Omit<{
|
|
|
290
290
|
as?: import("@heroui/system-rsc").As<any> | undefined;
|
|
291
291
|
onClose?: ((() => void) & (() => void)) | undefined;
|
|
292
292
|
classNames?: import("@heroui/theme").SlotsToClasses<"content" | "base" | "arrow"> | undefined;
|
|
293
|
+
placement?: import("@heroui/aria-utils").OverlayPlacement | undefined;
|
|
294
|
+
motionProps?: Omit<import("framer-motion").HTMLMotionProps<"div">, "ref"> | undefined;
|
|
295
|
+
delay?: number | undefined;
|
|
296
|
+
triggerScaleOnOpen?: boolean | undefined;
|
|
297
|
+
isTriggerDisabled?: boolean | undefined;
|
|
298
|
+
closeDelay?: number | undefined;
|
|
299
|
+
trigger?: "focus" | undefined;
|
|
300
|
+
portalContainer?: Element | undefined;
|
|
301
|
+
updatePositionDeps?: any[] | undefined;
|
|
293
302
|
isOpen?: boolean | undefined;
|
|
303
|
+
isDismissable?: boolean | undefined;
|
|
304
|
+
shouldCloseOnBlur?: boolean | undefined;
|
|
305
|
+
isKeyboardDismissDisabled?: boolean | undefined;
|
|
306
|
+
shouldCloseOnInteractOutside?: ((element: Element) => boolean) | undefined;
|
|
294
307
|
defaultOpen?: boolean | undefined;
|
|
295
308
|
onOpenChange?: ((isOpen: boolean) => void) | undefined;
|
|
296
|
-
|
|
297
|
-
containerPadding?: number | undefined;
|
|
309
|
+
showArrow?: boolean | undefined;
|
|
298
310
|
crossOffset?: number | undefined;
|
|
299
311
|
shouldFlip?: boolean | undefined;
|
|
300
|
-
|
|
301
|
-
shouldCloseOnInteractOutside?: ((element: Element) => boolean) | undefined;
|
|
302
|
-
isDismissable?: boolean | undefined;
|
|
303
|
-
shouldCloseOnBlur?: boolean | undefined;
|
|
304
|
-
showArrow?: boolean | undefined;
|
|
305
|
-
updatePositionDeps?: any[] | undefined;
|
|
306
|
-
triggerScaleOnOpen?: boolean | undefined;
|
|
307
|
-
isTriggerDisabled?: boolean | undefined;
|
|
308
|
-
motionProps?: Omit<import("framer-motion").HTMLMotionProps<"div">, "ref"> | undefined;
|
|
309
|
-
portalContainer?: Element | undefined;
|
|
310
|
-
trigger?: "focus" | undefined;
|
|
311
|
-
delay?: number | undefined;
|
|
312
|
-
closeDelay?: number | undefined;
|
|
312
|
+
containerPadding?: number | undefined;
|
|
313
313
|
}, "ref"> & import("react").RefAttributes<import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>>>;
|
|
314
314
|
export default ExtendedTooltip;
|
package/dist/components/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./UXButton/index.js";
|
|
|
5
5
|
export * from "./UXCalendar/index.js";
|
|
6
6
|
export * from "./UXCheckbox/index.js";
|
|
7
7
|
export * from "./UXChip/index.js";
|
|
8
|
+
export * from "./UXCopy/index.js";
|
|
8
9
|
export * from "./UXDatePicker/index.js";
|
|
9
10
|
export * from "./UXDateRangePicker/index.js";
|
|
10
11
|
export * from "./UXDivider/index.js";
|
|
@@ -4,7 +4,10 @@ import { cn } from "@heroui/theme";
|
|
|
4
4
|
import { textClasses } from "./Text.type.js";
|
|
5
5
|
const Text = /*#__PURE__*/ forwardRef(({ variant = 'body2Bold', fontWeight, color, lineHeight, align, className, h1, h2, h3, body1, body1Bold, body2, body2Bold, body3, body3Bold, caption1, caption1Bold, ...props }, ref)=>/*#__PURE__*/ jsx("span", {
|
|
6
6
|
ref: ref,
|
|
7
|
-
|
|
7
|
+
style: {
|
|
8
|
+
color: color?.startsWith('#') ? color : void 0
|
|
9
|
+
},
|
|
10
|
+
className: cn(textClasses.variant[variant], h1 && textClasses.variant.h1, h2 && textClasses.variant.h2, h3 && textClasses.variant.h3, body1 && textClasses.variant.body1, body1Bold && textClasses.variant.body1Bold, body2 && textClasses.variant.body2, body2Bold && textClasses.variant.body2Bold, body3 && textClasses.variant.body3, body3Bold && textClasses.variant.body3Bold, caption1 && textClasses.variant.caption1, caption1Bold && textClasses.variant.caption1Bold, textClasses.fontWeight[fontWeight], !color?.startsWith('#') && textClasses.color[color], textClasses.lineHeight[lineHeight], textClasses.align[align], className),
|
|
8
11
|
...props
|
|
9
12
|
}));
|
|
10
13
|
Text.displayName = 'UX.Text';
|
|
@@ -89,7 +89,7 @@ export interface TextProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
|
89
89
|
* | warning | #FF9821 | #FF9821 |
|
|
90
90
|
* | gold | #FFB800 | #F38300 |
|
|
91
91
|
*/
|
|
92
|
-
color?: UXForegroundColor
|
|
92
|
+
color?: UXForegroundColor | `#${string}`;
|
|
93
93
|
lineHeight?: TextLineHeight;
|
|
94
94
|
align?: TextAlign;
|
|
95
95
|
}
|
package/dist/hooks/useI18n.d.ts
CHANGED
package/dist/hooks/useI18n.js
CHANGED
|
@@ -2,11 +2,23 @@ import { useLang } from "./useLang.js";
|
|
|
2
2
|
const en = {
|
|
3
3
|
table: {
|
|
4
4
|
emptyContent: 'No data available.'
|
|
5
|
+
},
|
|
6
|
+
copy: {
|
|
7
|
+
copy: 'Copy',
|
|
8
|
+
success: 'Copied successfully!',
|
|
9
|
+
error: 'Copy failed: ',
|
|
10
|
+
address: 'Address copied: '
|
|
5
11
|
}
|
|
6
12
|
};
|
|
7
13
|
const zh = {
|
|
8
14
|
table: {
|
|
9
15
|
emptyContent: '暂无数据'
|
|
16
|
+
},
|
|
17
|
+
copy: {
|
|
18
|
+
copy: '复制',
|
|
19
|
+
success: '复制成功!',
|
|
20
|
+
error: '复制失败:',
|
|
21
|
+
address: '地址已复制:'
|
|
10
22
|
}
|
|
11
23
|
};
|
|
12
24
|
const useI18n = ()=>{
|
package/dist/hooks/useLang.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
-
|
|
2
|
+
function getLangFromHtml() {
|
|
3
|
+
if ('undefined' == typeof window) return 'en';
|
|
4
|
+
const htmlLang = document.documentElement.lang || document.documentElement.getAttribute('lang');
|
|
5
|
+
if ('zh' === htmlLang || htmlLang?.startsWith('zh')) return 'zh';
|
|
6
|
+
return 'en';
|
|
7
|
+
}
|
|
3
8
|
function useLang() {
|
|
4
|
-
const [lang, setLang] = useState(
|
|
5
|
-
if ('undefined' != typeof window) {
|
|
6
|
-
const value = localStorage.getItem(STORAGE_KEY) ?? 'en';
|
|
7
|
-
return value;
|
|
8
|
-
}
|
|
9
|
-
return 'en';
|
|
10
|
-
});
|
|
9
|
+
const [lang, setLang] = useState(getLangFromHtml);
|
|
11
10
|
useEffect(()=>{
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const observer = new MutationObserver((mutations)=>{
|
|
12
|
+
mutations.forEach((mutation)=>{
|
|
13
|
+
if ('attributes' === mutation.type && ('lang' === mutation.attributeName || 'data-lang' === mutation.attributeName)) setLang(getLangFromHtml());
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
observer.observe(document.documentElement, {
|
|
17
|
+
attributes: true,
|
|
18
|
+
attributeFilter: [
|
|
19
|
+
'lang'
|
|
20
|
+
]
|
|
21
|
+
});
|
|
20
22
|
return ()=>{
|
|
21
|
-
|
|
22
|
-
window.removeEventListener('ux-lang-change', handleCustomStorageChange);
|
|
23
|
+
observer.disconnect();
|
|
23
24
|
};
|
|
24
25
|
}, []);
|
|
25
26
|
return lang;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { absoluteFullClasses, baseStyles, collapseAdjacentVariantBorders, dataFocusVisibleClasses, focusVisibleClasses, groupDataFocusVisibleClasses, hiddenInputClasses, ringClasses, translateCenterClasses, } from './classes';
|
|
2
|
+
export * from './detect';
|
|
2
3
|
export * from './input-classes';
|
|
3
4
|
export { colorVariants } from './variants';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { absoluteFullClasses, baseStyles, collapseAdjacentVariantBorders, dataFocusVisibleClasses, focusVisibleClasses, groupDataFocusVisibleClasses, hiddenInputClasses, ringClasses, translateCenterClasses } from "./classes.js";
|
|
2
2
|
import { colorVariants } from "./variants.js";
|
|
3
|
+
export * from "./detect.js";
|
|
3
4
|
export * from "./input-classes.js";
|
|
4
5
|
export { absoluteFullClasses, baseStyles, collapseAdjacentVariantBorders, colorVariants, dataFocusVisibleClasses, focusVisibleClasses, groupDataFocusVisibleClasses, hiddenInputClasses, ringClasses, translateCenterClasses };
|
|
@@ -41,7 +41,7 @@ const inputClasses = {
|
|
|
41
41
|
color: {
|
|
42
42
|
default: {
|
|
43
43
|
inputWrapper: 'caret-foreground',
|
|
44
|
-
input: 'text-foreground
|
|
44
|
+
input: 'text-foreground'
|
|
45
45
|
},
|
|
46
46
|
primary: {
|
|
47
47
|
inputWrapper: 'caret-primary',
|
|
@@ -49,7 +49,7 @@ const inputClasses = {
|
|
|
49
49
|
},
|
|
50
50
|
secondary: {
|
|
51
51
|
inputWrapper: 'caret-foreground',
|
|
52
|
-
input: 'text-
|
|
52
|
+
input: 'text-secondary'
|
|
53
53
|
},
|
|
54
54
|
success: {
|
|
55
55
|
inputWrapper: 'caret-success',
|
|
@@ -185,9 +185,9 @@ const inputClasses = {
|
|
|
185
185
|
'lg'
|
|
186
186
|
],
|
|
187
187
|
class: {
|
|
188
|
-
inputWrapper: 'bg-background-200 text-
|
|
188
|
+
inputWrapper: 'bg-background-200 text-tertiary font-medium',
|
|
189
189
|
label: 'font-medium',
|
|
190
|
-
input: '!outline-none placeholder:text-
|
|
190
|
+
input: '!outline-none placeholder:text-tertiary dark:placeholder:text-tertiary placeholder:font-medium font-medium text-foreground'
|
|
191
191
|
}
|
|
192
192
|
},
|
|
193
193
|
{
|
|
@@ -195,7 +195,7 @@ const inputClasses = {
|
|
|
195
195
|
color: 'default',
|
|
196
196
|
isInvalid: false,
|
|
197
197
|
class: {
|
|
198
|
-
inputWrapper: 'group-data-[focus=true]:border-foreground
|
|
198
|
+
inputWrapper: 'group-data-[focus=true]:border-foreground'
|
|
199
199
|
}
|
|
200
200
|
},
|
|
201
201
|
{
|
|
@@ -211,7 +211,7 @@ const inputClasses = {
|
|
|
211
211
|
color: 'secondary',
|
|
212
212
|
isInvalid: false,
|
|
213
213
|
class: {
|
|
214
|
-
inputWrapper: 'group-data-[focus=true]:border-
|
|
214
|
+
inputWrapper: 'group-data-[focus=true]:border-secondary'
|
|
215
215
|
}
|
|
216
216
|
},
|
|
217
217
|
{
|
|
@@ -260,9 +260,9 @@ const inputClasses = {
|
|
|
260
260
|
isInvalid: false,
|
|
261
261
|
class: {
|
|
262
262
|
inputWrapper: [
|
|
263
|
-
'border-foreground
|
|
264
|
-
'data-[hover=true]:border-foreground
|
|
265
|
-
'group-data-[focus=true]:border-foreground
|
|
263
|
+
'border-foreground',
|
|
264
|
+
'data-[hover=true]:border-foreground',
|
|
265
|
+
'group-data-[focus=true]:border-foreground'
|
|
266
266
|
]
|
|
267
267
|
}
|
|
268
268
|
},
|
|
@@ -284,9 +284,9 @@ const inputClasses = {
|
|
|
284
284
|
isInvalid: false,
|
|
285
285
|
class: {
|
|
286
286
|
inputWrapper: [
|
|
287
|
-
'border-
|
|
287
|
+
'border-secondary',
|
|
288
288
|
'data-[hover=true]:bg-background-200/70',
|
|
289
|
-
'group-data-[focus=true]:border-
|
|
289
|
+
'group-data-[focus=true]:border-secondary'
|
|
290
290
|
]
|
|
291
291
|
}
|
|
292
292
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@particle-network/ui-react",
|
|
3
|
-
"version": "0.3.0
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -48,7 +48,9 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"ahooks": "^3.9.4",
|
|
51
|
-
"
|
|
51
|
+
"copy-to-clipboard": "^3.3.3",
|
|
52
|
+
"@particle-network/icons": "0.3.0",
|
|
53
|
+
"@particle-network/ui-shared": "0.2.0"
|
|
52
54
|
},
|
|
53
55
|
"scripts": {
|
|
54
56
|
"build": "rslib build",
|