@arcblock/ux 2.1.32 → 2.1.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/Locale/selector.js +35 -13
- package/lib/NavMenu/nav-menu.js +4 -4
- package/package.json +4 -4
- package/src/Locale/selector.js +36 -5
- package/src/NavMenu/nav-menu.js +2 -4
package/lib/Locale/selector.js
CHANGED
|
@@ -41,7 +41,7 @@ var _globeLight = _interopRequireDefault(require("./images/globe-light.png"));
|
|
|
41
41
|
|
|
42
42
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
43
43
|
|
|
44
|
-
const _excluded = ["dark", "showText", "popperProps"];
|
|
44
|
+
const _excluded = ["dark", "showText", "popperProps", "popperType", "icon"];
|
|
45
45
|
|
|
46
46
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
47
47
|
|
|
@@ -59,7 +59,9 @@ function LocaleSelector(props) {
|
|
|
59
59
|
const {
|
|
60
60
|
dark,
|
|
61
61
|
showText,
|
|
62
|
-
popperProps
|
|
62
|
+
popperProps,
|
|
63
|
+
popperType,
|
|
64
|
+
icon: Icon
|
|
63
65
|
} = props,
|
|
64
66
|
rest = _objectWithoutProperties(props, _excluded);
|
|
65
67
|
|
|
@@ -88,23 +90,39 @@ function LocaleSelector(props) {
|
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
const ButtonComponent = showText ? _Button.default : _IconButton.default;
|
|
91
|
-
|
|
93
|
+
const handleEventProps = popperType === 'hover' ? {
|
|
94
|
+
onMouseEnter: () => {
|
|
95
|
+
setOpen(true);
|
|
96
|
+
},
|
|
97
|
+
onMouseLeave: onClose
|
|
98
|
+
} : {
|
|
99
|
+
onClick: () => {
|
|
100
|
+
setOpen(!open);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const renderIcon = (0, _react.useMemo)(() => {
|
|
104
|
+
if (Icon) {
|
|
105
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
109
|
+
src: dark ? _globeDark.default : _globeLight.default,
|
|
110
|
+
className: "trigger-image",
|
|
111
|
+
alt: "globe"
|
|
112
|
+
});
|
|
113
|
+
}, [Icon, dark]);
|
|
114
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Div, _objectSpread(_objectSpread(_objectSpread({
|
|
92
115
|
component: "div",
|
|
93
116
|
dark: dark,
|
|
94
117
|
theme: theme
|
|
95
|
-
}, rest), {}, {
|
|
118
|
+
}, rest), handleEventProps), {}, {
|
|
96
119
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonComponent, {
|
|
97
120
|
ref: anchorEl,
|
|
98
121
|
className: "trigger",
|
|
99
|
-
onClick: () => setOpen(!open),
|
|
100
122
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
101
123
|
display: "flex",
|
|
102
124
|
alignItems: "center",
|
|
103
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
104
|
-
src: dark ? _globeDark.default : _globeLight.default,
|
|
105
|
-
className: "trigger-image",
|
|
106
|
-
alt: "globe"
|
|
107
|
-
}), showText ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
125
|
+
children: [renderIcon, showText ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
108
126
|
component: "strong",
|
|
109
127
|
className: "trigger-text",
|
|
110
128
|
children: _context.languages.find(x => x.value === locale).text
|
|
@@ -146,14 +164,18 @@ LocaleSelector.propTypes = {
|
|
|
146
164
|
size: _propTypes.default.number,
|
|
147
165
|
showText: _propTypes.default.bool,
|
|
148
166
|
popperProps: _propTypes.default.object,
|
|
149
|
-
onChange: _propTypes.default.func
|
|
167
|
+
onChange: _propTypes.default.func,
|
|
168
|
+
popperType: _propTypes.default.oneOf(['hover', 'click']),
|
|
169
|
+
icon: _propTypes.default.any
|
|
150
170
|
};
|
|
151
171
|
LocaleSelector.defaultProps = {
|
|
152
172
|
dark: false,
|
|
153
173
|
showText: true,
|
|
154
174
|
size: 24,
|
|
155
175
|
popperProps: {},
|
|
156
|
-
onChange: () => {}
|
|
176
|
+
onChange: () => {},
|
|
177
|
+
popperType: 'click',
|
|
178
|
+
icon: null
|
|
157
179
|
};
|
|
158
180
|
var _default = LocaleSelector;
|
|
159
181
|
exports.default = _default;
|
|
@@ -161,4 +183,4 @@ exports.default = _default;
|
|
|
161
183
|
const Div = _styledComponents.default.div.withConfig({
|
|
162
184
|
displayName: "selector__Div",
|
|
163
185
|
componentId: "sc-wfz3sf-0"
|
|
164
|
-
})(["
|
|
186
|
+
})(["display:inline-block;.trigger{display:flex;flex-direction:column;justify-content:center;font-size:14px;.trigger-image{width:", "px;height:", "px;}.trigger-text{margin-left:5px;font-size:14px;color:", ";}}.locales{background:", ";}.locale-item{font-size:16px;font-style:normal;font-stretch:normal;line-height:normal;letter-spacing:2px;text-align:center;color:", ";cursor:pointer;display:flex;padding:16px;align-items:center;.check-icon{visibility:hidden;margin-right:4px;}.check-icon-visible{visibility:visible;}}"], props => props.size, props => props.size, props => (0, _Util.getColor)(props), props => (0, _Util.getBackground)(props), props => (0, _Util.getColor)(props));
|
package/lib/NavMenu/nav-menu.js
CHANGED
|
@@ -104,10 +104,10 @@ function NavMenu(_ref) {
|
|
|
104
104
|
});
|
|
105
105
|
}, [state, mode, activate, open, close]);
|
|
106
106
|
(0, _react.useEffect)(() => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
}, [
|
|
107
|
+
setState(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
108
|
+
activeId
|
|
109
|
+
}));
|
|
110
|
+
}, [activeId]);
|
|
111
111
|
const classes = (0, _clsx.default)('navmenu', "navmenu--".concat(mode), rest.className);
|
|
112
112
|
|
|
113
113
|
const renderItem = (item, index) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.35",
|
|
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": "c414716f6cc96f0e6a376a334b8cc6a5d5dedb6b",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@arcblock/icons": "^2.1.
|
|
58
|
-
"@arcblock/react-hooks": "^2.1.
|
|
57
|
+
"@arcblock/icons": "^2.1.35",
|
|
58
|
+
"@arcblock/react-hooks": "^2.1.35",
|
|
59
59
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
60
60
|
"@emotion/react": "^11.9.0",
|
|
61
61
|
"@emotion/styled": "^11.8.1",
|
package/src/Locale/selector.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react/jsx-no-bind */
|
|
2
|
-
import { useState, useContext, useRef } from 'react';
|
|
2
|
+
import { useState, useContext, useRef, useMemo } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
|
|
@@ -22,7 +22,7 @@ import globeDark from './images/globe-dark.png';
|
|
|
22
22
|
import globeLight from './images/globe-light.png';
|
|
23
23
|
|
|
24
24
|
function LocaleSelector(props) {
|
|
25
|
-
const { dark, showText, popperProps, ...rest } = props;
|
|
25
|
+
const { dark, showText, popperProps, popperType, icon: Icon, ...rest } = props;
|
|
26
26
|
const { locale, changeLocale } = useContext(LocaleContext);
|
|
27
27
|
const anchorEl = useRef(null);
|
|
28
28
|
const [open, setOpen] = useState(false);
|
|
@@ -43,11 +43,34 @@ function LocaleSelector(props) {
|
|
|
43
43
|
|
|
44
44
|
const ButtonComponent = showText ? Button : IconButton;
|
|
45
45
|
|
|
46
|
+
const handleEventProps =
|
|
47
|
+
popperType === 'hover'
|
|
48
|
+
? {
|
|
49
|
+
onMouseEnter: () => {
|
|
50
|
+
setOpen(true);
|
|
51
|
+
},
|
|
52
|
+
onMouseLeave: onClose,
|
|
53
|
+
}
|
|
54
|
+
: {
|
|
55
|
+
onClick: () => {
|
|
56
|
+
setOpen(!open);
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const renderIcon = useMemo(() => {
|
|
61
|
+
if (Icon) {
|
|
62
|
+
return <Icon />;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return <img src={dark ? globeDark : globeLight} className="trigger-image" alt="globe" />;
|
|
66
|
+
}, [Icon, dark]);
|
|
67
|
+
|
|
46
68
|
return (
|
|
47
|
-
<Div component="div" dark={dark} theme={theme} {...rest}>
|
|
48
|
-
<ButtonComponent ref={anchorEl} className="trigger"
|
|
69
|
+
<Div component="div" dark={dark} theme={theme} {...rest} {...handleEventProps}>
|
|
70
|
+
<ButtonComponent ref={anchorEl} className="trigger">
|
|
49
71
|
<Box display="flex" alignItems="center">
|
|
50
|
-
|
|
72
|
+
{renderIcon}
|
|
73
|
+
|
|
51
74
|
{showText ? (
|
|
52
75
|
<Typography component="strong" className="trigger-text">
|
|
53
76
|
{languages.find((x) => x.value === locale).text}
|
|
@@ -57,6 +80,7 @@ function LocaleSelector(props) {
|
|
|
57
80
|
)}
|
|
58
81
|
</Box>
|
|
59
82
|
</ButtonComponent>
|
|
83
|
+
|
|
60
84
|
<Popper open={open} anchorEl={anchorEl.current} {...popperProps} disablePortal>
|
|
61
85
|
<div className="locales">
|
|
62
86
|
<ClickAwayListener onClickAway={onClose}>
|
|
@@ -84,6 +108,8 @@ LocaleSelector.propTypes = {
|
|
|
84
108
|
showText: PropTypes.bool,
|
|
85
109
|
popperProps: PropTypes.object,
|
|
86
110
|
onChange: PropTypes.func,
|
|
111
|
+
popperType: PropTypes.oneOf(['hover', 'click']),
|
|
112
|
+
icon: PropTypes.any,
|
|
87
113
|
};
|
|
88
114
|
|
|
89
115
|
LocaleSelector.defaultProps = {
|
|
@@ -92,20 +118,25 @@ LocaleSelector.defaultProps = {
|
|
|
92
118
|
size: 24,
|
|
93
119
|
popperProps: {},
|
|
94
120
|
onChange: () => {},
|
|
121
|
+
popperType: 'click',
|
|
122
|
+
icon: null,
|
|
95
123
|
};
|
|
96
124
|
|
|
97
125
|
export default LocaleSelector;
|
|
98
126
|
|
|
99
127
|
const Div = styled.div`
|
|
128
|
+
display: inline-block;
|
|
100
129
|
.trigger {
|
|
101
130
|
display: flex;
|
|
102
131
|
flex-direction: column;
|
|
103
132
|
justify-content: center;
|
|
104
133
|
font-size: 14px;
|
|
134
|
+
|
|
105
135
|
.trigger-image {
|
|
106
136
|
width: ${(props) => props.size}px;
|
|
107
137
|
height: ${(props) => props.size}px;
|
|
108
138
|
}
|
|
139
|
+
|
|
109
140
|
.trigger-text {
|
|
110
141
|
margin-left: 5px;
|
|
111
142
|
font-size: 14px;
|
package/src/NavMenu/nav-menu.js
CHANGED
|
@@ -54,10 +54,8 @@ function NavMenu({ items, mode, children, activeId, textColor, activeTextColor,
|
|
|
54
54
|
}, [state, mode, activate, open, close]);
|
|
55
55
|
|
|
56
56
|
useEffect(() => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
}, [activate, activeId]);
|
|
57
|
+
setState((prev) => ({ ...prev, activeId }));
|
|
58
|
+
}, [activeId]);
|
|
61
59
|
|
|
62
60
|
const classes = clsx('navmenu', `navmenu--${mode}`, rest.className);
|
|
63
61
|
const renderItem = (item, index) => {
|