@arcblock/ux 2.9.13 → 2.9.15
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/es/Address/did-address.js +18 -13
- package/es/Colors/themes/default.js +0 -1
- package/es/Colors/themes/temp.js +10 -1
- package/es/ContactForm/index.js +2 -2
- package/es/DID/index.js +0 -1
- package/es/Dialog/confirm.js +1 -99
- package/es/Dialog/dialog.js +4 -7
- package/es/Dialog/index.js +1 -1
- package/es/Dialog/use-confirm.js +105 -0
- package/es/Locale/selector.js +1 -1
- package/es/Locale/util.js +10 -5
- package/es/NFTDisplay/index.js +0 -1
- package/es/Passport/index.js +2 -0
- package/es/Passport/passport.js +103 -0
- package/es/SessionBlocklet/index.js +1 -1
- package/es/SessionUser/components/logged-in.js +1 -1
- package/es/SessionUser/components/un-login.js +1 -1
- package/es/SessionUser/components/user-info.js +1 -1
- package/es/SessionUser/index.js +2 -2
- package/es/Tabs/index.js +88 -2
- package/es/Theme/theme.js +12 -3
- package/es/Util/passport.js +62 -0
- package/lib/ActionButton/index.js +6 -7
- package/lib/ActivityIndicator/index.js +4 -4
- package/lib/Address/compact-text.js +6 -6
- package/lib/Address/did-address.js +25 -21
- package/lib/Address/index.js +4 -4
- package/lib/Address/responsive-did-address.js +4 -4
- package/lib/Alert/index.js +5 -6
- package/lib/AnimationWaiter/index.js +4 -4
- package/lib/Async/index.js +6 -6
- package/lib/Avatar/did-motif.js +5 -6
- package/lib/Avatar/etherscan-blockies.js +2 -3
- package/lib/Avatar/index.js +4 -4
- package/lib/Badge/index.js +5 -6
- package/lib/Blocklet/blocklet.js +4 -4
- package/lib/Blocklet/index.js +3 -4
- package/lib/Blocklet/utils.js +3 -5
- package/lib/BlockletContext/index.js +1 -2
- package/lib/BlockletNFT/index.js +4 -4
- package/lib/Button/index.js +1 -2
- package/lib/Button/wrap.js +4 -4
- package/lib/ButtonGroup/index.js +1 -2
- package/lib/ClickToCopy/copy-button.js +4 -4
- package/lib/ClickToCopy/index.js +6 -6
- package/lib/CodeBlock/LightBox.js +1 -2
- package/lib/CodeBlock/index.js +4 -4
- package/lib/Colors/themes/default.js +1 -2
- package/lib/Colors/themes/temp.js +11 -3
- package/lib/ContactForm/index.js +2 -2
- package/lib/CookieConsent/index.js +6 -6
- package/lib/CountDown/index.js +4 -4
- package/lib/DID/index.js +7 -9
- package/lib/Datatable/CustomToolbar.js +2 -2
- package/lib/Datatable/index.js +49 -49
- package/lib/Datatable/utils.js +2 -3
- package/lib/Dialog/confirm.js +5 -113
- package/lib/Dialog/dialog.js +14 -18
- package/lib/Dialog/index.js +3 -4
- package/lib/Dialog/use-confirm.js +126 -0
- package/lib/Earth/index.js +7 -8
- package/lib/Empty/index.js +5 -6
- package/lib/Header/auto-hidden.js +5 -6
- package/lib/Header/header.js +5 -6
- package/lib/Header/responsive-header.js +5 -6
- package/lib/Icon/image.js +4 -4
- package/lib/Icon/index.js +6 -7
- package/lib/Img/index.js +5 -6
- package/lib/InfoRow/index.js +5 -6
- package/lib/Layout/dashboard/external-link.js +4 -4
- package/lib/Layout/dashboard/full-page.js +5 -6
- package/lib/Layout/dashboard/index.js +4 -4
- package/lib/Layout/dashboard/sidebar.js +5 -6
- package/lib/Layout/dashboard-legacy/header.js +4 -4
- package/lib/Layout/dashboard-legacy/index.js +4 -4
- package/lib/Layout/dashboard-legacy/sidebar.js +4 -4
- package/lib/Layout/index.js +4 -4
- package/lib/Locale/browser-lang.js +1 -2
- package/lib/Locale/context.js +6 -8
- package/lib/Locale/languages.js +7 -9
- package/lib/Locale/selector.js +5 -5
- package/lib/Locale/util.js +12 -11
- package/lib/Logo/index.js +4 -4
- package/lib/NFTDisplay/aspect-ratio-container.js +5 -6
- package/lib/NFTDisplay/broken.js +4 -4
- package/lib/NFTDisplay/index.js +5 -7
- package/lib/NFTDisplay/svg-embedder/img.js +5 -6
- package/lib/NFTDisplay/svg-embedder/inline-svg.js +5 -6
- package/lib/NavMenu/nav-menu.js +5 -6
- package/lib/NavMenu/style.js +2 -4
- package/lib/PageScroller/index.js +6 -7
- package/lib/Passport/index.js +9 -0
- package/lib/Passport/passport.js +116 -0
- package/lib/PoweredByArcBlock/index.js +4 -4
- package/lib/PricingTable/PricingPlan.js +1 -2
- package/lib/PricingTable/index.js +1 -2
- package/lib/QRCode/index.js +5 -6
- package/lib/RelativeTime/index.js +4 -4
- package/lib/Result/common.js +4 -4
- package/lib/Result/index.js +7 -8
- package/lib/Result/result.js +5 -6
- package/lib/Result/translations.js +2 -3
- package/lib/Screenshot/BaseScreenshot/index.js +5 -6
- package/lib/Screenshot/BaseScreenshot/shells/Macbook.js +10 -15
- package/lib/Screenshot/BaseScreenshot/shells/Phone.js +10 -15
- package/lib/Screenshot/index.js +5 -6
- package/lib/SessionBlocklet/index.js +5 -5
- package/lib/SessionManager/index.js +1 -2
- package/lib/SessionUser/components/logged-in.js +5 -5
- package/lib/SessionUser/components/session-user-item.js +5 -6
- package/lib/SessionUser/components/session-user-switch.js +4 -4
- package/lib/SessionUser/components/un-login.js +1 -1
- package/lib/SessionUser/components/user-info.js +1 -1
- package/lib/SessionUser/index.js +2 -2
- package/lib/SessionUser/libs/translation.js +2 -3
- package/lib/Spinner/index.js +13 -14
- package/lib/SplitButton/index.js +4 -4
- package/lib/Switch/index.js +5 -6
- package/lib/Tabs/index.js +98 -11
- package/lib/Tag/index.js +5 -6
- package/lib/TextCollapse/index.js +5 -6
- package/lib/Theme/index.js +6 -7
- package/lib/Theme/theme.js +18 -11
- package/lib/Toast/index.js +12 -13
- package/lib/Typography/index.js +4 -4
- package/lib/Util/constant.js +10 -20
- package/lib/Util/deprecate.js +4 -4
- package/lib/Util/index.js +2 -4
- package/lib/Util/passport.js +72 -0
- package/lib/Util/wallet.js +1 -2
- package/lib/Video/index.js +4 -4
- package/lib/Wallet/Action.js +4 -4
- package/lib/Wallet/Download.js +4 -4
- package/lib/WebWalletSWKeeper/index.js +5 -6
- package/lib/withTheme/index.js +5 -6
- package/lib/withTracker/error_boundary.js +2 -2
- package/lib/withTracker/index.js +8 -9
- package/package.json +12 -6
- package/src/Address/did-address.jsx +15 -12
- package/src/Colors/themes/temp.js +9 -0
- package/src/Dialog/confirm.jsx +94 -0
- package/src/Dialog/{dialog.js → dialog.jsx} +14 -7
- package/src/Dialog/index.js +1 -1
- package/src/Dialog/use-confirm.jsx +114 -0
- package/src/Locale/selector.jsx +1 -1
- package/src/Locale/util.js +12 -5
- package/src/Passport/index.jsx +3 -0
- package/src/Passport/passport.jsx +99 -0
- package/src/SessionBlocklet/index.jsx +1 -1
- package/src/SessionUser/components/logged-in.jsx +1 -1
- package/src/SessionUser/components/un-login.jsx +1 -1
- package/src/SessionUser/components/user-info.jsx +1 -1
- package/src/SessionUser/index.jsx +1 -1
- package/src/Tabs/index.jsx +124 -0
- package/src/Theme/theme.js +13 -3
- package/src/Util/passport.js +75 -0
- package/src/Dialog/confirm.js +0 -201
- package/src/Tabs/index.js +0 -45
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import { Tabs as MuiTabs, Tab as MuiTab } from '@mui/material';
|
|
3
|
+
|
|
4
|
+
import { temp as colors } from '../Colors';
|
|
5
|
+
import { styled } from '../Theme';
|
|
6
|
+
|
|
7
|
+
const PREFIX = 'index';
|
|
8
|
+
|
|
9
|
+
const classes = {
|
|
10
|
+
tabs: `${PREFIX}-tabs`,
|
|
11
|
+
tab: `${PREFIX}-tab`,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const StyledMuiTabs = styled(MuiTabs)(({ theme }) => ({
|
|
15
|
+
[`& .${classes.tabs}`]: {},
|
|
16
|
+
|
|
17
|
+
[`& .${classes.tab}`]: {
|
|
18
|
+
fontSize: '0.875rem',
|
|
19
|
+
[theme.breakpoints.up('md')]: {
|
|
20
|
+
fontSize: '1rem',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
function CardTabs({ tabs, current, onChange, ...rest }) {
|
|
26
|
+
return (
|
|
27
|
+
<MuiTabs
|
|
28
|
+
scrollButtons="auto"
|
|
29
|
+
value={current}
|
|
30
|
+
onChange={(_, newValue) => onChange(newValue)}
|
|
31
|
+
{...rest}
|
|
32
|
+
variant="scrollable"
|
|
33
|
+
sx={{
|
|
34
|
+
minHeight: 'auto',
|
|
35
|
+
'.MuiTabs-scrollButtons.Mui-disabled': {
|
|
36
|
+
opacity: 0.3,
|
|
37
|
+
cursor: 'not-allowed',
|
|
38
|
+
pointerEvents: 'auto',
|
|
39
|
+
},
|
|
40
|
+
'.MuiTabs-scroller': {
|
|
41
|
+
borderRadius: '100vw',
|
|
42
|
+
},
|
|
43
|
+
'.MuiTabs-flexContainer': {
|
|
44
|
+
borderRadius: '100vw',
|
|
45
|
+
backgroundColor: colors.backgroundsBgComponent,
|
|
46
|
+
padding: 0.5,
|
|
47
|
+
display: 'inline-flex',
|
|
48
|
+
columnGap: 0.25,
|
|
49
|
+
},
|
|
50
|
+
'.MuiTab-root': {
|
|
51
|
+
borderRadius: '100vw',
|
|
52
|
+
border: '1px solid transparent',
|
|
53
|
+
minHeight: 'auto',
|
|
54
|
+
lineHeight: 1,
|
|
55
|
+
py: 1,
|
|
56
|
+
color: colors.foregroundsFgSubtile,
|
|
57
|
+
fontSize: '13px',
|
|
58
|
+
fontWeight: 'normal',
|
|
59
|
+
textTransform: 'capitalize',
|
|
60
|
+
transition: 'background-color 0.2s ease',
|
|
61
|
+
'&.Mui-selected, &:hover': {
|
|
62
|
+
backgroundColor: 'white',
|
|
63
|
+
borderColor: colors.lineBorderBase,
|
|
64
|
+
color: colors.foregroundsFgBase,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
'.MuiTabs-indicator': {
|
|
68
|
+
display: 'none',
|
|
69
|
+
},
|
|
70
|
+
...rest.sx,
|
|
71
|
+
}}>
|
|
72
|
+
{tabs.map((x) => (
|
|
73
|
+
<MuiTab className={classes.tab} key={x.value} value={x.value} label={x.label} icon={x.icon || null} />
|
|
74
|
+
))}
|
|
75
|
+
</MuiTabs>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
CardTabs.propTypes = {
|
|
80
|
+
tabs: PropTypes.array.isRequired,
|
|
81
|
+
current: PropTypes.string.isRequired,
|
|
82
|
+
onChange: PropTypes.func.isRequired,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @typedef {import('@mui/material').TabsProps & {
|
|
87
|
+
* tabs: string[];
|
|
88
|
+
* onChange: (value) => {};
|
|
89
|
+
* variant: 'card' | 'fullWidth' | 'scrollable' | 'standard'
|
|
90
|
+
* }} TabsProps
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @description
|
|
95
|
+
* @param { TabsProps} props
|
|
96
|
+
* @return {import('react').ReactNode}
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
export default function Tabs({ tabs, current, onChange, ...rest }) {
|
|
100
|
+
if (rest.variant === 'card') {
|
|
101
|
+
return <CardTabs tabs={tabs} current={current} onChange={onChange} />;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<StyledMuiTabs
|
|
106
|
+
scrollButtons="auto"
|
|
107
|
+
variant="scrollable"
|
|
108
|
+
value={current}
|
|
109
|
+
onChange={(_, newValue) => onChange(newValue)}
|
|
110
|
+
indicatorColor="primary"
|
|
111
|
+
{...rest}
|
|
112
|
+
className={[classes.tabs, rest.className || ''].join(' ')}>
|
|
113
|
+
{tabs.map((x) => (
|
|
114
|
+
<MuiTab className={classes.tab} key={x.value} value={x.value} label={x.label} icon={x.icon || null} />
|
|
115
|
+
))}
|
|
116
|
+
</StyledMuiTabs>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
Tabs.propTypes = {
|
|
121
|
+
tabs: PropTypes.array.isRequired,
|
|
122
|
+
current: PropTypes.string.isRequired,
|
|
123
|
+
onChange: PropTypes.func.isRequired,
|
|
124
|
+
};
|
package/src/Theme/theme.js
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
// https://app.zeplin.io/styleguide/5d1436f1e97c2156f49c0725/colors
|
|
2
2
|
import { createTheme as _createTheme, responsiveFontSizes } from '@mui/material/styles';
|
|
3
|
-
|
|
4
|
-
import '@fontsource/
|
|
3
|
+
// 为了避免加载全量的字体导致打包后体积太大,目前只选择了 latin 语系的字体
|
|
4
|
+
import '@fontsource/inter/latin-400.css';
|
|
5
|
+
import '@fontsource/inter/latin-500.css';
|
|
6
|
+
import '@fontsource/inter/latin-600.css';
|
|
7
|
+
import '@fontsource/inter/latin-700.css';
|
|
8
|
+
import '@fontsource/inter/latin-900.css';
|
|
9
|
+
import '@fontsource/inter/latin-ext-400.css';
|
|
10
|
+
import '@fontsource/inter/latin-ext-500.css';
|
|
11
|
+
import '@fontsource/inter/latin-ext-600.css';
|
|
12
|
+
import '@fontsource/inter/latin-ext-700.css';
|
|
13
|
+
import '@fontsource/inter/latin-ext-900.css';
|
|
14
|
+
|
|
5
15
|
import colors from '../Colors';
|
|
6
16
|
|
|
7
17
|
const muiDarkTheme = _createTheme({ palette: { mode: 'dark' } });
|
|
@@ -52,7 +62,7 @@ export const create = ({ mode = 'light', pageWidth = 'md', palette, typography,
|
|
|
52
62
|
gray: mode === 'light' ? colors.grey[500] : colors.grey[300],
|
|
53
63
|
},
|
|
54
64
|
fontFamily: [
|
|
55
|
-
'
|
|
65
|
+
'Inter',
|
|
56
66
|
'Avenir',
|
|
57
67
|
'-apple-system',
|
|
58
68
|
'BlinkMacSystemFont',
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { getNftBGColor, DEFAULT_COLORS, getNftBGColorFromDid, getSvg } from '@arcblock/nft-display';
|
|
2
|
+
|
|
3
|
+
export const getPassportColor = (preferredColor, did) => {
|
|
4
|
+
let color;
|
|
5
|
+
if (preferredColor === 'default') {
|
|
6
|
+
color = DEFAULT_COLORS['app-passport'];
|
|
7
|
+
} else if (preferredColor === 'auto') {
|
|
8
|
+
color = getNftBGColorFromDid(did);
|
|
9
|
+
} else {
|
|
10
|
+
color = getNftBGColor(preferredColor);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return color;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const getTextColor = (background) => {
|
|
17
|
+
const r = parseInt(background.slice(1, 3), 16);
|
|
18
|
+
const g = parseInt(background.slice(3, 5), 16);
|
|
19
|
+
const b = parseInt(background.slice(5, 7), 16);
|
|
20
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
21
|
+
return luminance > 0.5 ? '#111' : '#EEE';
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const createPassportSvg = ({
|
|
25
|
+
issuer = '',
|
|
26
|
+
title = '',
|
|
27
|
+
issuerDid = '',
|
|
28
|
+
issuerAvatarUrl = '',
|
|
29
|
+
ownerDid = '',
|
|
30
|
+
ownerName = '',
|
|
31
|
+
ownerAvatarUrl = '',
|
|
32
|
+
preferredColor = 'default',
|
|
33
|
+
revoked = false,
|
|
34
|
+
isDataUrl = false,
|
|
35
|
+
width = '100%',
|
|
36
|
+
height = '100%',
|
|
37
|
+
}) => {
|
|
38
|
+
const color = getPassportColor(preferredColor, issuerDid);
|
|
39
|
+
|
|
40
|
+
const svgXML = getSvg({
|
|
41
|
+
width,
|
|
42
|
+
height,
|
|
43
|
+
|
|
44
|
+
tag: revoked ? 'revoked' : '',
|
|
45
|
+
tagVariant: revoked ? 'error' : 'info',
|
|
46
|
+
|
|
47
|
+
color,
|
|
48
|
+
|
|
49
|
+
did: ownerDid,
|
|
50
|
+
variant: 'app-passport' || ownerName,
|
|
51
|
+
verifiable: true,
|
|
52
|
+
|
|
53
|
+
issuer: {
|
|
54
|
+
name: issuer,
|
|
55
|
+
icon: issuerAvatarUrl,
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
header: {
|
|
59
|
+
name: title,
|
|
60
|
+
icon: ownerAvatarUrl,
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
// FIXME: @wangshijun this should be dynamic
|
|
64
|
+
extra: {
|
|
65
|
+
key: 'Exp',
|
|
66
|
+
value: '2123-01-01',
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (isDataUrl) {
|
|
71
|
+
return `data:image/svg+xml;utf8,${encodeURIComponent(svgXML)}`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return svgXML;
|
|
75
|
+
};
|
package/src/Dialog/confirm.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import { forwardRef, useRef, useImperativeHandle } from 'react';
|
|
3
|
-
import { useMemoizedFn, useReactive } from 'ahooks';
|
|
4
|
-
import noop from 'lodash/noop';
|
|
5
|
-
|
|
6
|
-
import Button from '../Button';
|
|
7
|
-
import Dialog from './dialog';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
@typedef {Object} ConfirmProps
|
|
11
|
-
@property {boolean} open
|
|
12
|
-
@property {React.ReactNode} title
|
|
13
|
-
@property {React.ReactNode} children
|
|
14
|
-
@property {() => void | Promise<void>} onConfirm
|
|
15
|
-
@property {() => void | Promise<void>} onCancel
|
|
16
|
-
@property {boolean} [showCancelButton=true]
|
|
17
|
-
@property {{text: string, props?: import('../Button/wrap').ButtonProps}} [confirmButton={text: 'Confirm'}]
|
|
18
|
-
@property {{text: string, props?: import('../Button/wrap').ButtonProps}} [cancelButton={text: 'Cancel'}]
|
|
19
|
-
@property {import('@mui/material').PaperProps} [PaperProps={}]
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
// 注意排在 {...rest} 之后的 props 优先级更高
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* @param {ConfirmProps} props
|
|
26
|
-
* @returns {import('react').ReactComponentElement}
|
|
27
|
-
*/
|
|
28
|
-
export default function Confirm({
|
|
29
|
-
title,
|
|
30
|
-
children,
|
|
31
|
-
onConfirm,
|
|
32
|
-
onCancel,
|
|
33
|
-
showCancelButton,
|
|
34
|
-
confirmButton,
|
|
35
|
-
cancelButton,
|
|
36
|
-
PaperProps,
|
|
37
|
-
...rest
|
|
38
|
-
}) {
|
|
39
|
-
// 去除 dialog 默认的 300 最小高度
|
|
40
|
-
PaperProps.style = Object.assign(
|
|
41
|
-
{
|
|
42
|
-
minHeight: 0,
|
|
43
|
-
},
|
|
44
|
-
PaperProps.style
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<Dialog
|
|
49
|
-
title={title}
|
|
50
|
-
PaperProps={PaperProps}
|
|
51
|
-
{...rest}
|
|
52
|
-
onClose={() => onCancel()}
|
|
53
|
-
actions={
|
|
54
|
-
<>
|
|
55
|
-
{showCancelButton && (
|
|
56
|
-
<Button onClick={() => onCancel()} color="primary" {...cancelButton.props}>
|
|
57
|
-
{cancelButton.text}
|
|
58
|
-
</Button>
|
|
59
|
-
)}
|
|
60
|
-
<Button onClick={() => onConfirm()} color="primary" autoFocus {...confirmButton.props}>
|
|
61
|
-
{confirmButton.text}
|
|
62
|
-
</Button>
|
|
63
|
-
</>
|
|
64
|
-
}>
|
|
65
|
-
{children}
|
|
66
|
-
</Dialog>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
Confirm.propTypes = {
|
|
71
|
-
title: PropTypes.node.isRequired,
|
|
72
|
-
children: PropTypes.node.isRequired,
|
|
73
|
-
onConfirm: PropTypes.func.isRequired,
|
|
74
|
-
onCancel: PropTypes.func.isRequired,
|
|
75
|
-
showCancelButton: PropTypes.bool,
|
|
76
|
-
// 可以传入 {text: ..., props: ...}
|
|
77
|
-
confirmButton: PropTypes.shape({
|
|
78
|
-
text: PropTypes.string.isRequired,
|
|
79
|
-
props: PropTypes.object,
|
|
80
|
-
}),
|
|
81
|
-
cancelButton: PropTypes.shape({
|
|
82
|
-
text: PropTypes.string.isRequired,
|
|
83
|
-
props: PropTypes.object,
|
|
84
|
-
}),
|
|
85
|
-
PaperProps: PropTypes.object,
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
Confirm.defaultProps = {
|
|
89
|
-
showCancelButton: true,
|
|
90
|
-
confirmButton: {
|
|
91
|
-
text: 'Confirm',
|
|
92
|
-
},
|
|
93
|
-
cancelButton: {
|
|
94
|
-
text: 'Cancel',
|
|
95
|
-
},
|
|
96
|
-
PaperProps: {},
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const ConfirmHolder = forwardRef((props, ref) => {
|
|
100
|
-
const state = useReactive({
|
|
101
|
-
show: false,
|
|
102
|
-
title: '',
|
|
103
|
-
content: '',
|
|
104
|
-
onConfirm: noop,
|
|
105
|
-
onCancel: noop,
|
|
106
|
-
loading: false,
|
|
107
|
-
confirmButtonText: 'Confirm',
|
|
108
|
-
cancelButtonText: 'Cancel',
|
|
109
|
-
});
|
|
110
|
-
const open = useMemoizedFn((params = {}) => {
|
|
111
|
-
state.show = true;
|
|
112
|
-
state.title = params.title;
|
|
113
|
-
state.content = params.content;
|
|
114
|
-
state.onConfirm = params.onConfirm || noop;
|
|
115
|
-
state.onCancel = params.onCancel || noop;
|
|
116
|
-
if (params.confirmButtonText) state.confirmButtonText = params.confirmButtonText;
|
|
117
|
-
if (params.cancelButtonText) state.cancelButtonText = params.cancelButtonText;
|
|
118
|
-
state.loading = false;
|
|
119
|
-
});
|
|
120
|
-
const reset = useMemoizedFn(() => {
|
|
121
|
-
state.title = '';
|
|
122
|
-
state.content = '';
|
|
123
|
-
state.onConfirm = noop;
|
|
124
|
-
state.onCancel = noop;
|
|
125
|
-
state.confirmButtonText = 'Confirm';
|
|
126
|
-
state.cancelButtonText = 'Cancel';
|
|
127
|
-
});
|
|
128
|
-
const close = useMemoizedFn(() => {
|
|
129
|
-
state.show = false;
|
|
130
|
-
setTimeout(() => {
|
|
131
|
-
reset();
|
|
132
|
-
}, 300);
|
|
133
|
-
});
|
|
134
|
-
const onCancel = useMemoizedFn(() => {
|
|
135
|
-
close();
|
|
136
|
-
state?.onCancel();
|
|
137
|
-
}, []);
|
|
138
|
-
const onConfirm = useMemoizedFn(async () => {
|
|
139
|
-
state.loading = true;
|
|
140
|
-
try {
|
|
141
|
-
await state?.onConfirm(close);
|
|
142
|
-
} finally {
|
|
143
|
-
state.loading = false;
|
|
144
|
-
}
|
|
145
|
-
}, []);
|
|
146
|
-
useImperativeHandle(
|
|
147
|
-
ref,
|
|
148
|
-
() => {
|
|
149
|
-
return {
|
|
150
|
-
open,
|
|
151
|
-
close,
|
|
152
|
-
};
|
|
153
|
-
},
|
|
154
|
-
[open, close]
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<Confirm
|
|
159
|
-
open={state.show}
|
|
160
|
-
title={state.title}
|
|
161
|
-
onConfirm={onConfirm}
|
|
162
|
-
onCancel={onCancel}
|
|
163
|
-
confirmButton={{
|
|
164
|
-
text: state.confirmButtonText,
|
|
165
|
-
props: {
|
|
166
|
-
variant: 'contained',
|
|
167
|
-
color: 'primary',
|
|
168
|
-
loading: state.loading,
|
|
169
|
-
},
|
|
170
|
-
}}
|
|
171
|
-
cancelButton={{
|
|
172
|
-
text: state.cancelButtonText,
|
|
173
|
-
props: {
|
|
174
|
-
variant: 'outlined',
|
|
175
|
-
color: 'primary',
|
|
176
|
-
},
|
|
177
|
-
}}>
|
|
178
|
-
{state.content}
|
|
179
|
-
</Confirm>
|
|
180
|
-
);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
export function useConfirm() {
|
|
184
|
-
const confirmRef = useRef(null);
|
|
185
|
-
|
|
186
|
-
const open = useMemoizedFn((...args) => {
|
|
187
|
-
confirmRef.current?.open(...args);
|
|
188
|
-
});
|
|
189
|
-
const close = useMemoizedFn((...args) => {
|
|
190
|
-
confirmRef.current?.close(...args);
|
|
191
|
-
});
|
|
192
|
-
const confirmApi = {
|
|
193
|
-
open,
|
|
194
|
-
close,
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
return {
|
|
198
|
-
confirmHolder: <ConfirmHolder ref={confirmRef} />,
|
|
199
|
-
confirmApi,
|
|
200
|
-
};
|
|
201
|
-
}
|
package/src/Tabs/index.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import MuiTabs from '@mui/material/Tabs';
|
|
3
|
-
import MuiTab from '@mui/material/Tab';
|
|
4
|
-
import { styled } from '../Theme';
|
|
5
|
-
|
|
6
|
-
const PREFIX = 'index';
|
|
7
|
-
|
|
8
|
-
const classes = {
|
|
9
|
-
tabs: `${PREFIX}-tabs`,
|
|
10
|
-
tab: `${PREFIX}-tab`,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const StyledMuiTabs = styled(MuiTabs)(({ theme }) => ({
|
|
14
|
-
[`& .${classes.tabs}`]: {},
|
|
15
|
-
|
|
16
|
-
[`& .${classes.tab}`]: {
|
|
17
|
-
fontSize: '0.875rem',
|
|
18
|
-
[theme.breakpoints.up('md')]: {
|
|
19
|
-
fontSize: '1rem',
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
export default function Tabs({ tabs, current, onChange, ...rest }) {
|
|
25
|
-
return (
|
|
26
|
-
<StyledMuiTabs
|
|
27
|
-
scrollButtons="auto"
|
|
28
|
-
variant="scrollable"
|
|
29
|
-
value={current}
|
|
30
|
-
onChange={(_, newValue) => onChange(newValue)}
|
|
31
|
-
indicatorColor="primary"
|
|
32
|
-
{...rest}
|
|
33
|
-
className={[classes.tabs, rest.className || ''].join(' ')}>
|
|
34
|
-
{tabs.map((x) => (
|
|
35
|
-
<MuiTab className={classes.tab} key={x.value} value={x.value} label={x.label} icon={x.icon || null} />
|
|
36
|
-
))}
|
|
37
|
-
</StyledMuiTabs>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
Tabs.propTypes = {
|
|
42
|
-
tabs: PropTypes.array.isRequired,
|
|
43
|
-
current: PropTypes.string.isRequired,
|
|
44
|
-
onChange: PropTypes.func.isRequired,
|
|
45
|
-
};
|