@arcblock/ux 2.0.0 → 2.0.3

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.
@@ -11,9 +11,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  var _styledComponents = _interopRequireDefault(require("styled-components"));
13
13
 
14
- var _green = _interopRequireDefault(require("@mui/material/colors/green"));
15
-
16
- var _blue = _interopRequireDefault(require("@mui/material/colors/blue"));
14
+ var _colors = require("@mui/material/colors");
17
15
 
18
16
  var _Logo = _interopRequireDefault(require("../Logo"));
19
17
 
@@ -62,13 +60,13 @@ function ActivityIndicator(_ref) {
62
60
  showText: false
63
61
  }), /*#__PURE__*/_react.default.createElement(Orbit, {
64
62
  size: 56,
65
- orbitColor: _green.default[500],
66
- atomColor: _green.default[500],
63
+ orbitColor: _colors.green[500],
64
+ atomColor: _colors.green[500],
67
65
  duration: 1
68
66
  }), /*#__PURE__*/_react.default.createElement(Orbit, {
69
67
  size: 80,
70
- orbitColor: _blue.default[800],
71
- atomColor: _blue.default[800],
68
+ orbitColor: _colors.blue[800],
69
+ atomColor: _colors.blue[800],
72
70
  duration: 1.5
73
71
  }), /*#__PURE__*/_react.default.createElement(Orbit, {
74
72
  size: 100,
@@ -13,7 +13,7 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
13
13
 
14
14
  var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
15
15
 
16
- var _blueGrey = _interopRequireDefault(require("@mui/material/colors/blueGrey"));
16
+ var _colors = require("@mui/material/colors");
17
17
 
18
18
  var _Icon = _interopRequireDefault(require("../Icon"));
19
19
 
@@ -75,7 +75,7 @@ const Alert = props => {
75
75
  borderColor
76
76
  } = types[type] || types.success;
77
77
  const styles = Object.assign({
78
- color: _blueGrey.default[500],
78
+ color: _colors.blueGrey[500],
79
79
  backgroundColor: variant === 'border' ? backgroundColor : 'transparent',
80
80
  borderLeft: variant === 'border' ? "5px solid ".concat(borderColor) : 'none'
81
81
  }, style);
@@ -19,7 +19,7 @@ var _Button = _interopRequireDefault(require("@mui/material/Button"));
19
19
 
20
20
  var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
21
21
 
22
- var _teal = _interopRequireDefault(require("@mui/material/colors/teal"));
22
+ var _colors = require("@mui/material/colors");
23
23
 
24
24
  var _image = _interopRequireDefault(require("../../Icon/image"));
25
25
 
@@ -110,7 +110,7 @@ const gradient = 'linear-gradient(32deg, rgba(144, 255, 230, 0.1), rgba(144, 255
110
110
  const MenuItem = (0, _styledComponents.default)(_Button.default).withConfig({
111
111
  displayName: "sidebar__MenuItem",
112
112
  componentId: "sc-gaosgy-1"
113
- })(["&&{display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;transition:all 200ms ease-in-out;background:", ";padding:24px 0;border-left:2px solid ", ";border-radius:0;&:hover{background:", ";border-left-color:", ";}.menu-title{margin-top:8px;font-size:12px;font-weight:500;text-align:center;text-transform:capitalize;letter-spacing:normal;width:80%;color:", ";}}"], props => props.selected ? gradient : '', props => props.selected ? _teal.default.A700 : 'transparent', gradient, _teal.default.A700, props => props.theme.palette.text.primary);
113
+ })(["&&{display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;transition:all 200ms ease-in-out;background:", ";padding:24px 0;border-left:2px solid ", ";border-radius:0;&:hover{background:", ";border-left-color:", ";}.menu-title{margin-top:8px;font-size:12px;font-weight:500;text-align:center;text-transform:capitalize;letter-spacing:normal;width:80%;color:", ";}}"], props => props.selected ? gradient : '', props => props.selected ? _colors.teal.A700 : 'transparent', gradient, _colors.teal.A700, props => props.theme.palette.text.primary);
114
114
 
115
115
  var _default = (0, _reactRouterDom.withRouter)((0, _withTheme.default)(Sidebar));
116
116
 
@@ -9,14 +9,13 @@ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _styles = require("@mui/styles");
12
+ var _styles = require("@mui/material/styles");
13
13
 
14
14
  var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
15
15
 
16
16
  var _Switch = _interopRequireDefault(require("@mui/material/Switch"));
17
17
 
18
- const _excluded = ["classes"],
19
- _excluded2 = ["labelProps"];
18
+ const _excluded = ["labelProps"];
20
19
 
21
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
21
 
@@ -24,62 +23,59 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
24
23
 
25
24
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
26
25
 
27
- // 参考: https://v4.mui.com/components/switches/
28
- const IOSSwitch = (0, _styles.withStyles)(theme => ({
29
- root: {
26
+ // 参考: https://mui.com/material-ui/react-switch/#customization
27
+ const IOSSwitch = (0, _styles.styled)(props => /*#__PURE__*/_react.default.createElement(_Switch.default, Object.assign({
28
+ focusVisibleClassName: ".Mui-focusVisible",
29
+ disableRipple: true
30
+ }, props)))(_ref => {
31
+ let {
32
+ theme
33
+ } = _ref;
34
+ return {
30
35
  width: 42,
31
36
  height: 26,
32
37
  padding: 0,
33
- margin: theme.spacing(1)
34
- },
35
- switchBase: {
36
- padding: 1,
37
- '&$checked': {
38
- transform: 'translateX(16px)',
39
- color: theme.palette.common.white,
40
- '& + $track': {
41
- backgroundColor: '#52d869',
42
- opacity: 1,
43
- border: 'none'
38
+ '& .MuiSwitch-switchBase': {
39
+ padding: 0,
40
+ margin: 2,
41
+ transitionDuration: '300ms',
42
+ '&.Mui-checked': {
43
+ transform: 'translateX(16px)',
44
+ color: '#fff',
45
+ '& + .MuiSwitch-track': {
46
+ backgroundColor: theme.palette.mode === 'dark' ? '#2ECA45' : '#65C466',
47
+ opacity: 1,
48
+ border: 0
49
+ },
50
+ '&.Mui-disabled + .MuiSwitch-track': {
51
+ opacity: 0.5
52
+ }
53
+ },
54
+ '&.Mui-focusVisible .MuiSwitch-thumb': {
55
+ color: '#33cf4d',
56
+ border: '6px solid #fff'
57
+ },
58
+ '&.Mui-disabled .MuiSwitch-thumb': {
59
+ color: theme.palette.mode === 'light' ? theme.palette.grey[100] : theme.palette.grey[600]
60
+ },
61
+ '&.Mui-disabled + .MuiSwitch-track': {
62
+ opacity: theme.palette.mode === 'light' ? 0.7 : 0.3
44
63
  }
45
64
  },
46
- '&$focusVisible $thumb': {
47
- color: '#52d869',
48
- border: '6px solid #fff'
49
- }
50
- },
51
- thumb: {
52
- width: 24,
53
- height: 24
54
- },
55
- track: {
56
- // fix: 下边框截断问题
57
- boxSizing: 'border-box',
58
- borderRadius: 26 / 2,
59
- border: "1px solid ".concat(theme.palette.grey[400]),
60
- backgroundColor: theme.palette.grey[50],
61
- opacity: 1,
62
- transition: theme.transitions.create(['background-color', 'border'])
63
- },
64
- checked: {},
65
- focusVisible: {}
66
- }))(_ref => {
67
- let {
68
- classes
69
- } = _ref,
70
- props = _objectWithoutProperties(_ref, _excluded);
71
-
72
- return /*#__PURE__*/_react.default.createElement(_Switch.default, Object.assign({
73
- focusVisibleClassName: classes.focusVisible,
74
- disableRipple: true,
75
- classes: {
76
- root: classes.root,
77
- switchBase: classes.switchBase,
78
- thumb: classes.thumb,
79
- track: classes.track,
80
- checked: classes.checked
65
+ '& .MuiSwitch-thumb': {
66
+ boxSizing: 'border-box',
67
+ width: 22,
68
+ height: 22
69
+ },
70
+ '& .MuiSwitch-track': {
71
+ borderRadius: 26 / 2,
72
+ backgroundColor: theme.palette.mode === 'light' ? '#E9E9EA' : '#39393D',
73
+ opacity: 1,
74
+ transition: theme.transitions.create(['background-color'], {
75
+ duration: 500
76
+ })
81
77
  }
82
- }, props));
78
+ };
83
79
  });
84
80
  /**
85
81
  * 抽取 blocklet server 中使用的 iOS 风格的 Switch, 该组件把 FormControlLabel 和 MuiSwitch 组合在一起,
@@ -90,18 +86,22 @@ function Switch(_ref2) {
90
86
  let {
91
87
  labelProps
92
88
  } = _ref2,
93
- rest = _objectWithoutProperties(_ref2, _excluded2);
89
+ rest = _objectWithoutProperties(_ref2, _excluded);
90
+
91
+ if (labelProps) {
92
+ return /*#__PURE__*/_react.default.createElement(_FormControlLabel.default, Object.assign({
93
+ control: /*#__PURE__*/_react.default.createElement(IOSSwitch, rest)
94
+ }, labelProps));
95
+ }
94
96
 
95
- return /*#__PURE__*/_react.default.createElement(_FormControlLabel.default, Object.assign({
96
- control: /*#__PURE__*/_react.default.createElement(IOSSwitch, rest)
97
- }, labelProps));
97
+ return /*#__PURE__*/_react.default.createElement(IOSSwitch, rest);
98
98
  }
99
99
 
100
100
  Switch.propTypes = {
101
101
  labelProps: _propTypes.default.object
102
102
  };
103
103
  Switch.defaultProps = {
104
- labelProps: {}
104
+ labelProps: null
105
105
  };
106
106
  var _default = Switch;
107
107
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.0.0",
3
+ "version": "2.0.3",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -53,10 +53,10 @@
53
53
  "react": ">=18.1.0",
54
54
  "react-ga": "^2.7.0"
55
55
  },
56
- "gitHead": "e246936f30652b6d526c33b1462f8ad5e93e7722",
56
+ "gitHead": "98bbad1ac5bd83c71dc49c1d883babe5b46731a6",
57
57
  "dependencies": {
58
- "@arcblock/icons": "^2.0.0",
59
- "@arcblock/react-hooks": "^2.0.0",
58
+ "@arcblock/icons": "^2.0.3",
59
+ "@arcblock/react-hooks": "^2.0.3",
60
60
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
61
61
  "@emotion/react": "^11.9.0",
62
62
  "@emotion/styled": "^11.8.1",
@@ -1,8 +1,7 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
- import green from '@mui/material/colors/green';
5
- import blue from '@mui/material/colors/blue';
4
+ import { green, blue } from '@mui/material/colors';
6
5
 
7
6
  import Logo from '../Logo';
8
7
  import colors from '../Colors';
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
4
  import Typography from '@mui/material/Typography';
5
- import blueGrey from '@mui/material/colors/blueGrey';
5
+ import { blueGrey } from '@mui/material/colors';
6
6
 
7
7
  import Icon from '../Icon';
8
8
  import { mergeProps } from '../Util';
@@ -6,7 +6,7 @@ import withTheme from '@mui/styles/withTheme';
6
6
  import { withRouter, Link } from 'react-router-dom';
7
7
  import Button from '@mui/material/Button';
8
8
  import Typography from '@mui/material/Typography';
9
- import teal from '@mui/material/colors/teal';
9
+ import { teal } from '@mui/material/colors';
10
10
 
11
11
  import ImageIcon from '../../Icon/image';
12
12
  import Logo from '../../Logo';
@@ -1,78 +1,74 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { withStyles } from '@mui/styles';
3
+ import { styled } from '@mui/material/styles';
4
4
  import FormControlLabel from '@mui/material/FormControlLabel';
5
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;