@arcblock/ux 1.14.44 → 1.14.48
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/Dialog/confirm.js +84 -0
- package/lib/Dialog/dialog.js +137 -0
- package/lib/Dialog/index.js +23 -0
- package/lib/Screenshot/index.js +1 -1
- package/lib/Spinner/index.js +16 -3
- package/package.json +4 -4
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = Confirm;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
|
13
|
+
|
|
14
|
+
var _dialog = _interopRequireDefault(require("./dialog"));
|
|
15
|
+
|
|
16
|
+
const _excluded = ["title", "children", "onConfirm", "onCancel", "showCancelButton", "confirmButton", "cancelButton", "PaperProps"];
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
// 注意排在 {...rest} 之后的 props 优先级更高
|
|
25
|
+
function Confirm(_ref) {
|
|
26
|
+
let {
|
|
27
|
+
title,
|
|
28
|
+
children,
|
|
29
|
+
onConfirm,
|
|
30
|
+
onCancel,
|
|
31
|
+
showCancelButton,
|
|
32
|
+
confirmButton,
|
|
33
|
+
cancelButton,
|
|
34
|
+
PaperProps
|
|
35
|
+
} = _ref,
|
|
36
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
37
|
+
|
|
38
|
+
// 去除 dialog 默认的 300 最小高度
|
|
39
|
+
PaperProps.style = Object.assign({
|
|
40
|
+
minHeight: 0
|
|
41
|
+
}, PaperProps.style);
|
|
42
|
+
return /*#__PURE__*/_react.default.createElement(_dialog.default, Object.assign({
|
|
43
|
+
title: title,
|
|
44
|
+
PaperProps: PaperProps
|
|
45
|
+
}, rest, {
|
|
46
|
+
onClose: () => onCancel(),
|
|
47
|
+
actions: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, showCancelButton && /*#__PURE__*/_react.default.createElement(_Button.default, Object.assign({
|
|
48
|
+
onClick: () => onCancel(),
|
|
49
|
+
color: "primary"
|
|
50
|
+
}, cancelButton.props), cancelButton.text), /*#__PURE__*/_react.default.createElement(_Button.default, Object.assign({
|
|
51
|
+
onClick: () => onConfirm(),
|
|
52
|
+
color: "primary",
|
|
53
|
+
autoFocus: true
|
|
54
|
+
}, confirmButton.props), confirmButton.text))
|
|
55
|
+
}), children);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
Confirm.propTypes = {
|
|
59
|
+
title: _propTypes.default.node.isRequired,
|
|
60
|
+
children: _propTypes.default.node.isRequired,
|
|
61
|
+
onConfirm: _propTypes.default.func.isRequired,
|
|
62
|
+
onCancel: _propTypes.default.func.isRequired,
|
|
63
|
+
showCancelButton: _propTypes.default.bool,
|
|
64
|
+
// 可以传入 {text: ..., props: ...}
|
|
65
|
+
confirmButton: _propTypes.default.shape({
|
|
66
|
+
text: _propTypes.default.string.isRequired,
|
|
67
|
+
props: _propTypes.default.object
|
|
68
|
+
}),
|
|
69
|
+
cancelButton: _propTypes.default.shape({
|
|
70
|
+
text: _propTypes.default.string.isRequired,
|
|
71
|
+
props: _propTypes.default.object
|
|
72
|
+
}),
|
|
73
|
+
PaperProps: _propTypes.default.object
|
|
74
|
+
};
|
|
75
|
+
Confirm.defaultProps = {
|
|
76
|
+
showCancelButton: true,
|
|
77
|
+
confirmButton: {
|
|
78
|
+
text: 'Confirm'
|
|
79
|
+
},
|
|
80
|
+
cancelButton: {
|
|
81
|
+
text: 'Cancel'
|
|
82
|
+
},
|
|
83
|
+
PaperProps: {}
|
|
84
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
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 _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
|
|
14
|
+
var _Dialog = _interopRequireDefault(require("@material-ui/core/Dialog"));
|
|
15
|
+
|
|
16
|
+
var _DialogContent = _interopRequireDefault(require("@material-ui/core/DialogContent"));
|
|
17
|
+
|
|
18
|
+
var _DialogActions = _interopRequireDefault(require("@material-ui/core/DialogActions"));
|
|
19
|
+
|
|
20
|
+
var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
|
|
21
|
+
|
|
22
|
+
var _useMediaQuery = _interopRequireDefault(require("@material-ui/core/useMediaQuery"));
|
|
23
|
+
|
|
24
|
+
var _styles = require("@material-ui/core/styles");
|
|
25
|
+
|
|
26
|
+
var _Close = _interopRequireDefault(require("@material-ui/icons/Close"));
|
|
27
|
+
|
|
28
|
+
const _excluded = ["children", "title", "prepend", "toolbar", "actions", "showCloseButton", "actionsPosition", "PaperProps"];
|
|
29
|
+
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
|
|
34
|
+
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; }
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Dialog
|
|
38
|
+
*
|
|
39
|
+
* - 固定尺寸或特殊的尺寸控制需求, 可使用 PaperProps.style (不再提供 width/height 等 props)
|
|
40
|
+
* 注意: 当设置明确的 width 时, 可能需要同时设置 maxWidth=false (mui dialog 默认 maxWidth=sm, 设置的 width 可能受限)
|
|
41
|
+
* - 添加默认最小尺寸 (300x300), 在需要 先展示 loading 再展示异步数据 的时候避免 loading 阶段窗口过小
|
|
42
|
+
*/
|
|
43
|
+
const Dialog = _ref => {
|
|
44
|
+
let {
|
|
45
|
+
children,
|
|
46
|
+
title,
|
|
47
|
+
prepend,
|
|
48
|
+
toolbar,
|
|
49
|
+
actions,
|
|
50
|
+
showCloseButton,
|
|
51
|
+
actionsPosition,
|
|
52
|
+
PaperProps
|
|
53
|
+
} = _ref,
|
|
54
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
55
|
+
|
|
56
|
+
const theme = (0, _styles.useTheme)(); // 不管是否是 mobile 设备, 只要屏宽 < sm, dialog 就处于 mobile 模式
|
|
57
|
+
|
|
58
|
+
const isMobile = (0, _useMediaQuery.default)(theme.breakpoints.down('sm'));
|
|
59
|
+
const showHeader = title || showCloseButton || toolbar;
|
|
60
|
+
|
|
61
|
+
const handleOnClose = (e, reason) => {
|
|
62
|
+
// escapeKeyDown/backdropClick
|
|
63
|
+
const {
|
|
64
|
+
onClose
|
|
65
|
+
} = rest;
|
|
66
|
+
|
|
67
|
+
if (onClose) {
|
|
68
|
+
onClose(e, reason);
|
|
69
|
+
}
|
|
70
|
+
}; // 添加默认最小尺寸 (300x300)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
PaperProps.style = Object.assign({
|
|
74
|
+
minWidth: 300,
|
|
75
|
+
minHeight: 300
|
|
76
|
+
}, PaperProps.style);
|
|
77
|
+
|
|
78
|
+
const closeButton = /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
79
|
+
className: "ux-dialog_closeButton",
|
|
80
|
+
onClick: e => handleOnClose(e, 'closeButton')
|
|
81
|
+
}, /*#__PURE__*/_react.default.createElement(_Close.default, null));
|
|
82
|
+
|
|
83
|
+
return /*#__PURE__*/_react.default.createElement(StyledMuiDialog, Object.assign({
|
|
84
|
+
fullScreen: isMobile,
|
|
85
|
+
onClose: handleOnClose,
|
|
86
|
+
PaperProps: PaperProps
|
|
87
|
+
}, rest), showHeader && /*#__PURE__*/_react.default.createElement(Header, {
|
|
88
|
+
className: "ux-dialog_header",
|
|
89
|
+
isMobile: isMobile
|
|
90
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
91
|
+
className: "ux-dialog_left"
|
|
92
|
+
}, showCloseButton && isMobile && closeButton, prepend && /*#__PURE__*/_react.default.createElement("div", {
|
|
93
|
+
className: "ux-dialog_prepend"
|
|
94
|
+
}, prepend), title && /*#__PURE__*/_react.default.createElement("h6", {
|
|
95
|
+
className: "ux-dialog_title"
|
|
96
|
+
}, title)), /*#__PURE__*/_react.default.createElement("div", {
|
|
97
|
+
className: "ux-dialog_right"
|
|
98
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
99
|
+
className: "ux-dialog_toolbar"
|
|
100
|
+
}, toolbar), showCloseButton && !isMobile && closeButton)), /*#__PURE__*/_react.default.createElement(_DialogContent.default, null, children), actions && /*#__PURE__*/_react.default.createElement(_DialogActions.default, {
|
|
101
|
+
className: "ux-dialog_actions--".concat(actionsPosition)
|
|
102
|
+
}, actions));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
Dialog.propTypes = {
|
|
106
|
+
children: _propTypes.default.node.isRequired,
|
|
107
|
+
title: _propTypes.default.node,
|
|
108
|
+
// 在 title 之前追加内容, 比如返回按钮
|
|
109
|
+
prepend: _propTypes.default.node,
|
|
110
|
+
// 顶部工具栏, 在 close button 另一侧
|
|
111
|
+
toolbar: _propTypes.default.node,
|
|
112
|
+
actions: _propTypes.default.node,
|
|
113
|
+
showCloseButton: _propTypes.default.bool,
|
|
114
|
+
actionsPosition: _propTypes.default.oneOf(['left', 'center', 'right']),
|
|
115
|
+
PaperProps: _propTypes.default.object
|
|
116
|
+
};
|
|
117
|
+
Dialog.defaultProps = {
|
|
118
|
+
showCloseButton: true,
|
|
119
|
+
title: '',
|
|
120
|
+
prepend: null,
|
|
121
|
+
toolbar: null,
|
|
122
|
+
actions: null,
|
|
123
|
+
actionsPosition: 'right',
|
|
124
|
+
PaperProps: {}
|
|
125
|
+
};
|
|
126
|
+
const StyledMuiDialog = (0, _styledComponents.default)(_Dialog.default).withConfig({
|
|
127
|
+
displayName: "dialog__StyledMuiDialog",
|
|
128
|
+
componentId: "sc-kt5gv0-0"
|
|
129
|
+
})([".MuiDialog-paper{border-radius:", "px;}.MuiDialogContent-root{padding:16px 24px;}.MuiDialogActions-root{padding:8px 24px 16px 24px;}.MuiDialogActions-root.ux-dialog_actions--left{justify-content:flex-start;}.MuiDialogActions-root.ux-dialog_actions--right{justify-content:flex-end;}.MuiDialogActions-root.ux-dialog_actions--center{justify-content:center;}"], props => props.fullScreen ? 0 : 12);
|
|
130
|
+
|
|
131
|
+
const Header = _styledComponents.default.div.withConfig({
|
|
132
|
+
displayName: "dialog__Header",
|
|
133
|
+
componentId: "sc-kt5gv0-1"
|
|
134
|
+
})(["display:flex;justify-content:space-between;align-items:center;padding:16px 24px;.ux-dialog_left{display:flex;justify-content:flex-start;align-items:center;min-width:0;}.ux-dialog_right{display:flex;justify-content:flex-end;align-items:center;}.ux-dialog_toolbar{display:flex;align-items:center;}.ux-dialog_title{margin:0;font-size:18px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.ux-dialog_closeButton{", "}"], props => props.isMobile ? 'margin-left: -12px;' : 'margin-right: -12px;');
|
|
135
|
+
|
|
136
|
+
var _default = Dialog;
|
|
137
|
+
exports.default = _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _dialog.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "Confirm", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _confirm.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
var _dialog = _interopRequireDefault(require("./dialog"));
|
|
20
|
+
|
|
21
|
+
var _confirm = _interopRequireDefault(require("./confirm"));
|
|
22
|
+
|
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/lib/Screenshot/index.js
CHANGED
|
@@ -174,7 +174,7 @@ const Screenshot = props => {
|
|
|
174
174
|
const Div = _styledComponents.default.div.withConfig({
|
|
175
175
|
displayName: "Screenshot__Div",
|
|
176
176
|
componentId: "sc-el6nkq-0"
|
|
177
|
-
})(["@media (max-width:", "px){transform-origin:0 0;transform:scale(", ");}.device-content video,.device-content img{border-radius:", "px;background-color:#fff;background-position:center center;background-size:cover;object-fit:cover;width:100.1%;height:100.1%;}"], props => types[props.type].width, props => types[props.type].scale, props => props.contentRadius);
|
|
177
|
+
})(["@media (max-width:", "px){transform-origin:0 0;transform:scale(", ");}.device-content{overflow:hidden;}.device-content video,.device-content img{border-radius:", "px;background-color:#fff;background-position:center center;background-size:cover;object-fit:cover;width:100.1%;height:100.1%;}"], props => types[props.type].width, props => types[props.type].scale, props => props.contentRadius);
|
|
178
178
|
|
|
179
179
|
Screenshot.propTypes = {
|
|
180
180
|
type: _propTypes.default.oneOf(Object.keys(types)),
|
package/lib/Spinner/index.js
CHANGED
|
@@ -7,6 +7,8 @@ exports.default = Spinner;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
10
12
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
13
|
|
|
12
14
|
var _icons = require("@arcblock/icons");
|
|
@@ -16,15 +18,26 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
18
|
/**
|
|
17
19
|
* Spinner
|
|
18
20
|
*/
|
|
19
|
-
function Spinner() {
|
|
20
|
-
return /*#__PURE__*/_react.default.createElement(Root,
|
|
21
|
+
function Spinner(props) {
|
|
22
|
+
return /*#__PURE__*/_react.default.createElement(Root, props, /*#__PURE__*/_react.default.createElement(_icons.SpinnerOuter, {
|
|
21
23
|
className: "scanned-spinner_outer"
|
|
22
24
|
}), /*#__PURE__*/_react.default.createElement(_icons.SpinnerInner, {
|
|
23
25
|
className: "scanned-spinner_inner"
|
|
24
26
|
}));
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
Spinner.propTypes = {
|
|
30
|
+
size: _propTypes.default.array,
|
|
31
|
+
duration: _propTypes.default.array
|
|
32
|
+
};
|
|
33
|
+
Spinner.defaultProps = {
|
|
34
|
+
// 外圈/内圈 尺寸
|
|
35
|
+
size: [56, 32],
|
|
36
|
+
// 外圈/内圈 动画 duration
|
|
37
|
+
duration: [1, 1.6]
|
|
38
|
+
};
|
|
39
|
+
|
|
27
40
|
const Root = _styledComponents.default.div.withConfig({
|
|
28
41
|
displayName: "Spinner__Root",
|
|
29
42
|
componentId: "sc-r57khp-0"
|
|
30
|
-
})(["display:inline-block;position:relative;width:
|
|
43
|
+
})(["display:inline-block;position:relative;width:", "px;height:", "px;.scanned-spinner_outer{width:100%;height:100%;animation:rota ", "s linear infinite;}.scanned-spinner_inner{position:absolute;top:50%;left:50%;width:", "px;height:", "px;margin:", ";animation:rota ", "s linear infinite;}@keyframes rota{0%{transform:rotate(0deg);}100%{transform:rotate(360deg);}}"], props => props.size[0], props => props.size[0], props => props.duration[0], props => props.size[1], props => props.size[1], props => "-".concat(props.size[1] / 2, "px 0 0 -").concat(props.size[1] / 2, "px"), props => props.duration[1]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.48",
|
|
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": "81301da8867ca981dbf7b6d8c422b7aba4e1ca7b",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@arcblock/icons": "^1.14.
|
|
58
|
-
"@arcblock/react-hooks": "^1.14.
|
|
57
|
+
"@arcblock/icons": "^1.14.48",
|
|
58
|
+
"@arcblock/react-hooks": "^1.14.48",
|
|
59
59
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
60
60
|
"@material-ui/core": "^4.10.1",
|
|
61
61
|
"@material-ui/icons": "4.5.1",
|