@arcblock/ux 2.13.35 → 2.13.37
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/lib/Tabs/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { type TabsProps as MuiTabsProps } from '@mui/material';
|
1
|
+
import { type TabsProps as MuiTabsProps, type TabProps } from '@mui/material';
|
2
2
|
interface TabsProps extends Omit<MuiTabsProps, 'variant' | 'onChange'> {
|
3
3
|
tabs: {
|
4
4
|
value: any;
|
@@ -8,6 +8,7 @@ interface TabsProps extends Omit<MuiTabsProps, 'variant' | 'onChange'> {
|
|
8
8
|
current: any;
|
9
9
|
onChange: (value: string) => void;
|
10
10
|
variant?: 'card' | 'line' | MuiTabsProps['variant'];
|
11
|
+
iconPosition?: TabProps['iconPosition'];
|
11
12
|
}
|
12
|
-
export default function Tabs({ tabs, current, onChange, variant, ...rest }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
13
|
+
export default function Tabs({ tabs, current, onChange, variant, iconPosition, ...rest }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
13
14
|
export {};
|
package/lib/Tabs/index.js
CHANGED
@@ -21,6 +21,7 @@ function CardTabs({
|
|
21
21
|
tabs,
|
22
22
|
current,
|
23
23
|
onChange,
|
24
|
+
iconPosition,
|
24
25
|
...rest
|
25
26
|
}) {
|
26
27
|
return /*#__PURE__*/_jsx(MuiTabs, {
|
@@ -74,7 +75,8 @@ function CardTabs({
|
|
74
75
|
className: classes.tab,
|
75
76
|
value: x.value,
|
76
77
|
label: x.label,
|
77
|
-
icon: x.icon
|
78
|
+
icon: x.icon,
|
79
|
+
iconPosition: iconPosition
|
78
80
|
}, x.value))
|
79
81
|
});
|
80
82
|
}
|
@@ -82,6 +84,7 @@ function LineTabs({
|
|
82
84
|
tabs,
|
83
85
|
current,
|
84
86
|
onChange,
|
87
|
+
iconPosition,
|
85
88
|
...rest
|
86
89
|
}) {
|
87
90
|
return /*#__PURE__*/_jsx(MuiTabs, {
|
@@ -140,7 +143,8 @@ function LineTabs({
|
|
140
143
|
className: classes.tab,
|
141
144
|
value: x.value,
|
142
145
|
label: x.label,
|
143
|
-
icon: x.icon
|
146
|
+
icon: x.icon,
|
147
|
+
iconPosition: iconPosition
|
144
148
|
}, x.value))
|
145
149
|
});
|
146
150
|
}
|
@@ -149,6 +153,7 @@ export default function Tabs({
|
|
149
153
|
current,
|
150
154
|
onChange,
|
151
155
|
variant,
|
156
|
+
iconPosition,
|
152
157
|
...rest
|
153
158
|
}) {
|
154
159
|
if (variant === 'card') {
|
@@ -156,7 +161,8 @@ export default function Tabs({
|
|
156
161
|
...rest,
|
157
162
|
tabs: tabs,
|
158
163
|
current: current,
|
159
|
-
onChange: onChange
|
164
|
+
onChange: onChange,
|
165
|
+
iconPosition: iconPosition
|
160
166
|
});
|
161
167
|
}
|
162
168
|
if (variant === 'line') {
|
@@ -164,7 +170,8 @@ export default function Tabs({
|
|
164
170
|
...rest,
|
165
171
|
tabs: tabs,
|
166
172
|
current: current,
|
167
|
-
onChange: onChange
|
173
|
+
onChange: onChange,
|
174
|
+
iconPosition: iconPosition
|
168
175
|
});
|
169
176
|
}
|
170
177
|
return /*#__PURE__*/_jsx(StyledMuiTabs, {
|
@@ -179,7 +186,8 @@ export default function Tabs({
|
|
179
186
|
className: classes.tab,
|
180
187
|
value: x.value,
|
181
188
|
label: x.label,
|
182
|
-
icon: x.icon
|
189
|
+
icon: x.icon,
|
190
|
+
iconPosition: iconPosition
|
183
191
|
}, x.value))
|
184
192
|
});
|
185
193
|
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import type { SxProps } from '@mui/material';
|
2
|
+
export declare const VERIFY_CODE_LENGTH = 6;
|
3
|
+
export default function VerificationCode({ length, code, onChange, onComplete, sx, }: {
|
4
|
+
length?: number;
|
5
|
+
code: string;
|
6
|
+
onChange?: (_code: string) => void;
|
7
|
+
onComplete?: (_code: string) => void;
|
8
|
+
sx?: SxProps;
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { useEffect } from 'react';
|
3
|
+
import { Box, TextField } from '@mui/material';
|
4
|
+
import trim from 'lodash/trim';
|
5
|
+
import noop from 'lodash/noop';
|
6
|
+
import { mergeSx } from '../Util/style';
|
7
|
+
export const VERIFY_CODE_LENGTH = 6;
|
8
|
+
export default function VerificationCode({
|
9
|
+
length = VERIFY_CODE_LENGTH,
|
10
|
+
code,
|
11
|
+
onChange = noop,
|
12
|
+
onComplete = noop,
|
13
|
+
sx
|
14
|
+
}) {
|
15
|
+
useEffect(() => {
|
16
|
+
if (code.length === length) {
|
17
|
+
onComplete?.(code);
|
18
|
+
}
|
19
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
20
|
+
}, [code, length]);
|
21
|
+
return /*#__PURE__*/_jsx(Box, {
|
22
|
+
sx: mergeSx({
|
23
|
+
width: '100%',
|
24
|
+
maxWidth: 360,
|
25
|
+
display: 'flex',
|
26
|
+
justifyContent: 'space-between',
|
27
|
+
gap: 1.5
|
28
|
+
}, sx),
|
29
|
+
children: [...Array(length)].map((_, index) => /*#__PURE__*/_jsx(TextField, {
|
30
|
+
id: `code-input-${index}`
|
31
|
+
// eslint-disable-next-line react/no-array-index-key
|
32
|
+
,
|
33
|
+
|
34
|
+
value: trim(code[index]) || '',
|
35
|
+
type: "number",
|
36
|
+
inputProps: {
|
37
|
+
maxLength: 1,
|
38
|
+
sx: {
|
39
|
+
textAlign: 'center',
|
40
|
+
fontSize: '1.5rem',
|
41
|
+
'&::-webkit-inner-spin-button, &::-webkit-outer-spin-button': {
|
42
|
+
WebkitAppearance: 'none',
|
43
|
+
margin: 0
|
44
|
+
}
|
45
|
+
},
|
46
|
+
autoComplete: 'off',
|
47
|
+
pattern: '[0-9]',
|
48
|
+
inputMode: 'numeric'
|
49
|
+
},
|
50
|
+
onChange: e => {
|
51
|
+
const newCode = code.split('');
|
52
|
+
newCode[index] = e.target.value;
|
53
|
+
onChange?.(newCode.join(''));
|
54
|
+
if (e.target.value && index < 5) {
|
55
|
+
document.getElementById(`code-input-${index + 1}`)?.focus();
|
56
|
+
}
|
57
|
+
},
|
58
|
+
onKeyDown: e => {
|
59
|
+
if (e.key === 'Backspace' && !trim(code[index]) && index > 0) {
|
60
|
+
document.getElementById(`code-input-${index - 1}`)?.focus();
|
61
|
+
}
|
62
|
+
},
|
63
|
+
required: true,
|
64
|
+
autoComplete: "off"
|
65
|
+
}, `code-input-${index}`))
|
66
|
+
});
|
67
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.13.
|
3
|
+
"version": "2.13.37",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -71,14 +71,14 @@
|
|
71
71
|
"react": ">=18.2.0",
|
72
72
|
"react-router-dom": ">=6.22.3"
|
73
73
|
},
|
74
|
-
"gitHead": "
|
74
|
+
"gitHead": "68ffad141209821dc8d24962e4f4930a8d5ccd77",
|
75
75
|
"dependencies": {
|
76
76
|
"@arcblock/did-motif": "^1.1.13",
|
77
|
-
"@arcblock/icons": "^2.13.
|
78
|
-
"@arcblock/nft-display": "^2.13.
|
79
|
-
"@arcblock/react-hooks": "^2.13.
|
77
|
+
"@arcblock/icons": "^2.13.37",
|
78
|
+
"@arcblock/nft-display": "^2.13.37",
|
79
|
+
"@arcblock/react-hooks": "^2.13.37",
|
80
80
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
81
|
-
"@blocklet/theme": "^2.13.
|
81
|
+
"@blocklet/theme": "^2.13.37",
|
82
82
|
"@fontsource/roboto": "~5.1.1",
|
83
83
|
"@fontsource/ubuntu-mono": "^5.0.18",
|
84
84
|
"@iconify-icons/logos": "^1.2.36",
|
package/src/Tabs/index.tsx
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Tabs as MuiTabs, Tab as MuiTab, type TabsProps as MuiTabsProps } from '@mui/material';
|
1
|
+
import { Tabs as MuiTabs, Tab as MuiTab, type TabsProps as MuiTabsProps, type TabProps } from '@mui/material';
|
2
2
|
|
3
3
|
import { styled } from '../Theme';
|
4
4
|
|
@@ -24,9 +24,10 @@ interface CardTabsProps extends Omit<MuiTabsProps, 'onChange'> {
|
|
24
24
|
tabs: { value: any; label: React.ReactNode; icon?: string | React.ReactElement }[];
|
25
25
|
current: any;
|
26
26
|
onChange: (value: string) => void;
|
27
|
+
iconPosition?: TabProps['iconPosition'];
|
27
28
|
}
|
28
29
|
|
29
|
-
function CardTabs({ tabs, current, onChange, ...rest }: CardTabsProps) {
|
30
|
+
function CardTabs({ tabs, current, onChange, iconPosition, ...rest }: CardTabsProps) {
|
30
31
|
return (
|
31
32
|
<MuiTabs
|
32
33
|
scrollButtons="auto"
|
@@ -76,7 +77,14 @@ function CardTabs({ tabs, current, onChange, ...rest }: CardTabsProps) {
|
|
76
77
|
...rest.sx,
|
77
78
|
}}>
|
78
79
|
{tabs.map((x) => (
|
79
|
-
<MuiTab
|
80
|
+
<MuiTab
|
81
|
+
className={classes.tab}
|
82
|
+
key={x.value}
|
83
|
+
value={x.value}
|
84
|
+
label={x.label}
|
85
|
+
icon={x.icon}
|
86
|
+
iconPosition={iconPosition}
|
87
|
+
/>
|
80
88
|
))}
|
81
89
|
</MuiTabs>
|
82
90
|
);
|
@@ -86,9 +94,10 @@ interface LineTabsProps extends Omit<MuiTabsProps, 'onChange'> {
|
|
86
94
|
tabs: { value: any; label: React.ReactNode; icon?: string | React.ReactElement }[];
|
87
95
|
current: any;
|
88
96
|
onChange: (value: string) => void;
|
97
|
+
iconPosition?: TabProps['iconPosition'];
|
89
98
|
}
|
90
99
|
|
91
|
-
function LineTabs({ tabs, current, onChange, ...rest }: LineTabsProps) {
|
100
|
+
function LineTabs({ tabs, current, onChange, iconPosition, ...rest }: LineTabsProps) {
|
92
101
|
return (
|
93
102
|
<MuiTabs
|
94
103
|
scrollButtons="auto"
|
@@ -146,7 +155,14 @@ function LineTabs({ tabs, current, onChange, ...rest }: LineTabsProps) {
|
|
146
155
|
...rest.sx,
|
147
156
|
}}>
|
148
157
|
{tabs.map((x) => (
|
149
|
-
<MuiTab
|
158
|
+
<MuiTab
|
159
|
+
className={classes.tab}
|
160
|
+
key={x.value}
|
161
|
+
value={x.value}
|
162
|
+
label={x.label}
|
163
|
+
icon={x.icon}
|
164
|
+
iconPosition={iconPosition}
|
165
|
+
/>
|
150
166
|
))}
|
151
167
|
</MuiTabs>
|
152
168
|
);
|
@@ -157,15 +173,16 @@ interface TabsProps extends Omit<MuiTabsProps, 'variant' | 'onChange'> {
|
|
157
173
|
current: any;
|
158
174
|
onChange: (value: string) => void;
|
159
175
|
variant?: 'card' | 'line' | MuiTabsProps['variant'];
|
176
|
+
iconPosition?: TabProps['iconPosition'];
|
160
177
|
}
|
161
178
|
|
162
|
-
export default function Tabs({ tabs, current, onChange, variant, ...rest }: TabsProps) {
|
179
|
+
export default function Tabs({ tabs, current, onChange, variant, iconPosition, ...rest }: TabsProps) {
|
163
180
|
if (variant === 'card') {
|
164
|
-
return <CardTabs {...rest} tabs={tabs} current={current} onChange={onChange} />;
|
181
|
+
return <CardTabs {...rest} tabs={tabs} current={current} onChange={onChange} iconPosition={iconPosition} />;
|
165
182
|
}
|
166
183
|
|
167
184
|
if (variant === 'line') {
|
168
|
-
return <LineTabs {...rest} tabs={tabs} current={current} onChange={onChange} />;
|
185
|
+
return <LineTabs {...rest} tabs={tabs} current={current} onChange={onChange} iconPosition={iconPosition} />;
|
169
186
|
}
|
170
187
|
|
171
188
|
return (
|
@@ -178,7 +195,14 @@ export default function Tabs({ tabs, current, onChange, variant, ...rest }: Tabs
|
|
178
195
|
{...rest}
|
179
196
|
className={[classes.tabs, rest.className || ''].join(' ')}>
|
180
197
|
{tabs.map((x) => (
|
181
|
-
<MuiTab
|
198
|
+
<MuiTab
|
199
|
+
className={classes.tab}
|
200
|
+
key={x.value}
|
201
|
+
value={x.value}
|
202
|
+
label={x.label}
|
203
|
+
icon={x.icon}
|
204
|
+
iconPosition={iconPosition}
|
205
|
+
/>
|
182
206
|
))}
|
183
207
|
</StyledMuiTabs>
|
184
208
|
);
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import { useEffect } from 'react';
|
2
|
+
import { Box, TextField } from '@mui/material';
|
3
|
+
import type { SxProps } from '@mui/material';
|
4
|
+
import trim from 'lodash/trim';
|
5
|
+
import noop from 'lodash/noop';
|
6
|
+
import { mergeSx } from '../Util/style';
|
7
|
+
|
8
|
+
export const VERIFY_CODE_LENGTH = 6;
|
9
|
+
|
10
|
+
export default function VerificationCode({
|
11
|
+
length = VERIFY_CODE_LENGTH,
|
12
|
+
code,
|
13
|
+
onChange = noop,
|
14
|
+
onComplete = noop,
|
15
|
+
sx,
|
16
|
+
}: {
|
17
|
+
length?: number;
|
18
|
+
code: string;
|
19
|
+
onChange?: (_code: string) => void;
|
20
|
+
onComplete?: (_code: string) => void;
|
21
|
+
sx?: SxProps;
|
22
|
+
}) {
|
23
|
+
useEffect(() => {
|
24
|
+
if (code.length === length) {
|
25
|
+
onComplete?.(code);
|
26
|
+
}
|
27
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
28
|
+
}, [code, length]);
|
29
|
+
return (
|
30
|
+
<Box
|
31
|
+
sx={mergeSx(
|
32
|
+
{
|
33
|
+
width: '100%',
|
34
|
+
maxWidth: 360,
|
35
|
+
display: 'flex',
|
36
|
+
justifyContent: 'space-between',
|
37
|
+
gap: 1.5,
|
38
|
+
},
|
39
|
+
sx
|
40
|
+
)}>
|
41
|
+
{[...Array(length)].map((_, index) => (
|
42
|
+
<TextField
|
43
|
+
id={`code-input-${index}`}
|
44
|
+
// eslint-disable-next-line react/no-array-index-key
|
45
|
+
key={`code-input-${index}`}
|
46
|
+
value={trim(code[index]) || ''}
|
47
|
+
type="number"
|
48
|
+
inputProps={{
|
49
|
+
maxLength: 1,
|
50
|
+
sx: {
|
51
|
+
textAlign: 'center',
|
52
|
+
fontSize: '1.5rem',
|
53
|
+
'&::-webkit-inner-spin-button, &::-webkit-outer-spin-button': {
|
54
|
+
WebkitAppearance: 'none',
|
55
|
+
margin: 0,
|
56
|
+
},
|
57
|
+
},
|
58
|
+
autoComplete: 'off',
|
59
|
+
pattern: '[0-9]',
|
60
|
+
inputMode: 'numeric',
|
61
|
+
}}
|
62
|
+
onChange={(e) => {
|
63
|
+
const newCode = code.split('');
|
64
|
+
newCode[index] = e.target.value;
|
65
|
+
onChange?.(newCode.join(''));
|
66
|
+
if (e.target.value && index < 5) {
|
67
|
+
document.getElementById(`code-input-${index + 1}`)?.focus();
|
68
|
+
}
|
69
|
+
}}
|
70
|
+
onKeyDown={(e) => {
|
71
|
+
if (e.key === 'Backspace' && !trim(code[index]) && index > 0) {
|
72
|
+
document.getElementById(`code-input-${index - 1}`)?.focus();
|
73
|
+
}
|
74
|
+
}}
|
75
|
+
required
|
76
|
+
autoComplete="off"
|
77
|
+
/>
|
78
|
+
))}
|
79
|
+
</Box>
|
80
|
+
);
|
81
|
+
}
|