@arcblock/ux 1.15.33 → 1.15.34
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/Switch/index.js +107 -0
- package/package.json +4 -4
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _styles = require("@material-ui/core/styles");
|
|
13
|
+
|
|
14
|
+
var _FormControlLabel = _interopRequireDefault(require("@material-ui/core/FormControlLabel"));
|
|
15
|
+
|
|
16
|
+
var _Switch = _interopRequireDefault(require("@material-ui/core/Switch"));
|
|
17
|
+
|
|
18
|
+
const _excluded = ["classes"],
|
|
19
|
+
_excluded2 = ["labelProps"];
|
|
20
|
+
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
|
|
23
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
24
|
+
|
|
25
|
+
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
|
+
|
|
27
|
+
// 参考: https://v4.mui.com/components/switches/
|
|
28
|
+
const IOSSwitch = (0, _styles.withStyles)(theme => ({
|
|
29
|
+
root: {
|
|
30
|
+
width: 42,
|
|
31
|
+
height: 26,
|
|
32
|
+
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'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
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
|
|
81
|
+
}
|
|
82
|
+
}, props));
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* 抽取 blocklet server 中使用的 iOS 风格的 Switch, 该组件把 FormControlLabel 和 MuiSwitch 组合在一起,
|
|
86
|
+
* 兼容 mui Switch props, 使用 labelProps 控制 FormControlLabel
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
function Switch(_ref2) {
|
|
90
|
+
let {
|
|
91
|
+
labelProps
|
|
92
|
+
} = _ref2,
|
|
93
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
94
|
+
|
|
95
|
+
return /*#__PURE__*/_react.default.createElement(_FormControlLabel.default, Object.assign({
|
|
96
|
+
control: /*#__PURE__*/_react.default.createElement(IOSSwitch, rest)
|
|
97
|
+
}, labelProps));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Switch.propTypes = {
|
|
101
|
+
labelProps: _propTypes.default.object
|
|
102
|
+
};
|
|
103
|
+
Switch.defaultProps = {
|
|
104
|
+
labelProps: {}
|
|
105
|
+
};
|
|
106
|
+
var _default = Switch;
|
|
107
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.34",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"react": ">=16.12.0",
|
|
53
53
|
"react-ga": "^2.7.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "2e499c768365882fdaed4a588163fde6600b7603",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@arcblock/icons": "^1.15.
|
|
58
|
-
"@arcblock/react-hooks": "^1.15.
|
|
57
|
+
"@arcblock/icons": "^1.15.34",
|
|
58
|
+
"@arcblock/react-hooks": "^1.15.34",
|
|
59
59
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
60
60
|
"@material-ui/core": "^4.12.3",
|
|
61
61
|
"@material-ui/icons": "4.11.2",
|