@arcblock/ux 2.1.54 → 2.1.57
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/ActivityIndicator/index.js +3 -1
- package/lib/Header/header.js +10 -5
- package/lib/Img/index.js +2 -1
- package/lib/SplitButton/index.js +9 -2
- package/package.json +4 -4
- package/src/ActivityIndicator/index.js +3 -1
- package/src/Header/header.js +5 -2
- package/src/Img/index.js +1 -0
- package/src/SplitButton/index.js +9 -3
|
@@ -34,7 +34,9 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
34
34
|
|
|
35
35
|
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; }
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
/**
|
|
38
|
+
* ActivityIndicator is used when we want to tell the user the request they made on the UI will take time.
|
|
39
|
+
*/
|
|
38
40
|
function ActivityIndicator(_ref) {
|
|
39
41
|
let {
|
|
40
42
|
messages,
|
package/lib/Header/header.js
CHANGED
|
@@ -19,7 +19,7 @@ var _autoHidden = _interopRequireDefault(require("./auto-hidden"));
|
|
|
19
19
|
|
|
20
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
21
|
|
|
22
|
-
const _excluded = ["logo", "brand", "brandAddon", "description", "children", "addons", "prepend"];
|
|
22
|
+
const _excluded = ["logo", "brand", "brandAddon", "description", "children", "addons", "prepend", "align"];
|
|
23
23
|
|
|
24
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
25
|
|
|
@@ -45,7 +45,8 @@ function Header(_ref) {
|
|
|
45
45
|
description,
|
|
46
46
|
children,
|
|
47
47
|
addons,
|
|
48
|
-
prepend
|
|
48
|
+
prepend,
|
|
49
|
+
align
|
|
49
50
|
} = _ref,
|
|
50
51
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
51
52
|
|
|
@@ -80,7 +81,9 @@ function Header(_ref) {
|
|
|
80
81
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
81
82
|
className: "header-brand-addon",
|
|
82
83
|
children: brandAddon
|
|
83
|
-
}),
|
|
84
|
+
}), align === 'right' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
85
|
+
flexGrow: 1
|
|
86
|
+
}), children, align === 'left' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
84
87
|
flexGrow: 1
|
|
85
88
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
86
89
|
className: "header-addons",
|
|
@@ -103,7 +106,8 @@ Header.propTypes = {
|
|
|
103
106
|
// 右侧区域, 可以放置 icons/actions/login 等
|
|
104
107
|
addons: _propTypes.default.node,
|
|
105
108
|
// logo 左侧内容
|
|
106
|
-
prepend: _propTypes.default.node
|
|
109
|
+
prepend: _propTypes.default.node,
|
|
110
|
+
align: _propTypes.default.oneOf(['left', 'right'])
|
|
107
111
|
};
|
|
108
112
|
Header.defaultProps = {
|
|
109
113
|
logo: null,
|
|
@@ -112,7 +116,8 @@ Header.defaultProps = {
|
|
|
112
116
|
description: null,
|
|
113
117
|
children: null,
|
|
114
118
|
addons: null,
|
|
115
|
-
prepend: null
|
|
119
|
+
prepend: null,
|
|
120
|
+
align: 'left'
|
|
116
121
|
};
|
|
117
122
|
|
|
118
123
|
const Root = _styledComponents.default.div.withConfig({
|
package/lib/Img/index.js
CHANGED
package/lib/SplitButton/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
|
|
|
25
25
|
|
|
26
26
|
var _ButtonGroup = _interopRequireDefault(require("@mui/material/ButtonGroup"));
|
|
27
27
|
|
|
28
|
-
var _Button = _interopRequireDefault(require("
|
|
28
|
+
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
|
29
29
|
|
|
30
30
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
31
31
|
|
|
@@ -43,6 +43,9 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
43
43
|
|
|
44
44
|
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; }
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* SplitButton allows the user to execute a default action which is bound to a Button or to choose a predefined action from a drop-down list.
|
|
48
|
+
*/
|
|
46
49
|
function SplitButton(_ref) {
|
|
47
50
|
let {
|
|
48
51
|
size,
|
|
@@ -57,6 +60,10 @@ function SplitButton(_ref) {
|
|
|
57
60
|
|
|
58
61
|
const [open, setOpen] = (0, _react.useState)(false);
|
|
59
62
|
const anchorRef = (0, _react.useRef)(null);
|
|
63
|
+
const menuItems = Array.isArray(menu) ? menu.map((item, index) => /*#__PURE__*/(0, _react.isValidElement)(item) ? item : /*#__PURE__*/(0, _react.createElement)(_MenuItem.default, _objectSpread(_objectSpread({}, item), {}, {
|
|
64
|
+
key: index
|
|
65
|
+
}))) // eslint-disable-line react/no-array-index-key
|
|
66
|
+
: menu;
|
|
60
67
|
|
|
61
68
|
const onToggle = () => {
|
|
62
69
|
setOpen(prevOpen => !prevOpen);
|
|
@@ -105,7 +112,7 @@ function SplitButton(_ref) {
|
|
|
105
112
|
onClickAway: handleClose,
|
|
106
113
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MenuList.default, {
|
|
107
114
|
onClick: handleItemClick,
|
|
108
|
-
children:
|
|
115
|
+
children: menuItems
|
|
109
116
|
})
|
|
110
117
|
})
|
|
111
118
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.57",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"react": ">=18.1.0",
|
|
53
53
|
"react-ga": "^2.7.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "3bf280fd6c092c0cf1649f42f65fc052b7598bbf",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@arcblock/icons": "^2.1.
|
|
58
|
-
"@arcblock/react-hooks": "^2.1.
|
|
57
|
+
"@arcblock/icons": "^2.1.57",
|
|
58
|
+
"@arcblock/react-hooks": "^2.1.57",
|
|
59
59
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
60
60
|
"@emotion/react": "^11.9.0",
|
|
61
61
|
"@emotion/styled": "^11.8.1",
|
|
@@ -6,7 +6,9 @@ import { green, blue } from '@mui/material/colors';
|
|
|
6
6
|
import Logo from '../Logo';
|
|
7
7
|
import colors from '../Colors';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* ActivityIndicator is used when we want to tell the user the request they made on the UI will take time.
|
|
11
|
+
*/
|
|
10
12
|
export default function ActivityIndicator({ messages, interval, ...rest }) {
|
|
11
13
|
const [index, setIndex] = useState(0);
|
|
12
14
|
|
package/src/Header/header.js
CHANGED
|
@@ -9,7 +9,7 @@ import AutoHidden from './auto-hidden';
|
|
|
9
9
|
* Header 组件
|
|
10
10
|
* TODO: Layout/dashboard 可以复用此处的 header
|
|
11
11
|
*/
|
|
12
|
-
function Header({ logo, brand, brandAddon, description, children, addons, prepend, ...rest }) {
|
|
12
|
+
function Header({ logo, brand, brandAddon, description, children, addons, prepend, align, ...rest }) {
|
|
13
13
|
const theme = useTheme();
|
|
14
14
|
return (
|
|
15
15
|
<Root {...rest} $theme={theme}>
|
|
@@ -25,8 +25,9 @@ function Header({ logo, brand, brandAddon, description, children, addons, prepen
|
|
|
25
25
|
</div>
|
|
26
26
|
</AutoHidden>
|
|
27
27
|
<div className="header-brand-addon">{brandAddon}</div>
|
|
28
|
+
{align === 'right' && <Box flexGrow={1} />}
|
|
28
29
|
{children}
|
|
29
|
-
<Box flexGrow={1} />
|
|
30
|
+
{align === 'left' && <Box flexGrow={1} />}
|
|
30
31
|
<div className="header-addons">{addons}</div>
|
|
31
32
|
</Container>
|
|
32
33
|
</Root>
|
|
@@ -47,6 +48,7 @@ Header.propTypes = {
|
|
|
47
48
|
addons: PropTypes.node,
|
|
48
49
|
// logo 左侧内容
|
|
49
50
|
prepend: PropTypes.node,
|
|
51
|
+
align: PropTypes.oneOf(['left', 'right']),
|
|
50
52
|
};
|
|
51
53
|
|
|
52
54
|
Header.defaultProps = {
|
|
@@ -57,6 +59,7 @@ Header.defaultProps = {
|
|
|
57
59
|
children: null,
|
|
58
60
|
addons: null,
|
|
59
61
|
prepend: null,
|
|
62
|
+
align: 'left',
|
|
60
63
|
};
|
|
61
64
|
|
|
62
65
|
const Root = styled.div`
|
package/src/Img/index.js
CHANGED
package/src/SplitButton/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useRef } from 'react';
|
|
1
|
+
import { useState, useRef, isValidElement } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import ExpandMore from '@mui/icons-material/ExpandMore';
|
|
@@ -8,11 +8,17 @@ import ClickAwayListener from '@mui/material/ClickAwayListener';
|
|
|
8
8
|
import MenuList from '@mui/material/MenuList';
|
|
9
9
|
import MenuItem from '@mui/material/MenuItem';
|
|
10
10
|
import ButtonGroup from '@mui/material/ButtonGroup';
|
|
11
|
-
import Button from '
|
|
11
|
+
import Button from '@mui/material/Button';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* SplitButton allows the user to execute a default action which is bound to a Button or to choose a predefined action from a drop-down list.
|
|
15
|
+
*/
|
|
13
16
|
export default function SplitButton({ size, color, menu, children, variant, onClick, menuButtonProps, ...rest }) {
|
|
14
17
|
const [open, setOpen] = useState(false);
|
|
15
18
|
const anchorRef = useRef(null);
|
|
19
|
+
const menuItems = Array.isArray(menu)
|
|
20
|
+
? menu.map((item, index) => (isValidElement(item) ? item : <MenuItem {...item} key={index} />)) // eslint-disable-line react/no-array-index-key
|
|
21
|
+
: menu;
|
|
16
22
|
|
|
17
23
|
const onToggle = () => {
|
|
18
24
|
setOpen((prevOpen) => !prevOpen);
|
|
@@ -49,7 +55,7 @@ export default function SplitButton({ size, color, menu, children, variant, onCl
|
|
|
49
55
|
<StyledPopper open={open} anchorEl={anchorRef.current} placement="bottom-end" disablePortal={false}>
|
|
50
56
|
<Paper>
|
|
51
57
|
<ClickAwayListener onClickAway={handleClose}>
|
|
52
|
-
<MenuList onClick={handleItemClick}>{
|
|
58
|
+
<MenuList onClick={handleItemClick}>{menuItems}</MenuList>
|
|
53
59
|
</ClickAwayListener>
|
|
54
60
|
</Paper>
|
|
55
61
|
</StyledPopper>
|