@arcblock/ux 1.15.27 → 1.15.31
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/CookieConsent/index.js +52 -39
- package/lib/Locale/context.js +12 -1
- package/lib/Locale/selector.js +6 -2
- package/lib/Util/index.js +1 -1
- package/package.json +4 -4
|
@@ -3,83 +3,96 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.UXCookieConsent = UXCookieConsent;
|
|
7
6
|
exports.default = DefaultCookieConsent;
|
|
7
|
+
Object.defineProperty(exports, "resetCookieConsentValue", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _reactCookieConsent.resetCookieConsentValue;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
8
13
|
|
|
9
14
|
var _react = _interopRequireDefault(require("react"));
|
|
10
15
|
|
|
11
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
17
|
|
|
18
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
19
|
+
|
|
13
20
|
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
|
14
21
|
|
|
15
|
-
var _reactCookieConsent =
|
|
22
|
+
var _reactCookieConsent = _interopRequireWildcard(require("react-cookie-consent"));
|
|
16
23
|
|
|
17
|
-
const _excluded = ["
|
|
24
|
+
const _excluded = ["children", "locale", "style"];
|
|
18
25
|
|
|
19
|
-
function
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
27
|
|
|
21
|
-
function
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
29
|
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
31
|
|
|
27
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; }
|
|
28
33
|
|
|
29
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; }
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const translations = {
|
|
37
|
+
en: {
|
|
38
|
+
content: 'We use cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content, to analyze our website traffic, and to understand where our visitors are coming from.',
|
|
39
|
+
agree: 'I Understand'
|
|
40
|
+
},
|
|
41
|
+
zh: {
|
|
42
|
+
content: '我们使用 cookies 和其他跟踪技术来改善您在我们网站上的浏览体验,向您展示个性化的内容,分析我们的网站流量,并了解我们的访问者来自哪里。',
|
|
43
|
+
agree: '我知道了'
|
|
44
|
+
}
|
|
45
|
+
};
|
|
38
46
|
/**
|
|
39
47
|
* DefaultCookieConsent, 对 react-cookie-consent package 封装, 以便 arcblock 内部产品可以快速使用
|
|
40
48
|
* - 默认内容
|
|
41
49
|
* - 默认配置/样式
|
|
42
50
|
*/
|
|
43
51
|
|
|
44
|
-
|
|
45
52
|
function DefaultCookieConsent(_ref) {
|
|
46
53
|
let {
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
children,
|
|
55
|
+
locale,
|
|
56
|
+
style
|
|
49
57
|
} = _ref,
|
|
50
58
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
51
59
|
|
|
52
|
-
|
|
60
|
+
if (locale && !translations[locale]) {
|
|
61
|
+
// eslint-disable-next-line no-param-reassign
|
|
62
|
+
locale = 'en';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement(Wrapper, {
|
|
66
|
+
style: style
|
|
67
|
+
}, /*#__PURE__*/_react.default.createElement(_reactCookieConsent.default, Object.assign({
|
|
68
|
+
disableStyles: true,
|
|
53
69
|
disableButtonStyles: true,
|
|
54
70
|
ButtonComponent: _Button.default,
|
|
71
|
+
buttonText: translations[locale].agree,
|
|
55
72
|
buttonClasses: "MuiButton-contained MuiButton-containedPrimary",
|
|
56
73
|
buttonStyle: {
|
|
57
|
-
|
|
74
|
+
marginTop: 16,
|
|
58
75
|
padding: '6px 16px'
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
alignItems: 'center',
|
|
66
|
-
padding: 16
|
|
67
|
-
}, style)
|
|
68
|
-
}, rest));
|
|
76
|
+
}
|
|
77
|
+
}, rest), children || /*#__PURE__*/_react.default.createElement("p", {
|
|
78
|
+
style: {
|
|
79
|
+
margin: 0
|
|
80
|
+
}
|
|
81
|
+
}, translations[locale].content)));
|
|
69
82
|
}
|
|
70
83
|
|
|
71
84
|
DefaultCookieConsent.propTypes = {
|
|
72
85
|
children: _propTypes.default.any,
|
|
73
86
|
style: _propTypes.default.object,
|
|
74
|
-
|
|
87
|
+
locale: _propTypes.default.string
|
|
75
88
|
};
|
|
76
89
|
DefaultCookieConsent.defaultProps = {
|
|
77
|
-
children:
|
|
78
|
-
style: {
|
|
79
|
-
margin: 0,
|
|
80
|
-
textAlign: 'justify'
|
|
81
|
-
}
|
|
82
|
-
}, "We use cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content, to analyze our website traffic, and to understand where our visitors are coming from."),
|
|
90
|
+
children: null,
|
|
83
91
|
style: {},
|
|
84
|
-
|
|
85
|
-
};
|
|
92
|
+
locale: 'en'
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const Wrapper = _styledComponents.default.div.withConfig({
|
|
96
|
+
displayName: "CookieConsent__Wrapper",
|
|
97
|
+
componentId: "sc-xilwg4-0"
|
|
98
|
+
})(["box-sizing:border-box;position:fixed;right:20px;bottom:20px;z-index:999;max-width:440px;padding:16px 24px;font-size:16px;color:#666;background:#fff;border-radius:6px;box-shadow:0 0 18px rgba(0,0,0,0.2);&:empty{display:none;}button{min-width:200px;}@media screen and (max-width:480px){left:16px;right:16px;bottom:16px;width:auto;button{display:block;width:100%;}}"]);
|
package/lib/Locale/context.js
CHANGED
|
@@ -47,9 +47,20 @@ exports.languages = languages;
|
|
|
47
47
|
const langParams = {
|
|
48
48
|
languages: ['zh', 'en'],
|
|
49
49
|
fallback: 'en'
|
|
50
|
+
}; // 跨应用传递多语言选择的方式是在 query string 中添加 locale 参数,LocaleSelector 要高优先级遵守这个参数
|
|
51
|
+
|
|
52
|
+
const getLocaleFromSearchParams = function getLocaleFromSearchParams() {
|
|
53
|
+
let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location.href;
|
|
54
|
+
const locale = new URL(url).searchParams.get('locale');
|
|
55
|
+
|
|
56
|
+
if (languages.find(x => x.value === locale)) {
|
|
57
|
+
return locale;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return null;
|
|
50
61
|
};
|
|
51
62
|
|
|
52
|
-
const getLocale = locale => locale || _jsCookie.default.get(cookieName) || (0, _browserLang.default)(langParams);
|
|
63
|
+
const getLocale = locale => locale || getLocaleFromSearchParams() || _jsCookie.default.get(cookieName) || (0, _browserLang.default)(langParams);
|
|
53
64
|
|
|
54
65
|
exports.getLocale = getLocale;
|
|
55
66
|
|
package/lib/Locale/selector.js
CHANGED
|
@@ -11,6 +11,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
11
11
|
|
|
12
12
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
13
|
|
|
14
|
+
var _styles = require("@material-ui/core/styles");
|
|
15
|
+
|
|
14
16
|
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
|
15
17
|
|
|
16
18
|
var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
|
|
@@ -27,7 +29,7 @@ var _MenuList = _interopRequireDefault(require("@material-ui/core/MenuList"));
|
|
|
27
29
|
|
|
28
30
|
var _Check = _interopRequireDefault(require("@material-ui/icons/Check"));
|
|
29
31
|
|
|
30
|
-
var _Util = require("
|
|
32
|
+
var _Util = require("../Util");
|
|
31
33
|
|
|
32
34
|
var _context = require("./context");
|
|
33
35
|
|
|
@@ -61,6 +63,7 @@ function LocaleSelector(props) {
|
|
|
61
63
|
} = (0, _react.useContext)(_context.LocaleContext);
|
|
62
64
|
const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
|
|
63
65
|
const [open, setOpen] = (0, _react.useState)(false);
|
|
66
|
+
const theme = (0, _styles.useTheme)();
|
|
64
67
|
|
|
65
68
|
const onSelect = newLocale => {
|
|
66
69
|
changeLocale(newLocale);
|
|
@@ -79,7 +82,8 @@ function LocaleSelector(props) {
|
|
|
79
82
|
const ButtonComponent = showText ? _Button.default : _IconButton.default;
|
|
80
83
|
return /*#__PURE__*/_react.default.createElement(Div, Object.assign({
|
|
81
84
|
component: "div",
|
|
82
|
-
dark: dark
|
|
85
|
+
dark: dark,
|
|
86
|
+
theme: theme
|
|
83
87
|
}, rest), /*#__PURE__*/_react.default.createElement(ButtonComponent, {
|
|
84
88
|
buttonRef: node => setAnchorEl(node),
|
|
85
89
|
className: "trigger",
|
package/lib/Util/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.31",
|
|
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": "7b25d985d20ebe47114e0d9d5b65fd57fc1033d2",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@arcblock/icons": "^1.15.
|
|
58
|
-
"@arcblock/react-hooks": "^1.15.
|
|
57
|
+
"@arcblock/icons": "^1.15.31",
|
|
58
|
+
"@arcblock/react-hooks": "^1.15.31",
|
|
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",
|