@particle-network/ui-react 0.3.0-beta.9 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/UXButton/button-theme.js +10 -10
- 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/UXDatePicker/index.js +1 -1
- package/dist/components/UXDropdown/dropdown-item.js +1 -1
- package/dist/components/UXDropdown/dropdown.js +1 -1
- package/dist/components/UXPopover/popover.extend.js +1 -1
- package/dist/components/UXSelect/index.js +1 -1
- package/dist/components/UXSpinner/spinner.d.ts +1 -1
- package/dist/components/UXSpinner/spinner.js +1 -1
- package/dist/components/UXToast/index.d.ts +2 -2
- package/dist/components/UXToast/index.js +29 -15
- package/dist/components/UXTooltip/index.js +10 -1
- package/dist/components/UXTooltip/tooltip.extend.d.ts +15 -15
- package/dist/components/UXTooltip/tooltip.extend.js +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- 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/package.json +6 -5
|
@@ -15,7 +15,7 @@ const button_theme_button = tv({
|
|
|
15
15
|
'whitespace-nowrap',
|
|
16
16
|
'min-w-max',
|
|
17
17
|
'font-normal',
|
|
18
|
-
'
|
|
18
|
+
'antialiased',
|
|
19
19
|
'overflow-hidden',
|
|
20
20
|
'tap-highlight-transparent',
|
|
21
21
|
'transform-gpu data-[pressed=true]:scale-[0.97]',
|
|
@@ -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;
|
|
@@ -29,7 +29,7 @@ const UXDatePicker = ({ classNames, ...props })=>/*#__PURE__*/ jsx(DatePicker, {
|
|
|
29
29
|
popoverProps: {
|
|
30
30
|
classNames: {
|
|
31
31
|
base: 'before:bg-content1 before:shadow-box',
|
|
32
|
-
content: 'bg-content1 text-foreground-300 shadow-box'
|
|
32
|
+
content: 'bg-content1 text-foreground-300 shadow-box antialiased'
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
timeInputProps: {
|
|
@@ -17,7 +17,7 @@ const classes = {
|
|
|
17
17
|
},
|
|
18
18
|
flat: {
|
|
19
19
|
base: '!outline-none min-h-8 px-md rounded-small text-foreground-300 !outline-none data-[selected=true]:text-foreground gap-1',
|
|
20
|
-
title: 'text-tiny font-medium',
|
|
20
|
+
title: 'text-tiny font-medium antialiased',
|
|
21
21
|
selectedIcon: '[&>svg>polyline]:stroke-[2.5]'
|
|
22
22
|
},
|
|
23
23
|
shadow: {
|
|
@@ -8,7 +8,7 @@ const UXDropdown = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
8
8
|
ref: ref,
|
|
9
9
|
classNames: {
|
|
10
10
|
content: [
|
|
11
|
-
'text-tiny p-2.5 text-foreground-300 rounded-medium no-scrollbar shadow-box',
|
|
11
|
+
'text-tiny p-2.5 text-foreground-300 rounded-medium no-scrollbar shadow-box antialiased',
|
|
12
12
|
content
|
|
13
13
|
],
|
|
14
14
|
...restClassNames
|
|
@@ -16,7 +16,7 @@ const ExtendedPopover = extendVariants(Popover, {
|
|
|
16
16
|
color: {
|
|
17
17
|
default: {
|
|
18
18
|
base: 'before:bg-content1 before:shadow-box',
|
|
19
|
-
content: 'bg-content1 text-foreground-300 shadow-box text-tiny'
|
|
19
|
+
content: 'bg-content1 text-foreground-300 shadow-box text-tiny antialiased'
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
},
|
|
@@ -35,7 +35,7 @@ const UXSelect = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
35
35
|
},
|
|
36
36
|
itemClasses: {
|
|
37
37
|
base: '!outline-none min-h-8 px-md rounded-small text-foreground-300 !outline-none data-[hover=true]:bg-background-200 data-[selected=true]:text-foreground gap-1',
|
|
38
|
-
title: 'text-tiny font-medium',
|
|
38
|
+
title: 'text-tiny font-medium antialiased',
|
|
39
39
|
selectedIcon: '[&>svg>polyline]:stroke-[2.5]'
|
|
40
40
|
}
|
|
41
41
|
},
|
|
@@ -4,7 +4,7 @@ import { cn } from "@heroui/theme";
|
|
|
4
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
10
|
const iconClassName = 'currentColor' === color ? void 0 : colorToClassName[color];
|
|
@@ -4,7 +4,7 @@ export type UXToastProps = Partial<ToastProps> & {
|
|
|
4
4
|
type: UXToastType;
|
|
5
5
|
};
|
|
6
6
|
export declare const UXToastProvider: () => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const toast: {
|
|
8
8
|
success: (message: string, props?: Partial<ToastProps>) => string | null;
|
|
9
9
|
error: (message: string, props?: Partial<ToastProps>) => string | null;
|
|
10
10
|
loading: (message: string, props?: Partial<ToastProps>) => string | null;
|
|
@@ -12,5 +12,5 @@ export declare const UXToast: {
|
|
|
12
12
|
type: UXToastType;
|
|
13
13
|
}) => string | null;
|
|
14
14
|
closeAll: () => void;
|
|
15
|
-
|
|
15
|
+
close: (key: string) => void;
|
|
16
16
|
};
|
|
@@ -3,13 +3,18 @@ import { ToastProvider, addToast, closeAll, closeToast } from "@heroui/toast";
|
|
|
3
3
|
import CircleCheckIcon from "@particle-network/icons/web/CircleCheckIcon";
|
|
4
4
|
import CircleCloseIcon from "@particle-network/icons/web/CircleCloseIcon";
|
|
5
5
|
import CloseIcon from "@particle-network/icons/web/CloseIcon";
|
|
6
|
+
import { hasLongWord } from "../../utils/index.js";
|
|
6
7
|
import { UXSpinner } from "../UXSpinner/index.js";
|
|
7
8
|
const UXToastProvider = ()=>/*#__PURE__*/ jsx(ToastProvider, {
|
|
9
|
+
disableAnimation: true,
|
|
8
10
|
placement: "top-center",
|
|
9
|
-
maxVisibleToasts:
|
|
11
|
+
maxVisibleToasts: 4,
|
|
10
12
|
toastOffset: 40,
|
|
11
13
|
toastProps: {
|
|
12
14
|
timeout: 4000
|
|
15
|
+
},
|
|
16
|
+
regionProps: {
|
|
17
|
+
className: 'items-center py-10'
|
|
13
18
|
}
|
|
14
19
|
});
|
|
15
20
|
const getIcon = (type)=>{
|
|
@@ -25,37 +30,46 @@ const getIcon = (type)=>{
|
|
|
25
30
|
return null;
|
|
26
31
|
};
|
|
27
32
|
const show = (props)=>{
|
|
28
|
-
const { type, hideCloseButton, variant, classNames, ...toastProps } = props ?? {};
|
|
33
|
+
const { type, hideCloseButton, variant, classNames, description, ...toastProps } = props ?? {};
|
|
34
|
+
const { base, description: descriptionClassName, icon, loadingComponent, content, closeButton, ...restClassNames } = classNames ?? {};
|
|
29
35
|
return addToast({
|
|
30
36
|
classNames: {
|
|
31
37
|
base: [
|
|
32
|
-
'bg-tertiary rounded-xl px-3.5 py-3 shadow-none !w-fit max-w-[
|
|
38
|
+
'bg-tertiary rounded-xl px-3.5 py-3 shadow-none border-none !w-fit max-w-[90vw] md:max-w-[400px]',
|
|
33
39
|
!hideCloseButton && 'pr-12',
|
|
34
40
|
'flat' === variant && 'success' === type && 'bg-[#0E3728]',
|
|
35
|
-
'flat' === variant && 'error' === type && 'bg-[#501D1D]'
|
|
41
|
+
'flat' === variant && 'error' === type && 'bg-[#501D1D]',
|
|
42
|
+
base
|
|
36
43
|
],
|
|
37
44
|
description: [
|
|
38
|
-
'text-foreground text-xs font-medium me-0 leading-4',
|
|
39
|
-
'flat' === variant && 'text-white'
|
|
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
|
|
40
49
|
],
|
|
41
50
|
icon: [
|
|
42
51
|
'shrink-0 h-5 w-5',
|
|
43
52
|
'success' === type && 'text-success',
|
|
44
53
|
'error' === type && 'text-danger',
|
|
45
|
-
'loading' === type && 'text-primary'
|
|
54
|
+
'loading' === type && 'text-primary',
|
|
55
|
+
icon
|
|
46
56
|
],
|
|
47
57
|
loadingComponent: [
|
|
48
|
-
'text-primary h-5 w-5'
|
|
58
|
+
'text-primary h-5 w-5',
|
|
59
|
+
loadingComponent
|
|
49
60
|
],
|
|
50
61
|
content: [
|
|
51
|
-
'gap-x-2.5'
|
|
62
|
+
'gap-x-2.5',
|
|
63
|
+
content
|
|
52
64
|
],
|
|
53
65
|
closeButton: [
|
|
54
66
|
'absolute right-3 top-1/2 -translate-y-1/2',
|
|
55
|
-
hideCloseButton ? 'opacity-0' : 'opacity-100'
|
|
67
|
+
hideCloseButton ? 'opacity-0' : 'opacity-100',
|
|
68
|
+
closeButton
|
|
56
69
|
],
|
|
57
|
-
...
|
|
70
|
+
...restClassNames
|
|
58
71
|
},
|
|
72
|
+
description,
|
|
59
73
|
icon: getIcon(type),
|
|
60
74
|
closeIcon: /*#__PURE__*/ jsx(CloseIcon, {
|
|
61
75
|
className: 'flat' === variant ? 'text-white' : 'text-foreground'
|
|
@@ -63,11 +77,11 @@ const show = (props)=>{
|
|
|
63
77
|
loadingComponent: /*#__PURE__*/ jsx(UXSpinner, {
|
|
64
78
|
size: 18
|
|
65
79
|
}),
|
|
66
|
-
timeout: 'loading' === type ? 1 / 0 :
|
|
80
|
+
timeout: 'loading' === type ? 1 / 0 : 3000,
|
|
67
81
|
...toastProps
|
|
68
82
|
});
|
|
69
83
|
};
|
|
70
|
-
const
|
|
84
|
+
const toast = {
|
|
71
85
|
success: (message, props)=>show({
|
|
72
86
|
type: 'success',
|
|
73
87
|
description: message,
|
|
@@ -86,6 +100,6 @@ const UXToast = {
|
|
|
86
100
|
}),
|
|
87
101
|
show,
|
|
88
102
|
closeAll: closeAll,
|
|
89
|
-
|
|
103
|
+
close: closeToast
|
|
90
104
|
};
|
|
91
|
-
export {
|
|
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;
|
|
@@ -16,7 +16,7 @@ const ExtendedTooltip = extendVariants(Tooltip, {
|
|
|
16
16
|
color: {
|
|
17
17
|
default: {
|
|
18
18
|
base: 'before:bg-content1 before:shadow-box',
|
|
19
|
-
content: 'bg-content1 text-foreground-300 shadow-box text-tiny leading-1.4 break-words wrap-break-word'
|
|
19
|
+
content: 'bg-content1 text-foreground-300 shadow-box text-tiny leading-1.4 break-words wrap-break-word antialiased'
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
},
|
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";
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@particle-network/ui-react",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@types/react": "^19.1.10",
|
|
40
40
|
"react": "^19.1.0",
|
|
41
41
|
"typescript": "^5.8.3",
|
|
42
|
-
"@particle-network/
|
|
43
|
-
"@particle-network/
|
|
42
|
+
"@particle-network/lintstaged-config": "0.1.0",
|
|
43
|
+
"@particle-network/eslint-config": "0.3.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": ">=16.9.0",
|
|
@@ -48,8 +48,9 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"ahooks": "^3.9.4",
|
|
51
|
-
"
|
|
52
|
-
"@particle-network/icons": "0.3.0
|
|
51
|
+
"copy-to-clipboard": "^3.3.3",
|
|
52
|
+
"@particle-network/icons": "0.3.0",
|
|
53
|
+
"@particle-network/ui-shared": "0.2.0"
|
|
53
54
|
},
|
|
54
55
|
"scripts": {
|
|
55
56
|
"build": "rslib build",
|