@arcblock/ux 1.15.31 → 1.15.35
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/Blocklet/index.js +6 -3
- package/lib/Switch/index.js +107 -0
- package/package.json +4 -4
package/lib/Blocklet/index.js
CHANGED
|
@@ -42,7 +42,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
42
42
|
const Div = _styledComponents.default.div.withConfig({
|
|
43
43
|
displayName: "Blocklet__Div",
|
|
44
44
|
componentId: "sc-3dga5l-0"
|
|
45
|
-
})(["&.arcblock-blocklet{border:1px solid #f2f2f2;padding:0 16px;border-radius:12px;background:#fff;overflow:hidden;&:hover{filter:drop-shadow(0px 4px 12px rgba(92,92,92,0.04));}}.arcblock-blocklet__content{padding:16px 0;}.arcblock-blocklet__content--main{display:flex;align-items:
|
|
45
|
+
})(["&.arcblock-blocklet{border:1px solid #f2f2f2;padding:0 16px;border-radius:12px;background:#fff;overflow:hidden;&:hover{filter:drop-shadow(0px 4px 12px rgba(92,92,92,0.04));}}.arcblock-blocklet__content{padding:16px 0;}.arcblock-blocklet__content--main{display:flex;align-items:center;cursor:pointer;}.arcblock-blocklet__content--body{overflow:hidden;flex:1;display:flex;align-items:flex-start;}.arcblock-blocklet__addons{padding:16px 0;border-top:1px solid #f2f2f2;}.arcblock-blocklet__cover{width:100px;height:100px;margin-right:16px;overflow:hidden;border-radius:12px;}.arcblock-blocklet__info{flex:1;overflow:hidden;.arcblock-blocklet__button{margin-top:16px;display:inline-block;}}.arcblock-blocklet__button{& > *{position:relative;&::before{content:'';position:absolute;display:block;left:50%;top:50%;height:", "%;width:", "%;transform:translate(-50%,-50%);}}& > *:not(.Mui-disabled){background-color:rgba(79,106,246,0.06);color:", ";}}.arcblock-blocklet__title{margin:0;font-size:18px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.arcblock-blocklet__describe{margin:2px 0 0;color:#999;font-size:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.arcblock-blocklet__addons{display:flex;justify-content:space-between;color:#999;font-size:14px;position:relative;}.arcblock-blocklet__addons--item{white-space:nowrap;}&.arcblock-blocklet--size-md{&:hover{position:relative;}.arcblock-blocklet__title{margin-bottom:3px;}.arcblock-blocklet__describe{white-space:normal;height:2.86em;}.arcblock-blocklet__button{margin-top:5px;}}&.arcblock-blocklet--size-sm,&.arcblock-blocklet--size-xs{.arcblock-blocklet__content{padding:12px 0;}.arcblock-blocklet__cover{width:48px;height:48px;border-radius:6px;}.arcblock-blocklet__addons{padding:8px 0;.arcblock-blocklet__addons--item{font-size:12px;}}}&.arcblock-blocklet--size-xs{.arcblock-blocklet__addons{display:none !important;}}"], props => props.scaleClickZone * 100, props => props.scaleClickZone * 100, props => props.theme.palette.primary.main);
|
|
46
46
|
|
|
47
47
|
function BlockletIcon(_ref) {
|
|
48
48
|
let {
|
|
@@ -142,6 +142,8 @@ function Blocklet(_ref2) {
|
|
|
142
142
|
className: "arcblock-blocklet__content--main",
|
|
143
143
|
onClick: _onMainClick,
|
|
144
144
|
ref: container
|
|
145
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
146
|
+
className: "arcblock-blocklet__content--body"
|
|
145
147
|
}, cover && /*#__PURE__*/_react.default.createElement("div", {
|
|
146
148
|
className: "arcblock-blocklet__cover"
|
|
147
149
|
}, /*#__PURE__*/_react.default.createElement(_Img.default, {
|
|
@@ -187,14 +189,15 @@ function Blocklet(_ref2) {
|
|
|
187
189
|
marginRight: 3,
|
|
188
190
|
color: 'inherit'
|
|
189
191
|
}
|
|
190
|
-
}), buttonText)))))), /*#__PURE__*/_react.default.createElement("div", {
|
|
192
|
+
}), buttonText))))))), /*#__PURE__*/_react.default.createElement("div", {
|
|
191
193
|
className: "arcblock-blocklet__addons"
|
|
192
194
|
}, addons.map((item, index) => /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
193
195
|
component: "span",
|
|
194
196
|
variant: "caption",
|
|
195
197
|
className: "arcblock-blocklet__addons--item" // eslint-disable-next-line react/no-array-index-key
|
|
196
198
|
,
|
|
197
|
-
key: index
|
|
199
|
+
key: index,
|
|
200
|
+
title: item.title
|
|
198
201
|
}, item.empty ? null : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(BlockletIcon, {
|
|
199
202
|
name: item.icon
|
|
200
203
|
}), item.pretty ? prettySize(item.value) : item.value)))));
|
|
@@ -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.35",
|
|
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": "e81fb3d8f4283b180866c26738e9db0ec89a06f3",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@arcblock/icons": "^1.15.
|
|
58
|
-
"@arcblock/react-hooks": "^1.15.
|
|
57
|
+
"@arcblock/icons": "^1.15.35",
|
|
58
|
+
"@arcblock/react-hooks": "^1.15.35",
|
|
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",
|