@arcblock/ux 2.10.65 → 2.10.67
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/ActionButton/index.d.ts +1 -1
- package/lib/Alert/index.d.ts +1 -1
- package/lib/AnimationWaiter/index.d.ts +27 -15
- package/lib/AnimationWaiter/index.js +15 -14
- package/lib/Async/index.d.ts +50 -17
- package/lib/Badge/index.d.ts +1 -1
- package/lib/Badge/index.js +7 -1
- package/lib/BlockletContext/index.d.ts +12 -28
- package/lib/BlockletContext/index.js +3 -21
- package/lib/Button/wrap.d.ts +5 -3
- package/lib/Button/wrap.js +2 -1
- package/lib/ButtonGroup/index.d.ts +12 -2
- package/lib/ButtonGroup/index.js +13 -3
- package/lib/CardSelector/index.d.ts +11 -33
- package/lib/CardSelector/index.js +16 -32
- package/lib/Center/index.d.ts +6 -21
- package/lib/Center/index.js +2 -17
- package/lib/ClickToCopy/copy-button.d.ts +9 -26
- package/lib/ClickToCopy/copy-button.js +5 -17
- package/lib/ClickToCopy/hook.d.ts +11 -5
- package/lib/ClickToCopy/hook.js +3 -3
- package/lib/ClickToCopy/index.d.ts +18 -29
- package/lib/ClickToCopy/index.js +0 -13
- package/lib/CodeBlock/LightBox.d.ts +1 -1
- package/lib/CodeBlock/index.d.ts +7 -26
- package/lib/CodeBlock/index.js +4 -17
- package/lib/Colors/index.d.ts +2 -2
- package/lib/Colors/themes/default.d.ts +54 -61
- package/lib/Colors/themes/temp.d.ts +35 -35
- package/lib/ContactForm/index.d.ts +26 -30
- package/lib/ContactForm/index.js +7 -17
- package/lib/Dialog/confirm.d.ts +3 -3
- package/lib/Dialog/confirm.js +2 -2
- package/lib/Earth/index.d.ts +10 -1
- package/lib/Header/auto-hidden.d.ts +6 -11
- package/lib/Header/auto-hidden.js +0 -5
- package/lib/Header/header.d.ts +20 -51
- package/lib/Header/header.js +10 -42
- package/lib/Header/index.d.ts +2 -2
- package/lib/Header/responsive-header.d.ts +10 -22
- package/lib/Header/responsive-header.js +1 -13
- package/lib/Icon/image.d.ts +8 -36
- package/lib/Icon/image.js +6 -24
- package/lib/Icon/index.d.ts +9 -1
- package/lib/Icon/index.js +6 -25
- package/lib/NavMenu/index.d.ts +1 -1
- package/lib/NavMenu/nav-menu.d.ts +37 -51
- package/lib/NavMenu/nav-menu.js +47 -102
- package/lib/NavMenu/style.d.ts +8 -2
- package/lib/NavMenu/style.js +3 -1
- package/lib/PageScroller/index.d.ts +13 -1
- package/lib/Passport/passport.js +1 -1
- package/lib/PricingTable/index.d.ts +3 -1
- package/lib/RelativeTime/index.d.ts +1 -1
- package/lib/Screenshot/BaseScreenshot/index.js +1 -1
- package/lib/SplitButton/index.d.ts +0 -19
- package/lib/SplitButton/index.js +7 -27
- package/lib/TextCollapse/index.d.ts +10 -1
- package/lib/Theme/index.d.ts +5 -13
- package/lib/Theme/index.js +4 -11
- package/lib/Theme/theme-provider.d.ts +16 -18
- package/lib/Theme/theme.d.ts +37 -11
- package/lib/Theme/theme.js +13 -22
- package/lib/Util/constant.d.ts +31 -31
- package/lib/Util/deprecate.d.ts +7 -5
- package/lib/Util/federated.d.ts +21 -21
- package/lib/Util/federated.js +1 -1
- package/lib/Util/index.d.ts +59 -60
- package/lib/Util/index.js +16 -43
- package/lib/Util/passport.d.ts +6 -6
- package/lib/Util/wallet.d.ts +15 -3
- package/lib/WebWalletSWKeeper/index.js +1 -1
- package/lib/global.d.ts +13 -0
- package/lib/index.d.ts +4 -2
- package/lib/index.js +2 -2
- package/lib/type.d.ts +31 -1
- package/package.json +5 -5
- package/src/AnimationWaiter/index.jsx +15 -14
- package/src/Async/{index.jsx → index.tsx} +13 -4
- package/src/Badge/index.jsx +8 -1
- package/src/BlockletContext/{index.jsx → index.tsx} +17 -22
- package/src/Button/wrap.jsx +2 -1
- package/src/ButtonGroup/index.js +13 -3
- package/src/CardSelector/{index.jsx → index.tsx} +32 -33
- package/src/Center/index.tsx +33 -0
- package/src/ClickToCopy/{copy-button.jsx → copy-button.tsx} +15 -16
- package/src/ClickToCopy/{hook.js → hook.ts} +5 -5
- package/src/ClickToCopy/{index.jsx → index.tsx} +12 -17
- package/src/CodeBlock/{index.jsx → index.tsx} +15 -17
- package/src/ContactForm/{index.jsx → index.tsx} +47 -29
- package/src/Dialog/confirm.jsx +2 -2
- package/src/Header/{auto-hidden.jsx → auto-hidden.tsx} +6 -7
- package/src/Header/{header.jsx → header.tsx} +32 -46
- package/src/Header/{responsive-header.jsx → responsive-header.tsx} +9 -15
- package/src/Icon/{image.jsx → image.tsx} +19 -22
- package/src/Icon/{index.jsx → index.tsx} +22 -24
- package/src/NavMenu/{nav-menu.jsx → nav-menu.tsx} +161 -144
- package/src/NavMenu/{style.js → style.ts} +9 -1
- package/src/Passport/passport.jsx +1 -1
- package/src/Screenshot/BaseScreenshot/index.jsx +1 -1
- package/src/SplitButton/index.tsx +10 -23
- package/src/Theme/{index.js → index.ts} +6 -12
- package/src/Theme/{theme-provider.jsx → theme-provider.tsx} +10 -2
- package/src/Theme/{theme.js → theme.ts} +54 -23
- package/src/Util/{deprecate.jsx → deprecate.tsx} +8 -4
- package/src/Util/{federated.js → federated.ts} +3 -3
- package/src/Util/{index.js → index.ts} +85 -59
- package/src/Util/{passport.js → passport.ts} +2 -2
- package/src/Util/{wallet.js → wallet.ts} +1 -1
- package/src/WebWalletSWKeeper/index.jsx +1 -1
- package/src/global.d.ts +13 -0
- package/src/{index.js → index.ts} +2 -2
- package/src/type.d.ts +31 -1
- package/src/Center/index.jsx +0 -41
- /package/src/CodeBlock/{LightBox.jsx → LightBox.tsx} +0 -0
- /package/src/Colors/{index.js → index.ts} +0 -0
- /package/src/Colors/themes/{default.js → default.ts} +0 -0
- /package/src/Colors/themes/{temp.js → temp.ts} +0 -0
- /package/src/Header/{index.js → index.ts} +0 -0
- /package/src/NavMenu/{index.js → index.ts} +0 -0
- /package/src/Util/{constant.js → constant.ts} +0 -0
package/src/Dialog/confirm.jsx
CHANGED
@@ -10,9 +10,9 @@ import Dialog from './dialog';
|
|
10
10
|
* @typedef {{
|
11
11
|
* title: React.ReactNode,
|
12
12
|
* open: boolean,
|
13
|
-
* children: React.ReactNode,
|
14
13
|
* onConfirm: Function,
|
15
14
|
* onCancel: Function,
|
15
|
+
* children?: React.ReactNode,
|
16
16
|
* showCancelButton?: boolean,
|
17
17
|
* showCloseButton?: boolean,
|
18
18
|
* fullScreen?: boolean,
|
@@ -113,9 +113,9 @@ export default function Confirm({
|
|
113
113
|
Confirm.propTypes = {
|
114
114
|
title: PropTypes.node.isRequired,
|
115
115
|
open: PropTypes.bool.isRequired,
|
116
|
-
children: PropTypes.node.isRequired,
|
117
116
|
onConfirm: PropTypes.func.isRequired,
|
118
117
|
onCancel: PropTypes.func.isRequired,
|
118
|
+
children: PropTypes.node,
|
119
119
|
showCancelButton: PropTypes.bool,
|
120
120
|
showCloseButton: PropTypes.bool,
|
121
121
|
fullScreen: PropTypes.bool,
|
@@ -1,19 +1,18 @@
|
|
1
|
-
import
|
2
|
-
import Box from '@mui/material/Box';
|
1
|
+
import Box, { type BoxProps } from '@mui/material/Box';
|
3
2
|
|
4
3
|
import { styled } from '../Theme';
|
5
4
|
|
5
|
+
export interface AutoHiddenProps extends BoxProps {
|
6
|
+
height: number | string;
|
7
|
+
}
|
8
|
+
|
6
9
|
/**
|
7
10
|
* 一个容器组件, 当子元素 width 超出该容器时自动隐藏子元素, 必须设置明确的 height 值
|
8
11
|
*/
|
9
|
-
function AutoHidden({ height, ...rest }) {
|
12
|
+
function AutoHidden({ height, ...rest }: AutoHiddenProps) {
|
10
13
|
return <Root height={height} {...rest} />;
|
11
14
|
}
|
12
15
|
|
13
|
-
AutoHidden.propTypes = {
|
14
|
-
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
15
|
-
};
|
16
|
-
|
17
16
|
const Root = styled(Box)`
|
18
17
|
overflow: hidden;
|
19
18
|
&:before {
|
@@ -1,34 +1,52 @@
|
|
1
|
-
import
|
2
|
-
import { Box, Container } from '@mui/material';
|
1
|
+
import { Box, Container, type Breakpoint } from '@mui/material';
|
3
2
|
import { useRef, useState, useEffect } from 'react';
|
4
3
|
import AutoHidden from './auto-hidden';
|
5
4
|
import { styled } from '../Theme';
|
6
5
|
|
6
|
+
export interface HeaderProps extends React.HTMLAttributes<HTMLDivElement> {
|
7
|
+
/** logo img/svg, 可以包裹一个 a 标签 */
|
8
|
+
logo?: React.ReactNode;
|
9
|
+
/** 相当于 Title, 可以包裹一个 a 标签 */
|
10
|
+
brand?: React.ReactNode;
|
11
|
+
/** brand 右侧的内容区域, 可显示一个 badge 或 tag */
|
12
|
+
brandAddon?: React.ReactNode;
|
13
|
+
/** brand 下方的描述 */
|
14
|
+
description?: React.ReactNode;
|
15
|
+
/** 右侧区域, 可以放置 icons/actions/login 等 */
|
16
|
+
addons?: React.ReactNode;
|
17
|
+
/** logo 左侧内容 */
|
18
|
+
prepend?: React.ReactNode;
|
19
|
+
align?: 'left' | 'right';
|
20
|
+
maxWidth?: Breakpoint | false;
|
21
|
+
// eslint-disable-next-line no-unused-vars
|
22
|
+
homeLink?: string | ((brandContent: React.ReactNode) => React.ReactNode);
|
23
|
+
}
|
24
|
+
|
7
25
|
/**
|
8
26
|
* Header 组件
|
9
27
|
* TODO: Layout/dashboard 可以复用此处的 header
|
10
28
|
*/
|
11
29
|
function Header({
|
12
|
-
logo,
|
13
|
-
brand,
|
14
|
-
brandAddon,
|
15
|
-
description,
|
16
|
-
children,
|
17
|
-
addons,
|
18
|
-
prepend,
|
19
|
-
align,
|
30
|
+
logo = null,
|
31
|
+
brand = null,
|
32
|
+
brandAddon = null,
|
33
|
+
description = null,
|
34
|
+
children = null,
|
35
|
+
addons = null,
|
36
|
+
prepend = null,
|
37
|
+
align = 'left',
|
20
38
|
maxWidth,
|
21
|
-
homeLink,
|
39
|
+
homeLink = '/',
|
22
40
|
...rest
|
23
|
-
}) {
|
24
|
-
const logoRef = useRef();
|
41
|
+
}: HeaderProps) {
|
42
|
+
const logoRef = useRef<HTMLDivElement>(null);
|
25
43
|
const [brandWrapperMinWidth, setBrandWrapperMinWidth] = useState('0px');
|
26
44
|
const style = { minWidth: brandWrapperMinWidth };
|
27
45
|
|
28
46
|
useEffect(() => {
|
29
47
|
const { searchParams } = new URL(window.location.href);
|
30
48
|
if (searchParams.get('inviter')) {
|
31
|
-
window.localStorage.setItem('inviter', searchParams.get('inviter'));
|
49
|
+
window.localStorage.setItem('inviter', searchParams.get('inviter')!);
|
32
50
|
}
|
33
51
|
|
34
52
|
if (logoRef.current) {
|
@@ -78,38 +96,6 @@ function Header({
|
|
78
96
|
);
|
79
97
|
}
|
80
98
|
|
81
|
-
Header.propTypes = {
|
82
|
-
// logo img/svg, 可以包裹一个 a 标签
|
83
|
-
logo: PropTypes.node,
|
84
|
-
// 相当于 Title, 可以包裹一个 a 标签
|
85
|
-
brand: PropTypes.node,
|
86
|
-
// brand 右侧的内容区域, 可显示一个 badge 或 tag
|
87
|
-
brandAddon: PropTypes.node,
|
88
|
-
// brand 下方的描述
|
89
|
-
description: PropTypes.node,
|
90
|
-
children: PropTypes.node,
|
91
|
-
// 右侧区域, 可以放置 icons/actions/login 等
|
92
|
-
addons: PropTypes.node,
|
93
|
-
// logo 左侧内容
|
94
|
-
prepend: PropTypes.node,
|
95
|
-
align: PropTypes.oneOf(['left', 'right']),
|
96
|
-
maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', false])]),
|
97
|
-
homeLink: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
98
|
-
};
|
99
|
-
|
100
|
-
Header.defaultProps = {
|
101
|
-
logo: null,
|
102
|
-
brand: null,
|
103
|
-
brandAddon: null,
|
104
|
-
description: null,
|
105
|
-
children: null,
|
106
|
-
addons: null,
|
107
|
-
prepend: null,
|
108
|
-
align: 'left',
|
109
|
-
maxWidth: undefined,
|
110
|
-
homeLink: '/',
|
111
|
-
};
|
112
|
-
|
113
99
|
const Root = styled(Box)`
|
114
100
|
position: relative;
|
115
101
|
z-index: ${(props) => props.theme.zIndex.appBar};
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { useState } from 'react';
|
2
|
-
import PropTypes from 'prop-types';
|
3
2
|
import { useCreation, useReactive } from 'ahooks';
|
4
3
|
import MenuIcon from '@mui/icons-material/Menu';
|
5
4
|
import CloseIcon from '@mui/icons-material/Close';
|
@@ -9,6 +8,13 @@ import useMediaQuery from '@mui/material/useMediaQuery';
|
|
9
8
|
import Drawer from '@mui/material/Drawer';
|
10
9
|
import Header from './header';
|
11
10
|
import { styled, useTheme } from '../Theme';
|
11
|
+
import { type HeaderProps } from './header';
|
12
|
+
|
13
|
+
export interface ResponsiveHeaderProps extends Omit<HeaderProps, 'children'> {
|
14
|
+
menu?: React.ReactNode;
|
15
|
+
// eslint-disable-next-line no-unused-vars
|
16
|
+
children?: React.ReactNode | ((props: { isMobile: boolean; closeMenu: () => void }) => React.ReactNode);
|
17
|
+
}
|
12
18
|
|
13
19
|
/**
|
14
20
|
* ResponsiveHeader
|
@@ -17,7 +23,7 @@ import { styled, useTheme } from '../Theme';
|
|
17
23
|
*
|
18
24
|
* 注意: 暂时不要通过 display: none 隐藏 logo, https://blog.patw.me/archives/1820/inline-svg-same-id-and-display-none-issue/
|
19
25
|
*/
|
20
|
-
function ResponsiveHeader({ menu, prepend, children, ...rest }) {
|
26
|
+
function ResponsiveHeader({ menu, prepend, children, ...rest }: ResponsiveHeaderProps) {
|
21
27
|
const theme = useTheme();
|
22
28
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
23
29
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
@@ -85,7 +91,7 @@ function ResponsiveHeader({ menu, prepend, children, ...rest }) {
|
|
85
91
|
ModalProps={{
|
86
92
|
disablePortal: false,
|
87
93
|
keepMounted: true,
|
88
|
-
BackdropComponent:
|
94
|
+
BackdropComponent: undefined,
|
89
95
|
}}
|
90
96
|
anchor="top"
|
91
97
|
sx={{
|
@@ -106,18 +112,6 @@ function ResponsiveHeader({ menu, prepend, children, ...rest }) {
|
|
106
112
|
);
|
107
113
|
}
|
108
114
|
|
109
|
-
ResponsiveHeader.propTypes = {
|
110
|
-
...Header.PropTypes,
|
111
|
-
// 如果是 function, 则
|
112
|
-
// - 会传入一个 isMobile 参数, isMobile 为 true 时, 表示 children 会显示在 menu 中, 可以根据 isMobile 参数调整要渲染的内容, 比如如果 isMobile 为 true 则使用 inline 模式的 NavMenu (适用于移动端)
|
113
|
-
// - 会传入一个 closeMenu 参数, 可以关闭 menu
|
114
|
-
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
115
|
-
};
|
116
|
-
|
117
|
-
ResponsiveHeader.defaultProps = {
|
118
|
-
...Header.defaultProps,
|
119
|
-
};
|
120
|
-
|
121
115
|
const Root = styled(Header)`
|
122
116
|
.header-menu {
|
123
117
|
display: none;
|
@@ -1,9 +1,25 @@
|
|
1
|
-
import PropTypes from 'prop-types';
|
2
|
-
|
3
1
|
import Img from '../Img';
|
4
2
|
import { styled } from '../Theme';
|
5
3
|
|
6
|
-
export
|
4
|
+
export interface ImageIconProps extends React.HTMLAttributes<HTMLDivElement> {
|
5
|
+
name: string;
|
6
|
+
size?: number;
|
7
|
+
color?: string;
|
8
|
+
alt?: string;
|
9
|
+
prefix?: string;
|
10
|
+
showBadge?: boolean;
|
11
|
+
}
|
12
|
+
|
13
|
+
export default function ImageIcon({
|
14
|
+
name,
|
15
|
+
size = 36,
|
16
|
+
alt = '',
|
17
|
+
color = '#000000',
|
18
|
+
prefix = '/images',
|
19
|
+
showBadge = false,
|
20
|
+
style = {},
|
21
|
+
...rest
|
22
|
+
}: ImageIconProps) {
|
7
23
|
const src = `${prefix}/${name}-${color.replace(/^#/, '')}.png`;
|
8
24
|
return (
|
9
25
|
<Div style={{ width: size, height: size }}>
|
@@ -20,25 +36,6 @@ export default function ImageIcon({ name, size, alt, color, style, prefix, showB
|
|
20
36
|
);
|
21
37
|
}
|
22
38
|
|
23
|
-
ImageIcon.propTypes = {
|
24
|
-
name: PropTypes.string.isRequired,
|
25
|
-
size: PropTypes.number,
|
26
|
-
color: PropTypes.string,
|
27
|
-
alt: PropTypes.string,
|
28
|
-
style: PropTypes.object,
|
29
|
-
prefix: PropTypes.string,
|
30
|
-
showBadge: PropTypes.bool,
|
31
|
-
};
|
32
|
-
|
33
|
-
ImageIcon.defaultProps = {
|
34
|
-
size: 36,
|
35
|
-
color: '#000000',
|
36
|
-
alt: '',
|
37
|
-
style: {},
|
38
|
-
prefix: '/images',
|
39
|
-
showBadge: false,
|
40
|
-
};
|
41
|
-
|
42
39
|
const Div = styled('div')`
|
43
40
|
position: relative;
|
44
41
|
.badge-point {
|
@@ -1,6 +1,4 @@
|
|
1
1
|
import { forwardRef } from 'react';
|
2
|
-
import PropTypes from 'prop-types';
|
3
|
-
|
4
2
|
import colors from '../Colors';
|
5
3
|
import { styled } from '../Theme';
|
6
4
|
import { withDeprecated } from '../Util/deprecate';
|
@@ -11,8 +9,27 @@ const variants = {
|
|
11
9
|
solid: 'fas',
|
12
10
|
};
|
13
11
|
|
12
|
+
export interface IconProps extends React.HTMLAttributes<HTMLElement> {
|
13
|
+
name: string;
|
14
|
+
color?: string;
|
15
|
+
size?: number;
|
16
|
+
variant?: 'light' | 'regular' | 'solid';
|
17
|
+
rounded?: boolean;
|
18
|
+
forwardedRef?: React.ForwardedRef<HTMLElement>;
|
19
|
+
}
|
20
|
+
|
14
21
|
// eslint-disable-next-line react/prop-types
|
15
|
-
function Icon({
|
22
|
+
function Icon({
|
23
|
+
name,
|
24
|
+
color = colors.grey[900],
|
25
|
+
size = 24,
|
26
|
+
variant = 'light',
|
27
|
+
rounded = false,
|
28
|
+
style = {},
|
29
|
+
className = '',
|
30
|
+
forwardedRef,
|
31
|
+
...rest
|
32
|
+
}: IconProps) {
|
16
33
|
const content = (
|
17
34
|
<i
|
18
35
|
ref={forwardedRef}
|
@@ -32,26 +49,7 @@ function Icon({ name, color, size, variant, rounded, style, className, forwarded
|
|
32
49
|
return content;
|
33
50
|
}
|
34
51
|
|
35
|
-
|
36
|
-
name: PropTypes.string.isRequired,
|
37
|
-
className: PropTypes.string,
|
38
|
-
color: PropTypes.string,
|
39
|
-
rounded: PropTypes.bool,
|
40
|
-
variant: PropTypes.string,
|
41
|
-
size: PropTypes.number,
|
42
|
-
style: PropTypes.object,
|
43
|
-
};
|
44
|
-
|
45
|
-
Icon.defaultProps = {
|
46
|
-
rounded: false,
|
47
|
-
variant: 'light',
|
48
|
-
color: colors.grey[900],
|
49
|
-
className: '',
|
50
|
-
size: 24,
|
51
|
-
style: {},
|
52
|
-
};
|
53
|
-
|
54
|
-
const Span = styled('span')`
|
52
|
+
const Span = styled('span')<{ size: number; color: string }>`
|
55
53
|
width: ${(props) => props.size * 2}px;
|
56
54
|
height: ${(props) => props.size * 2}px;
|
57
55
|
border-radius: 50%;
|
@@ -69,6 +67,6 @@ const Span = styled('span')`
|
|
69
67
|
`;
|
70
68
|
|
71
69
|
export default withDeprecated(
|
72
|
-
forwardRef((props, ref) => <Icon {...props} forwardedRef={ref} />),
|
70
|
+
forwardRef<HTMLElement, IconProps>((props, ref) => <Icon {...props} forwardedRef={ref} />),
|
73
71
|
{ name: 'Icon', alternative: 'SVG icons' }
|
74
72
|
);
|