@arcblock/ux 1.17.21 → 2.0.2

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.
Files changed (99) hide show
  1. package/lib/ActionButton/index.js +1 -1
  2. package/lib/ActivityIndicator/index.js +5 -7
  3. package/lib/Alert/index.js +3 -3
  4. package/lib/Async/index.js +1 -1
  5. package/lib/Badge/index.js +1 -1
  6. package/lib/Blocklet/blocklet.js +5 -5
  7. package/lib/BlockletNFT/index.js +7 -7
  8. package/lib/Button/index.js +1 -1
  9. package/lib/Button/wrap.js +2 -21
  10. package/lib/ButtonGroup/index.js +2 -2
  11. package/lib/ClickToCopy/index.js +2 -2
  12. package/lib/CodeBlock/index.js +3 -3
  13. package/lib/ContactForm/index.js +3 -3
  14. package/lib/CookieConsent/index.js +7 -3
  15. package/lib/Dialog/dialog.js +10 -9
  16. package/lib/Footer/index.js +1 -1
  17. package/lib/Header/header.js +4 -4
  18. package/lib/Header/responsive-header.js +7 -7
  19. package/lib/Icon/index.js +1 -1
  20. package/lib/Img/index.js +12 -7
  21. package/lib/InfoRow/index.js +1 -1
  22. package/lib/Layout/dashboard/header.js +9 -9
  23. package/lib/Layout/dashboard/index.js +3 -3
  24. package/lib/Layout/dashboard/sidebar.js +6 -6
  25. package/lib/Layout/index.js +19 -16
  26. package/lib/Locale/selector.js +16 -11
  27. package/lib/NFTDisplay/broken.js +1 -1
  28. package/lib/NavMenu/nav-menu.js +1 -1
  29. package/lib/PageScroller/index.js +6 -2
  30. package/lib/PricingTable/PricingPlan.js +4 -4
  31. package/lib/PricingTable/index.js +2 -2
  32. package/lib/Result/common.js +3 -3
  33. package/lib/Result/index.js +3 -6
  34. package/lib/Result/result.js +3 -2
  35. package/lib/Spinner/index.js +2 -2
  36. package/lib/SplitButton/index.js +8 -8
  37. package/lib/Switch/index.js +60 -60
  38. package/lib/Tabs/index.js +26 -17
  39. package/lib/Tag/index.js +2 -2
  40. package/lib/TextCollapse/index.js +1 -1
  41. package/lib/Theme/index.js +51 -67
  42. package/lib/Toast/index.js +12 -11
  43. package/lib/Video/index.js +1 -1
  44. package/lib/Wallet/Action.js +1 -1
  45. package/lib/Wallet/Download.js +1 -1
  46. package/lib/Wallet/Open.js +1 -1
  47. package/lib/WechatPrompt/index.js +2 -2
  48. package/lib/withTheme/index.js +3 -3
  49. package/package.json +10 -8
  50. package/src/ActionButton/index.js +1 -1
  51. package/src/ActivityIndicator/index.js +1 -2
  52. package/src/Alert/index.js +2 -2
  53. package/src/Async/index.js +1 -1
  54. package/src/Badge/index.js +1 -1
  55. package/src/Blocklet/blocklet.js +4 -4
  56. package/src/BlockletNFT/index.js +7 -7
  57. package/src/Button/index.js +1 -1
  58. package/src/Button/wrap.js +2 -9
  59. package/src/ButtonGroup/index.js +2 -2
  60. package/src/ClickToCopy/index.js +2 -2
  61. package/src/CodeBlock/index.js +3 -3
  62. package/src/ContactForm/index.js +3 -3
  63. package/src/CookieConsent/index.js +4 -3
  64. package/src/Dialog/dialog.js +12 -9
  65. package/src/Footer/index.js +1 -1
  66. package/src/Header/header.js +5 -5
  67. package/src/Header/responsive-header.js +7 -7
  68. package/src/Icon/index.js +1 -0
  69. package/src/Img/index.js +12 -6
  70. package/src/InfoRow/index.js +1 -1
  71. package/src/Layout/dashboard/header.js +10 -10
  72. package/src/Layout/dashboard/index.js +3 -3
  73. package/src/Layout/dashboard/sidebar.js +10 -13
  74. package/src/Layout/index.js +18 -16
  75. package/src/Locale/selector.js +22 -17
  76. package/src/NFTDisplay/broken.js +1 -1
  77. package/src/NavMenu/nav-menu.js +1 -1
  78. package/src/PageScroller/index.js +4 -2
  79. package/src/PricingTable/PricingPlan.js +4 -4
  80. package/src/PricingTable/index.js +2 -2
  81. package/src/Result/common.js +3 -3
  82. package/src/Result/index.js +0 -2
  83. package/src/Result/result.js +3 -2
  84. package/src/Spinner/index.js +2 -2
  85. package/src/SplitButton/index.js +8 -8
  86. package/src/Switch/index.js +44 -48
  87. package/src/Tabs/index.js +16 -10
  88. package/src/Tag/index.js +2 -2
  89. package/src/TextCollapse/index.js +1 -1
  90. package/src/Theme/index.js +44 -57
  91. package/src/Toast/index.js +11 -11
  92. package/src/Video/index.js +1 -1
  93. package/src/Wallet/Action.js +1 -1
  94. package/src/Wallet/Download.js +1 -1
  95. package/src/Wallet/Open.js +1 -1
  96. package/src/WechatPrompt/index.js +2 -2
  97. package/src/withTheme/index.js +2 -2
  98. package/lib/Theme/responsiveFontSizes.js +0 -83
  99. package/src/Theme/responsiveFontSizes.js +0 -94
@@ -1,11 +1,11 @@
1
1
  import React, { useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
- import MenuIcon from '@material-ui/icons/Menu';
5
- import Button from '@material-ui/core/IconButton';
6
- import useTheme from '@material-ui/core/styles/useTheme';
7
- import useMediaQuery from '@material-ui/core/useMediaQuery';
8
- import Drawer from '@material-ui/core/Drawer';
4
+ import MenuIcon from '@mui/icons-material/Menu';
5
+ import Button from '@mui/material/IconButton';
6
+ import useTheme from '@mui/styles/useTheme';
7
+ import useMediaQuery from '@mui/material/useMediaQuery';
8
+ import Drawer from '@mui/material/Drawer';
9
9
  import Header from './header';
10
10
 
11
11
  /**
@@ -17,7 +17,7 @@ import Header from './header';
17
17
  */
18
18
  function ResponsiveHeader({ menu, prepend, children, ...rest }) {
19
19
  const theme = useTheme();
20
- const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
20
+ const isMobile = useMediaQuery(theme.breakpoints.down('md'));
21
21
  const [drawerOpen, setDrawerOpen] = useState(false);
22
22
  const _children =
23
23
  typeof children === 'function'
@@ -81,7 +81,7 @@ const Root = styled(Header)`
81
81
  .header-menu {
82
82
  display: none;
83
83
  }
84
- ${props => props.$theme.breakpoints.down('sm')} {
84
+ ${props => props.$theme.breakpoints.down('md')} {
85
85
  .header-menu {
86
86
  display: block;
87
87
  }
package/src/Icon/index.js CHANGED
@@ -10,6 +10,7 @@ const variants = {
10
10
  solid: 'fas',
11
11
  };
12
12
 
13
+ // eslint-disable-next-line react/prop-types
13
14
  const Icon = ({ name, color, size, variant, rounded, style, className, forwardedRef, ...rest }) => {
14
15
  const content = (
15
16
  <i
package/src/Img/index.js CHANGED
@@ -1,12 +1,19 @@
1
1
  import React, { useEffect, useMemo, useState } from 'react';
2
+ import { styled } from '@mui/material/styles';
2
3
  import PropTypes from 'prop-types';
3
- import { makeStyles, SvgIcon } from '@material-ui/core';
4
+ import { SvgIcon } from '@mui/material';
4
5
  import { useInView } from 'react-intersection-observer';
5
6
  import Alert from 'mdi-material-ui/Alert';
6
7
  import ImageIcon from 'mdi-material-ui/Image';
7
8
 
8
- const useStyles = makeStyles(() => ({
9
- root: {
9
+ const PREFIX = 'Img';
10
+
11
+ const classes = {
12
+ root: `${PREFIX}-root`,
13
+ };
14
+
15
+ const Root = styled('div')(() => ({
16
+ [`& .${classes.root}`]: {
10
17
  position: 'relative',
11
18
  overflow: 'hidden',
12
19
  '& .image--state, & .image--img': {
@@ -56,7 +63,6 @@ function Img({
56
63
  onSuccess,
57
64
  ...rest
58
65
  }) {
59
- const classes = useStyles();
60
66
  const [ref, inView] = lazy ? useInView({ threshold: 0, triggerOnce: true }) : [null, true];
61
67
 
62
68
  const [imgState, setImgState] = useState('init');
@@ -117,7 +123,7 @@ function Img({
117
123
 
118
124
  return (
119
125
  // paddingTop 要求元素本身的宽度为 100%,所以只能加一个外层元素去限制宽度
120
- <div ref={ref} style={outerStyle} {...rest}>
126
+ <Root ref={ref} style={outerStyle} {...rest}>
121
127
  <div className={`image ${className} ${classes.root}`} style={mergedStyle}>
122
128
  {!fallback && imgState === 'error' && (
123
129
  <div className="image--state" title="loading image">
@@ -131,7 +137,7 @@ function Img({
131
137
  )}
132
138
  {imgState === 'loaded' && <img className="image--img" src={src} alt={alt} />}
133
139
  </div>
134
- </div>
140
+ </Root>
135
141
  );
136
142
  }
137
143
 
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import camelCase from 'lodash/camelCase';
4
4
  import upperFirst from 'lodash/upperFirst';
5
5
  import styled from 'styled-components';
6
- import Typography from '@material-ui/core/Typography';
6
+ import Typography from '@mui/material/Typography';
7
7
 
8
8
  const InfoRow = ({ name, nameFormatter, layout, children, valueComponent, nameWidth, ...rest }) => (
9
9
  <Container layout={layout} width={nameWidth} {...rest}>
@@ -1,20 +1,20 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
- import Button from '@material-ui/core/IconButton';
5
- import AppBar from '@material-ui/core/AppBar';
6
- import Toolbar from '@material-ui/core/Toolbar';
7
- import Box from '@material-ui/core/Box';
8
- import Typography from '@material-ui/core/Typography';
9
- import Hidden from '@material-ui/core/Hidden';
10
- import MenuIcon from '@material-ui/icons/Menu';
4
+ import Button from '@mui/material/IconButton';
5
+ import AppBar from '@mui/material/AppBar';
6
+ import Toolbar from '@mui/material/Toolbar';
7
+ import Box from '@mui/material/Box';
8
+ import Typography from '@mui/material/Typography';
9
+ import Hidden from '@mui/material/Hidden';
10
+ import MenuIcon from '@mui/icons-material/Menu';
11
11
  import { Link } from 'react-router-dom';
12
12
 
13
13
  import Logo from '../../Logo';
14
14
 
15
15
  const StyledAppBar = styled(AppBar)`
16
16
  && {
17
- z-index: ${props => props.theme.zIndex.drawer + 1};
17
+ z-index: ${props => props.theme.zIndex.drawer};
18
18
  background: ${props => props.theme.palette.background.default};
19
19
  box-shadow: none;
20
20
  top: 0;
@@ -71,7 +71,7 @@ const StyledAppBar = styled(AppBar)`
71
71
  .header-menu {
72
72
  display: none;
73
73
  }
74
- ${props => props.theme.breakpoints.down('sm')} {
74
+ ${props => props.theme.breakpoints.down('md')} {
75
75
  .header-title {
76
76
  display: none;
77
77
  }
@@ -116,7 +116,7 @@ export default function Header({
116
116
  <MenuIcon />
117
117
  </Button>
118
118
  <Link to={homeUrl} className="header-link">
119
- <Hidden smDown>
119
+ <Hidden mdDown>
120
120
  <div className="header-logo">{logo || <Logo showText={false} />}</div>
121
121
  </Hidden>
122
122
  <div className="header-title">
@@ -2,9 +2,9 @@ import React, { useEffect, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Helmet from 'react-helmet';
4
4
  import styled from 'styled-components';
5
- import Container from '@material-ui/core/Container';
6
- import Box from '@material-ui/core/Box';
7
- import Drawer from '@material-ui/core/Drawer';
5
+ import Container from '@mui/material/Container';
6
+ import Box from '@mui/material/Box';
7
+ import Drawer from '@mui/material/Drawer';
8
8
  import useWindowSize from 'react-use/lib/useWindowSize';
9
9
 
10
10
  import Sidebar from './sidebar';
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
- import withTheme from '@material-ui/core/styles/withTheme';
4
+ import withTheme from '@mui/styles/withTheme';
5
5
 
6
6
  import { withRouter, Link } from 'react-router-dom';
7
- import Button from '@material-ui/core/Button';
8
- import Typography from '@material-ui/core/Typography';
9
- import teal from '@material-ui/core/colors/teal';
7
+ import Button from '@mui/material/Button';
8
+ import Typography from '@mui/material/Typography';
9
+ import { teal } from '@mui/material/colors';
10
10
 
11
11
  import ImageIcon from '../../Icon/image';
12
12
  import Logo from '../../Logo';
@@ -77,7 +77,7 @@ const MenuItems = React.memo(styled.div`
77
77
  text-align: center;
78
78
  font-size: 0;
79
79
  }
80
- ${props => props.theme.breakpoints.down('sm')} {
80
+ ${props => props.theme.breakpoints.down('md')} {
81
81
  && .sidebar-logo {
82
82
  display: block;
83
83
  }
@@ -88,7 +88,10 @@ const gradient = 'linear-gradient(32deg, rgba(144, 255, 230, 0.1), rgba(144, 255
88
88
 
89
89
  const MenuItem = styled(Button)`
90
90
  && {
91
- display: block;
91
+ display: flex;
92
+ flex-direction: column;
93
+ justify-content: center;
94
+ align-items: center;
92
95
  width: 100%;
93
96
  transition: all 200ms ease-in-out;
94
97
  background: ${props => (props.selected ? gradient : '')};
@@ -109,13 +112,7 @@ const MenuItem = styled(Button)`
109
112
  text-transform: capitalize;
110
113
  letter-spacing: normal;
111
114
  width: 80%;
112
- }
113
-
114
- .MuiButton-label {
115
- display: flex;
116
- flex-direction: column;
117
- justify-content: center;
118
- align-items: center;
115
+ color: ${props => props.theme.palette.text.primary};
119
116
  }
120
117
  }
121
118
  `;
@@ -2,19 +2,19 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
4
  import Helmet from 'react-helmet';
5
- import Link from '@material-ui/core/Link';
5
+ import Link from '@mui/material/Link';
6
6
 
7
- import AppBar from '@material-ui/core/AppBar';
8
- import Container from '@material-ui/core/Container';
9
- import Drawer from '@material-ui/core/Drawer';
10
- import Divider from '@material-ui/core/Divider';
11
- import Toolbar from '@material-ui/core/Toolbar';
12
- import Typography from '@material-ui/core/Typography';
13
- import List from '@material-ui/core/List';
14
- import ListItem from '@material-ui/core/ListItem';
15
- import ListItemText from '@material-ui/core/ListItemText';
16
- import IconButton from '@material-ui/core/IconButton';
17
- import MenuIcon from '@material-ui/icons/Menu';
7
+ import AppBar from '@mui/material/AppBar';
8
+ import Container from '@mui/material/Container';
9
+ import Drawer from '@mui/material/Drawer';
10
+ import Divider from '@mui/material/Divider';
11
+ import Toolbar from '@mui/material/Toolbar';
12
+ import Typography from '@mui/material/Typography';
13
+ import List from '@mui/material/List';
14
+ import ListItem from '@mui/material/ListItem';
15
+ import ListItemText from '@mui/material/ListItemText';
16
+ import IconButton from '@mui/material/IconButton';
17
+ import MenuIcon from '@mui/icons-material/Menu';
18
18
 
19
19
  import Footer from '../Footer';
20
20
  import OpenInWallet from '../Wallet/Open';
@@ -63,7 +63,7 @@ export default function Layout({
63
63
  <Divider />
64
64
  <List>
65
65
  {links.map(x => (
66
- <Link className="nav-link" key={x.url} href={x.url}>
66
+ <Link className="nav-link" key={x.url} href={x.url} underline="hover">
67
67
  <ListItem button className={activeLink === x.url ? 'drawer-highlight-nav' : ''}>
68
68
  <ListItemText>
69
69
  {x.icon && (
@@ -99,7 +99,8 @@ export default function Layout({
99
99
  aria-label="open drawer"
100
100
  edge="start"
101
101
  onClick={onToggleDrawer}
102
- className="menu-button">
102
+ className="menu-button"
103
+ size="large">
103
104
  <MenuIcon />
104
105
  </IconButton>
105
106
  {showLogo ? <div className="menu-logo">{logo}</div> : <></>}
@@ -130,7 +131,8 @@ export default function Layout({
130
131
  key={x.url}
131
132
  href={x.url}
132
133
  className={`nav-link ${activeLink === x.url ? 'highlight-nav' : ''}`}
133
- color={x.color}>
134
+ color={x.color}
135
+ underline="hover">
134
136
  {x.icon && (
135
137
  <Icon
136
138
  name={x.icon}
@@ -278,7 +280,7 @@ const Div = styled.div`
278
280
  }
279
281
  }
280
282
 
281
- ${props => props.theme.breakpoints.down('sm')} {
283
+ ${props => props.theme.breakpoints.down('md')} {
282
284
  .toolbar {
283
285
  .nav-links,
284
286
  .menu-logo,
@@ -1,16 +1,18 @@
1
+ /* eslint-disable react/jsx-no-bind */
1
2
  import React, { useState, useContext, useRef } from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import styled from 'styled-components';
4
5
 
5
- import { useTheme } from '@material-ui/core/styles';
6
- import Button from '@material-ui/core/Button';
7
- import Typography from '@material-ui/core/Typography';
8
- import IconButton from '@material-ui/core/IconButton';
9
- import ClickAwayListener from '@material-ui/core/ClickAwayListener';
10
- import Popper from '@material-ui/core/Popper';
11
- import MenuItem from '@material-ui/core/MenuItem';
12
- import MenuList from '@material-ui/core/MenuList';
13
- import CheckIcon from '@material-ui/icons/Check';
6
+ import { useTheme } from '@mui/styles';
7
+ import Button from '@mui/material/Button';
8
+ import Typography from '@mui/material/Typography';
9
+ import IconButton from '@mui/material/IconButton';
10
+ import ClickAwayListener from '@mui/material/ClickAwayListener';
11
+ import Popper from '@mui/material/Popper';
12
+ import MenuItem from '@mui/material/MenuItem';
13
+ import MenuList from '@mui/material/MenuList';
14
+ import Box from '@mui/material/Box';
15
+ import CheckIcon from '@mui/icons-material/Check';
14
16
 
15
17
  import { getColor, getBackground } from '../Util';
16
18
 
@@ -44,14 +46,16 @@ function LocaleSelector(props) {
44
46
  return (
45
47
  <Div component="div" dark={dark} theme={theme} {...rest}>
46
48
  <ButtonComponent ref={anchorEl} className="trigger" onClick={() => setOpen(!open)}>
47
- <img src={dark ? globeDark : globeLight} className="trigger-image" alt="globe" />
48
- {showText ? (
49
- <Typography component="strong" className="trigger-text">
50
- {languages.find(x => x.value === locale).text}
51
- </Typography>
52
- ) : (
53
- ''
54
- )}
49
+ <Box display="flex" alignItems="center">
50
+ <img src={dark ? globeDark : globeLight} className="trigger-image" alt="globe" />
51
+ {showText ? (
52
+ <Typography component="strong" className="trigger-text">
53
+ {languages.find(x => x.value === locale).text}
54
+ </Typography>
55
+ ) : (
56
+ ''
57
+ )}
58
+ </Box>
55
59
  </ButtonComponent>
56
60
  <Popper open={open} anchorEl={anchorEl.current} {...popperProps} disablePortal>
57
61
  <div className="locales">
@@ -105,6 +109,7 @@ const Div = styled.div`
105
109
  .trigger-text {
106
110
  margin-left: 5px;
107
111
  font-size: 14px;
112
+ color: ${props => getColor(props)};
108
113
  }
109
114
  }
110
115
 
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
- import BrokenImage from '@material-ui/icons/BrokenImage';
3
+ import BrokenImage from '@mui/icons-material/BrokenImage';
4
4
 
5
5
  export default function Broken() {
6
6
  return <Root className="nft-display__broken" />;
@@ -1,7 +1,7 @@
1
1
  import React, { createContext, useContext, useMemo, useState, useRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import clsx from 'clsx';
4
- import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
4
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
5
5
  import { HorizontalStyle, InlineStyle } from './style';
6
6
 
7
7
  const NavMenuContext = createContext();
@@ -220,8 +220,10 @@ const PageScroller = ({
220
220
  pageContainer.current.addEventListener(Events.TOUCHMOVE, touchMove);
221
221
  pageContainer.current.addEventListener(Events.KEYDOWN, keyPress);
222
222
  return () => {
223
- pageContainer.current.removeEventListener(Events.TOUCHMOVE, touchMove);
224
- pageContainer.current.removeEventListener(Events.KEYDOWN, keyPress);
223
+ if (pageContainer.current?.removeEventListener) {
224
+ pageContainer.current.removeEventListener(Events.TOUCHMOVE, touchMove);
225
+ pageContainer.current.removeEventListener(Events.KEYDOWN, keyPress);
226
+ }
225
227
  };
226
228
  }, [touchMove, keyPress]);
227
229
 
@@ -2,10 +2,10 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
4
 
5
- import Card from '@material-ui/core/Card';
6
- import Button from '@material-ui/core/Button';
7
- import CardContent from '@material-ui/core/CardContent';
8
- import Typography from '@material-ui/core/Typography';
5
+ import Card from '@mui/material/Card';
6
+ import Button from '@mui/material/Button';
7
+ import CardContent from '@mui/material/CardContent';
8
+ import Typography from '@mui/material/Typography';
9
9
 
10
10
  const PricingPlan = ({ plan }) => (
11
11
  <PlanCard shadow>
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
- import Grid from '@material-ui/core/Grid';
4
+ import Grid from '@mui/material/Grid';
5
5
 
6
6
  import PricingPlan from './PricingPlan';
7
7
 
@@ -9,7 +9,7 @@ const PricingTable = ({ plans }) => {
9
9
  if (plans && plans.length > 0) {
10
10
  return (
11
11
  <Div variant="even">
12
- <Grid container spacing={2} justify="center">
12
+ <Grid container spacing={2} justifyContent="center">
13
13
  {plans.map(x => (
14
14
  <Grid item className="plan-item" key={x.id} xs={12} sm={6} md={3}>
15
15
  <PricingPlan plan={x} />
@@ -1,9 +1,9 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  /* eslint-disable no-param-reassign */
3
3
  import React from 'react';
4
- import useTheme from '@material-ui/core/styles/useTheme';
5
- import InfoIcon from '@material-ui/icons/Info';
6
- import CancelRoundedIcon from '@material-ui/icons/CancelRounded';
4
+ import useTheme from '@mui/styles/useTheme';
5
+ import InfoIcon from '@mui/icons-material/Info';
6
+ import CancelRoundedIcon from '@mui/icons-material/CancelRounded';
7
7
  import Result from './result';
8
8
  import translations from './translations';
9
9
  import { useLocaleContext } from '../Locale/context';
@@ -26,11 +26,9 @@ const ResultWrapper = ({ status, ...rest }) => {
26
26
  ResultWrapper.propTypes = {
27
27
  status: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
28
28
  ...Result.propTypes,
29
- title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
30
29
  };
31
30
  ResultWrapper.defaultProps = {
32
31
  status: '',
33
- title: '',
34
32
  };
35
33
 
36
34
  export default ResultWrapper;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
- import Box from '@material-ui/core/Box';
4
+ import Box from '@mui/material/Box';
5
5
 
6
6
  const Result = ({ icon, title, description, extra, ...rest }) => {
7
7
  return (
@@ -30,13 +30,14 @@ const Result = ({ icon, title, description, extra, ...rest }) => {
30
30
 
31
31
  Result.propTypes = {
32
32
  icon: PropTypes.element,
33
- title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,
33
+ title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
34
34
  description: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
35
35
  actions: PropTypes.any,
36
36
  extra: PropTypes.element,
37
37
  };
38
38
  Result.defaultProps = {
39
39
  icon: undefined,
40
+ title: '',
40
41
  description: '',
41
42
  actions: null,
42
43
  extra: undefined,
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
- import CircularProgress from '@material-ui/core/CircularProgress';
2
+ import CircularProgress from '@mui/material/CircularProgress';
3
3
 
4
4
  /**
5
5
  * Spinner
6
6
  *
7
- * 之前的 Spinner 实现由内外 2 个环构成, 现在改为基于 @material-ui/core/CircularProgress 的实现
7
+ * 之前的 Spinner 实现由内外 2 个环构成, 现在改为基于 @mui/material/CircularProgress 的实现
8
8
  *
9
9
  * - 之前 size prop 是 array 类型, 需要与 CircularProgress#size 兼容
10
10
  * - color 默认使用 #4598fa, 如果调用方传入了 color prop 或 style#color, 则默认 color 被覆盖
@@ -1,13 +1,13 @@
1
1
  import React, { useState, useRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
- import ExpandMore from '@material-ui/icons/ExpandMore';
5
- import Popper from '@material-ui/core/Popper';
6
- import Paper from '@material-ui/core/Paper';
7
- import ClickAwayListener from '@material-ui/core/ClickAwayListener';
8
- import MenuList from '@material-ui/core/MenuList';
9
- import MenuItem from '@material-ui/core/MenuItem';
10
- import ButtonGroup from '@material-ui/core/ButtonGroup';
4
+ import ExpandMore from '@mui/icons-material/ExpandMore';
5
+ import Popper from '@mui/material/Popper';
6
+ import Paper from '@mui/material/Paper';
7
+ import ClickAwayListener from '@mui/material/ClickAwayListener';
8
+ import MenuList from '@mui/material/MenuList';
9
+ import MenuItem from '@mui/material/MenuItem';
10
+ import ButtonGroup from '@mui/material/ButtonGroup';
11
11
  import Button from '../Button';
12
12
 
13
13
  export default function SplitButton({
@@ -72,7 +72,7 @@ export default function SplitButton({
72
72
 
73
73
  SplitButton.propTypes = {
74
74
  size: PropTypes.oneOf(['small', 'medium', 'large']),
75
- color: PropTypes.oneOf(['default', 'primary', 'secondary', 'inherit']),
75
+ color: PropTypes.oneOf(['primary', 'secondary', 'inherit']),
76
76
  menu: PropTypes.oneOfType([PropTypes.node, PropTypes.array]),
77
77
  // 也可以是用于渲染主按钮的 function
78
78
  children: PropTypes.any,
@@ -1,78 +1,74 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { withStyles } from '@material-ui/core/styles';
4
- import FormControlLabel from '@material-ui/core/FormControlLabel';
5
- import MuiSwitch from '@material-ui/core/Switch';
3
+ import { styled } from '@mui/material/styles';
4
+ import FormControlLabel from '@mui/material/FormControlLabel';
5
+ import MuiSwitch from '@mui/material/Switch';
6
6
 
7
- // 参考: https://v4.mui.com/components/switches/
8
- const IOSSwitch = withStyles(theme => ({
9
- root: {
10
- width: 42,
11
- height: 26,
7
+ // 参考: https://mui.com/material-ui/react-switch/#customization
8
+ const IOSSwitch = styled(props => (
9
+ <MuiSwitch focusVisibleClassName=".Mui-focusVisible" disableRipple {...props} />
10
+ ))(({ theme }) => ({
11
+ width: 42,
12
+ height: 26,
13
+ padding: 0,
14
+ '& .MuiSwitch-switchBase': {
12
15
  padding: 0,
13
- margin: theme.spacing(1),
14
- },
15
- switchBase: {
16
- padding: 1,
17
- '&$checked': {
16
+ margin: 2,
17
+ transitionDuration: '300ms',
18
+ '&.Mui-checked': {
18
19
  transform: 'translateX(16px)',
19
- color: theme.palette.common.white,
20
- '& + $track': {
21
- backgroundColor: '#52d869',
20
+ color: '#fff',
21
+ '& + .MuiSwitch-track': {
22
+ backgroundColor: theme.palette.mode === 'dark' ? '#2ECA45' : '#65C466',
22
23
  opacity: 1,
23
- border: 'none',
24
+ border: 0,
25
+ },
26
+ '&.Mui-disabled + .MuiSwitch-track': {
27
+ opacity: 0.5,
24
28
  },
25
29
  },
26
- '&$focusVisible $thumb': {
27
- color: '#52d869',
30
+ '&.Mui-focusVisible .MuiSwitch-thumb': {
31
+ color: '#33cf4d',
28
32
  border: '6px solid #fff',
29
33
  },
34
+ '&.Mui-disabled .MuiSwitch-thumb': {
35
+ color: theme.palette.mode === 'light' ? theme.palette.grey[100] : theme.palette.grey[600],
36
+ },
37
+ '&.Mui-disabled + .MuiSwitch-track': {
38
+ opacity: theme.palette.mode === 'light' ? 0.7 : 0.3,
39
+ },
30
40
  },
31
- thumb: {
32
- width: 24,
33
- height: 24,
34
- },
35
- track: {
36
- // fix: 下边框截断问题
41
+ '& .MuiSwitch-thumb': {
37
42
  boxSizing: 'border-box',
43
+ width: 22,
44
+ height: 22,
45
+ },
46
+ '& .MuiSwitch-track': {
38
47
  borderRadius: 26 / 2,
39
- border: `1px solid ${theme.palette.grey[400]}`,
40
- backgroundColor: theme.palette.grey[50],
48
+ backgroundColor: theme.palette.mode === 'light' ? '#E9E9EA' : '#39393D',
41
49
  opacity: 1,
42
- transition: theme.transitions.create(['background-color', 'border']),
50
+ transition: theme.transitions.create(['background-color'], {
51
+ duration: 500,
52
+ }),
43
53
  },
44
- checked: {},
45
- focusVisible: {},
46
- }))(({ classes, ...props }) => {
47
- return (
48
- <MuiSwitch
49
- focusVisibleClassName={classes.focusVisible}
50
- disableRipple
51
- classes={{
52
- root: classes.root,
53
- switchBase: classes.switchBase,
54
- thumb: classes.thumb,
55
- track: classes.track,
56
- checked: classes.checked,
57
- }}
58
- {...props}
59
- />
60
- );
61
- });
54
+ }));
62
55
 
63
56
  /**
64
57
  * 抽取 blocklet server 中使用的 iOS 风格的 Switch, 该组件把 FormControlLabel 和 MuiSwitch 组合在一起,
65
58
  * 兼容 mui Switch props, 使用 labelProps 控制 FormControlLabel
66
59
  */
67
60
  function Switch({ labelProps, ...rest }) {
68
- return <FormControlLabel control={<IOSSwitch {...rest} />} {...labelProps} />;
61
+ if (labelProps) {
62
+ return <FormControlLabel control={<IOSSwitch {...rest} />} {...labelProps} />;
63
+ }
64
+ return <IOSSwitch {...rest} />;
69
65
  }
70
66
 
71
67
  Switch.propTypes = {
72
68
  labelProps: PropTypes.object,
73
69
  };
74
70
  Switch.defaultProps = {
75
- labelProps: {},
71
+ labelProps: null,
76
72
  };
77
73
 
78
74
  export default Switch;