@arcblock/ux 2.4.67 → 2.4.69
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 +19 -4
- package/package.json +4 -4
- package/src/CookieConsent/index.js +14 -1
@@ -23,7 +23,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
23
23
|
|
24
24
|
var _templateObject;
|
25
25
|
|
26
|
-
const _excluded = ["children", "locale", "style"];
|
26
|
+
const _excluded = ["children", "locale", "style", "displayInIframe"];
|
27
27
|
|
28
28
|
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); }
|
29
29
|
|
@@ -54,6 +54,14 @@ const translations = {
|
|
54
54
|
}
|
55
55
|
};
|
56
56
|
|
57
|
+
function inIframe() {
|
58
|
+
try {
|
59
|
+
return window.self !== window.top;
|
60
|
+
} catch (e) {
|
61
|
+
return true;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
57
65
|
function AcceptButton(props) {
|
58
66
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, _objectSpread({
|
59
67
|
variant: "contained"
|
@@ -70,10 +78,15 @@ function DefaultCookieConsent(_ref) {
|
|
70
78
|
let {
|
71
79
|
children,
|
72
80
|
locale,
|
73
|
-
style
|
81
|
+
style,
|
82
|
+
displayInIframe
|
74
83
|
} = _ref,
|
75
84
|
rest = _objectWithoutProperties(_ref, _excluded);
|
76
85
|
|
86
|
+
if (!displayInIframe && inIframe()) {
|
87
|
+
return null;
|
88
|
+
}
|
89
|
+
|
77
90
|
if (locale && !translations[locale]) {
|
78
91
|
// eslint-disable-next-line no-param-reassign
|
79
92
|
locale = 'en';
|
@@ -104,11 +117,13 @@ function DefaultCookieConsent(_ref) {
|
|
104
117
|
DefaultCookieConsent.propTypes = {
|
105
118
|
children: _propTypes.default.any,
|
106
119
|
style: _propTypes.default.object,
|
107
|
-
locale: _propTypes.default.string
|
120
|
+
locale: _propTypes.default.string,
|
121
|
+
displayInIframe: _propTypes.default.bool
|
108
122
|
};
|
109
123
|
DefaultCookieConsent.defaultProps = {
|
110
124
|
children: null,
|
111
125
|
style: {},
|
112
|
-
locale: 'en'
|
126
|
+
locale: 'en',
|
127
|
+
displayInIframe: false
|
113
128
|
};
|
114
129
|
const Wrapper = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n box-sizing: border-box;\n position: fixed;\n right: 20px;\n bottom: 20px;\n z-index: 999;\n max-width: 440px;\n padding: 16px 24px;\n font-size: 16px;\n color: #666;\n background: #fff;\n border-radius: 6px;\n box-shadow: 0 0 18px rgba(0, 0, 0, 0.2);\n &:empty {\n display: none;\n }\n button {\n min-width: 200px;\n }\n\n @media screen and (max-width: 480px) {\n left: 16px;\n right: 16px;\n bottom: 16px;\n width: auto;\n button {\n display: block;\n width: 100%;\n }\n }\n"])));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.4.
|
3
|
+
"version": "2.4.69",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -47,11 +47,11 @@
|
|
47
47
|
"react": ">=18.1.0",
|
48
48
|
"react-ga": "^2.7.0"
|
49
49
|
},
|
50
|
-
"gitHead": "
|
50
|
+
"gitHead": "7f35b30f5e0b403bf60030a59619ed27f2492da3",
|
51
51
|
"dependencies": {
|
52
52
|
"@arcblock/did-motif": "^1.1.10",
|
53
|
-
"@arcblock/icons": "^2.4.
|
54
|
-
"@arcblock/react-hooks": "^2.4.
|
53
|
+
"@arcblock/icons": "^2.4.69",
|
54
|
+
"@arcblock/react-hooks": "^2.4.69",
|
55
55
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
56
56
|
"@emotion/react": "^11.10.4",
|
57
57
|
"@emotion/styled": "^11.10.4",
|
@@ -19,6 +19,14 @@ const translations = {
|
|
19
19
|
},
|
20
20
|
};
|
21
21
|
|
22
|
+
function inIframe() {
|
23
|
+
try {
|
24
|
+
return window.self !== window.top;
|
25
|
+
} catch (e) {
|
26
|
+
return true;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
22
30
|
function AcceptButton(props) {
|
23
31
|
return <Button variant="contained" {...props} />;
|
24
32
|
}
|
@@ -28,7 +36,10 @@ function AcceptButton(props) {
|
|
28
36
|
* - 默认内容
|
29
37
|
* - 默认配置/样式
|
30
38
|
*/
|
31
|
-
export default function DefaultCookieConsent({ children, locale, style, ...rest }) {
|
39
|
+
export default function DefaultCookieConsent({ children, locale, style, displayInIframe, ...rest }) {
|
40
|
+
if (!displayInIframe && inIframe()) {
|
41
|
+
return null;
|
42
|
+
}
|
32
43
|
if (locale && !translations[locale]) {
|
33
44
|
// eslint-disable-next-line no-param-reassign
|
34
45
|
locale = 'en';
|
@@ -52,12 +63,14 @@ DefaultCookieConsent.propTypes = {
|
|
52
63
|
children: PropTypes.any,
|
53
64
|
style: PropTypes.object,
|
54
65
|
locale: PropTypes.string,
|
66
|
+
displayInIframe: PropTypes.bool,
|
55
67
|
};
|
56
68
|
|
57
69
|
DefaultCookieConsent.defaultProps = {
|
58
70
|
children: null,
|
59
71
|
style: {},
|
60
72
|
locale: 'en',
|
73
|
+
displayInIframe: false,
|
61
74
|
};
|
62
75
|
|
63
76
|
const Wrapper = styled('div')`
|