@arcblock/ux 2.6.9 → 2.7.1
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/babel.config.es.js +12 -0
- package/es/ActionButton/index.js +99 -0
- package/es/ActivityIndicator/index.js +180 -0
- package/es/Address/compact-text.js +105 -0
- package/es/Address/did-address.js +211 -0
- package/es/Address/index.js +23 -0
- package/es/Address/responsive-did-address.js +88 -0
- package/es/Alert/index.js +134 -0
- package/es/AnimationWaiter/default-animation.json +1 -0
- package/es/AnimationWaiter/index.js +239 -0
- package/es/Async/index.js +38 -0
- package/es/Avatar/did-motif.js +64 -0
- package/es/Avatar/etherscan-blockies.js +83 -0
- package/es/Avatar/index.js +176 -0
- package/es/Badge/index.js +98 -0
- package/es/Blocklet/blocklet.js +298 -0
- package/es/Blocklet/index.js +4 -0
- package/es/Blocklet/utils.js +52 -0
- package/es/BlockletNFT/index.js +412 -0
- package/es/Button/index.js +8 -0
- package/es/Button/wrap.js +140 -0
- package/es/ButtonGroup/index.js +6 -0
- package/es/CardSelector/index.js +131 -0
- package/es/Center/index.js +41 -0
- package/es/ClickToCopy/copy-button.js +72 -0
- package/es/ClickToCopy/hook.js +39 -0
- package/es/ClickToCopy/index.js +93 -0
- package/es/CodeBlock/LightBox.js +85 -0
- package/es/CodeBlock/index.js +226 -0
- package/es/Colors/index.js +2 -0
- package/es/Colors/themes/default.js +78 -0
- package/es/ContactForm/index.js +230 -0
- package/es/CookieConsent/index.js +113 -0
- package/es/CountDown/index.js +178 -0
- package/es/DID/index.js +105 -0
- package/es/Datatable/CustomToolbar.js +396 -0
- package/es/Datatable/DatatableContext.js +34 -0
- package/es/Datatable/TableSearch.js +165 -0
- package/es/Datatable/index.js +627 -0
- package/es/Datatable/utils.js +132 -0
- package/es/Dialog/confirm.js +90 -0
- package/es/Dialog/dialog.js +192 -0
- package/es/Dialog/index.js +3 -0
- package/es/DidLogo/index.js +31 -0
- package/es/DriftBot/index.js +70 -0
- package/es/Earth/countries.json +8057 -0
- package/es/Earth/index.js +521 -0
- package/es/Earth/util.js +51 -0
- package/es/Empty/index.js +64 -0
- package/es/ErrorBoundary/fallback.js +73 -0
- package/es/ErrorBoundary/index.js +1 -0
- package/es/Footer/index.js +172 -0
- package/es/Header/auto-hidden.js +35 -0
- package/es/Header/header.js +211 -0
- package/es/Header/index.js +2 -0
- package/es/Header/responsive-header.js +111 -0
- package/es/Icon/image.js +65 -0
- package/es/Icon/index.js +84 -0
- package/es/Img/index.js +217 -0
- package/es/InfoRow/index.js +87 -0
- package/es/Layout/dashboard/external-link.js +58 -0
- package/es/Layout/dashboard/full-page.js +53 -0
- package/es/Layout/dashboard/index.js +275 -0
- package/es/Layout/dashboard/sidebar.js +209 -0
- package/es/Layout/dashboard-legacy/header.js +174 -0
- package/es/Layout/dashboard-legacy/index.js +149 -0
- package/es/Layout/dashboard-legacy/sidebar.js +129 -0
- package/es/Layout/index.js +335 -0
- package/es/Locale/browser-lang.js +52 -0
- package/es/Locale/context.js +114 -0
- package/es/Locale/languages.js +60 -0
- package/es/Locale/selector.js +180 -0
- package/es/Locale/util.js +13 -0
- package/es/Logo/images/logo-dark-text.svg +3 -0
- package/es/Logo/images/logo-dark-top.svg +6 -0
- package/es/Logo/images/logo-light-text.svg +3 -0
- package/es/Logo/images/logo-light-top.svg +6 -0
- package/es/Logo/index.js +136 -0
- package/es/Metric/index.js +132 -0
- package/es/NFTDisplay/README.md +59 -0
- package/es/NFTDisplay/aspect-ratio-container.js +39 -0
- package/es/NFTDisplay/broken.js +18 -0
- package/es/NFTDisplay/demo/data/asset-state-display-url.json +7 -0
- package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-1-1.json +10 -0
- package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-374-130.json +10 -0
- package/es/NFTDisplay/demo/data/asset-state-gzipped-svg-with-foreign-object.json +20 -0
- package/es/NFTDisplay/demo/data/asset-state-svg.json +29 -0
- package/es/NFTDisplay/demo/data/asset-state-url.json +10 -0
- package/es/NFTDisplay/index.js +323 -0
- package/es/NFTDisplay/loading.js +18 -0
- package/es/NFTDisplay/svg-embedder/img.js +45 -0
- package/es/NFTDisplay/svg-embedder/inline-svg.js +39 -0
- package/es/NavMenu/index.js +2 -0
- package/es/NavMenu/nav-menu.js +286 -0
- package/es/NavMenu/style.js +176 -0
- package/es/PageScroller/index.js +286 -0
- package/es/PageScroller/story/FifthComponent.js +9 -0
- package/es/PageScroller/story/FirstComponent.js +9 -0
- package/es/PageScroller/story/FourthComponent.js +12 -0
- package/es/PageScroller/story/FullPage.js +47 -0
- package/es/PageScroller/story/PageContain.js +59 -0
- package/es/PageScroller/story/SecondComponent.js +9 -0
- package/es/PageScroller/story/ThirdComponent.js +9 -0
- package/es/PageScroller/story/index.css +115 -0
- package/es/PageScroller/usePrevValue.js +9 -0
- package/es/PricingTable/PricingPlan.js +124 -0
- package/es/PricingTable/index.js +53 -0
- package/es/QRCode/index.js +72 -0
- package/es/RelativeTime/index.js +98 -0
- package/es/Result/common.js +140 -0
- package/es/Result/demo/fixtures/result-image-404.svg +1 -0
- package/es/Result/index.js +33 -0
- package/es/Result/result.js +59 -0
- package/es/Result/translations.js +54 -0
- package/es/Screenshot/BaseScreenshot/index.js +91 -0
- package/es/Screenshot/BaseScreenshot/shells/Macbook.js +51 -0
- package/es/Screenshot/BaseScreenshot/shells/Phone.js +36 -0
- package/es/Screenshot/demo/images/bg-00.jpg +0 -0
- package/es/Screenshot/demo/images/bg-01.jpg +0 -0
- package/es/Screenshot/demo/images/bg-02.jpg +0 -0
- package/es/Screenshot/demo/images/bg-03.jpg +0 -0
- package/es/Screenshot/demo/images/bg-04.jpg +0 -0
- package/es/Screenshot/demo/images/bg-05.jpg +0 -0
- package/es/Screenshot/demo/images/bg-06.jpg +0 -0
- package/es/Screenshot/demo/images/bg-07.jpg +0 -0
- package/es/Screenshot/demo/images/bg-08.jpg +0 -0
- package/es/Screenshot/demo/images/bg-09.jpg +0 -0
- package/es/Screenshot/devices.css +1366 -0
- package/es/Screenshot/index.js +299 -0
- package/es/SessionManager/federated-login-detecter.js +166 -0
- package/es/SessionManager/index.js +468 -0
- package/es/SessionManager/user-popper.js +132 -0
- package/es/Sparkline/index.js +193 -0
- package/es/Spinner/index.js +28 -0
- package/es/SplitButton/index.js +144 -0
- package/es/Switch/index.js +96 -0
- package/es/Tabs/index.js +48 -0
- package/es/Tag/index.js +108 -0
- package/es/TextCollapse/index.js +92 -0
- package/es/Theme/index.js +16 -0
- package/es/Theme/theme-provider.js +39 -0
- package/es/Theme/theme.js +133 -0
- package/es/Toast/index.js +95 -0
- package/es/Util/deprecate.js +28 -0
- package/es/Util/index.js +298 -0
- package/es/Util/wallet.js +32 -0
- package/es/Video/index.js +89 -0
- package/es/Wallet/Action.js +119 -0
- package/es/Wallet/Download.js +331 -0
- package/es/Wallet/Open.js +45 -0
- package/es/Wallet/images/abtwallet.png +0 -0
- package/es/Wallet/images/android_download.svg +23 -0
- package/es/Wallet/images/app-store.svg +20 -0
- package/es/Wallet/images/google-play.svg +70 -0
- package/es/WebWalletSWKeeper/index.js +115 -0
- package/es/WechatPrompt/images/android.png +0 -0
- package/es/WechatPrompt/images/ios.png +0 -0
- package/es/WechatPrompt/index.js +88 -0
- package/es/index.js +38 -0
- package/es/withTheme/index.js +69 -0
- package/es/withTracker/README.md +34 -0
- package/es/withTracker/error_boundary.js +34 -0
- package/es/withTracker/index.js +56 -0
- package/package.json +272 -5
@@ -0,0 +1,299 @@
|
|
1
|
+
import { createElement, Children, cloneElement, useEffect, useRef, useState } from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { mergeProps } from '../Util';
|
4
|
+
import { styled } from '../Theme';
|
5
|
+
import BaseScreenshot from './BaseScreenshot';
|
6
|
+
import './devices.css';
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
9
|
+
const types = {
|
10
|
+
'iphone-x': {
|
11
|
+
borderRadius: 32,
|
12
|
+
width: 342,
|
13
|
+
scale: 0.78
|
14
|
+
},
|
15
|
+
'iphone-8': {
|
16
|
+
borderRadius: 0,
|
17
|
+
width: 336,
|
18
|
+
scale: 0.78
|
19
|
+
},
|
20
|
+
'ipad-pro': {
|
21
|
+
borderRadius: 0,
|
22
|
+
width: 560,
|
23
|
+
scale: 0.62
|
24
|
+
},
|
25
|
+
'imac-pro': {
|
26
|
+
borderRadius: 0,
|
27
|
+
width: 624,
|
28
|
+
scale: 0.56
|
29
|
+
},
|
30
|
+
macbook: {
|
31
|
+
borderRadius: 0,
|
32
|
+
width: 740,
|
33
|
+
scale: 0.47
|
34
|
+
},
|
35
|
+
'macbook-pro': {
|
36
|
+
borderRadius: 0,
|
37
|
+
width: 740,
|
38
|
+
scale: 0.47
|
39
|
+
},
|
40
|
+
'surface-pro': {
|
41
|
+
borderRadius: 0,
|
42
|
+
width: 561,
|
43
|
+
scale: 0.62
|
44
|
+
},
|
45
|
+
'surface-book': {
|
46
|
+
borderRadius: 0,
|
47
|
+
width: 728,
|
48
|
+
scale: 0.47
|
49
|
+
},
|
50
|
+
'surface-studio': {
|
51
|
+
borderRadius: 0,
|
52
|
+
width: 640,
|
53
|
+
scale: 0.55
|
54
|
+
},
|
55
|
+
'galaxy-s8': {
|
56
|
+
borderRadius: 0,
|
57
|
+
width: 321,
|
58
|
+
scale: 0.8
|
59
|
+
},
|
60
|
+
'google-pixel': {
|
61
|
+
borderRadius: 0,
|
62
|
+
width: 360,
|
63
|
+
scale: 0.72
|
64
|
+
},
|
65
|
+
'google-pixel-2-xl': {
|
66
|
+
borderRadius: 0,
|
67
|
+
width: 360,
|
68
|
+
scale: 0.72
|
69
|
+
},
|
70
|
+
'apple-watch': {
|
71
|
+
borderRadius: 0,
|
72
|
+
width: 200,
|
73
|
+
scale: 1
|
74
|
+
}
|
75
|
+
};
|
76
|
+
const childProps = {
|
77
|
+
img: ['alt', 'title', 'src', 'srcSet', 'sizes', 'loading', 'key', 'children'],
|
78
|
+
video: ['alt', 'title', 'muted', 'autoplay', 'loop', 'key', 'children']
|
79
|
+
};
|
80
|
+
const createChild = child => [/*#__PURE__*/createElement(child.type, childProps[child.type].reduce((acc, x) => {
|
81
|
+
acc[x] = child.props[x];
|
82
|
+
return acc;
|
83
|
+
}, {}))];
|
84
|
+
const findChildren = (children, returnArgWhenNotFound = true) => {
|
85
|
+
for (let i = 0; i < children.length; i++) {
|
86
|
+
const child = children[i];
|
87
|
+
if (['img', 'video'].includes(child.type)) {
|
88
|
+
return createChild(child);
|
89
|
+
}
|
90
|
+
if (child.props && child.props.children) {
|
91
|
+
const subChildren = Children.toArray(child.props.children);
|
92
|
+
const result = findChildren(subChildren, false);
|
93
|
+
if (result) {
|
94
|
+
return result;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
if (returnArgWhenNotFound) {
|
99
|
+
return children;
|
100
|
+
}
|
101
|
+
return null;
|
102
|
+
};
|
103
|
+
|
104
|
+
// This component is built upon the awesome device.css lib
|
105
|
+
// By default it will find and only render img/video tags in the children
|
106
|
+
// If neither of them are found, the whole child tree is rendered
|
107
|
+
function OldScreenshot(props) {
|
108
|
+
const newProps = mergeProps(props, OldScreenshot, ['style', 'width', 'height']);
|
109
|
+
const {
|
110
|
+
type,
|
111
|
+
children,
|
112
|
+
style,
|
113
|
+
className,
|
114
|
+
width,
|
115
|
+
height,
|
116
|
+
...rest
|
117
|
+
} = newProps;
|
118
|
+
const {
|
119
|
+
zIndex = 0,
|
120
|
+
borderRadius = 0
|
121
|
+
} = types[type] || {};
|
122
|
+
return /*#__PURE__*/_jsxs(Div, {
|
123
|
+
...rest,
|
124
|
+
type: type,
|
125
|
+
className: `device device-${type} ${className}`.trim(),
|
126
|
+
style: style,
|
127
|
+
contentRadius: borderRadius,
|
128
|
+
contentZIndex: zIndex,
|
129
|
+
children: [/*#__PURE__*/_jsx("div", {
|
130
|
+
className: "device-frame",
|
131
|
+
children: /*#__PURE__*/_jsx("div", {
|
132
|
+
className: "device-content",
|
133
|
+
children: findChildren(Children.toArray(children)).map((item, index) => /*#__PURE__*/cloneElement(item, {
|
134
|
+
key: index
|
135
|
+
}))
|
136
|
+
})
|
137
|
+
}), /*#__PURE__*/_jsx("div", {
|
138
|
+
className: "device-stripe"
|
139
|
+
}), /*#__PURE__*/_jsx("div", {
|
140
|
+
className: "device-header"
|
141
|
+
}), /*#__PURE__*/_jsx("div", {
|
142
|
+
className: "device-sensors"
|
143
|
+
}), /*#__PURE__*/_jsx("div", {
|
144
|
+
className: "device-btns"
|
145
|
+
}), /*#__PURE__*/_jsx("div", {
|
146
|
+
className: "device-power"
|
147
|
+
})]
|
148
|
+
});
|
149
|
+
}
|
150
|
+
const Div = styled('div')`
|
151
|
+
@media (max-width: ${props => types[props.type].width}px) {
|
152
|
+
transform-origin: 0 0;
|
153
|
+
transform: scale(${props => types[props.type].scale});
|
154
|
+
}
|
155
|
+
.device-content {
|
156
|
+
overflow: hidden;
|
157
|
+
}
|
158
|
+
.device-content video,
|
159
|
+
.device-content img {
|
160
|
+
border-radius: ${props => props.contentRadius}px;
|
161
|
+
background-color: #fff;
|
162
|
+
background-position: center center;
|
163
|
+
background-size: cover;
|
164
|
+
object-fit: cover;
|
165
|
+
width: 100.1%;
|
166
|
+
height: 100.1%;
|
167
|
+
}
|
168
|
+
`;
|
169
|
+
OldScreenshot.propTypes = {
|
170
|
+
type: PropTypes.oneOf(Object.keys(types)),
|
171
|
+
children: PropTypes.any.isRequired,
|
172
|
+
className: PropTypes.string,
|
173
|
+
width: PropTypes.number,
|
174
|
+
height: PropTypes.number,
|
175
|
+
style: PropTypes.oneOfType([PropTypes.object, PropTypes.string])
|
176
|
+
};
|
177
|
+
OldScreenshot.defaultProps = {
|
178
|
+
type: 'iphone-x',
|
179
|
+
className: '',
|
180
|
+
style: '{}',
|
181
|
+
width: 0,
|
182
|
+
height: 0
|
183
|
+
};
|
184
|
+
|
185
|
+
/**
|
186
|
+
* 用于修正旧版 Screenshot 无法匹配尺寸的问题
|
187
|
+
* @param {*} props params to OldScreenshot
|
188
|
+
* @returns <OldScreenshot />
|
189
|
+
*/
|
190
|
+
function ScreenFixer(props) {
|
191
|
+
const screenEl = useRef(null);
|
192
|
+
const [height, setHeight] = useState(undefined);
|
193
|
+
const [scale, setScale] = useState(null);
|
194
|
+
useEffect(() => {
|
195
|
+
let resizeObs;
|
196
|
+
const fixSize = () => {
|
197
|
+
const {
|
198
|
+
clientWidth
|
199
|
+
} = screenEl.current;
|
200
|
+
|
201
|
+
// 获取内部元素的宽高
|
202
|
+
const {
|
203
|
+
clientWidth: targetWidth,
|
204
|
+
clientHeight: targetHeight
|
205
|
+
} = screenEl.current.children[0];
|
206
|
+
const realScale = clientWidth / targetWidth;
|
207
|
+
if (realScale < 1) {
|
208
|
+
setScale(realScale);
|
209
|
+
setHeight(realScale * targetHeight);
|
210
|
+
} else {
|
211
|
+
setScale(null);
|
212
|
+
setHeight(undefined);
|
213
|
+
}
|
214
|
+
};
|
215
|
+
if (screenEl.current) {
|
216
|
+
resizeObs = new ResizeObserver(fixSize);
|
217
|
+
resizeObs.observe(screenEl.current);
|
218
|
+
}
|
219
|
+
return () => {
|
220
|
+
if (resizeObs) {
|
221
|
+
resizeObs.disconnect();
|
222
|
+
}
|
223
|
+
};
|
224
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
225
|
+
}, [screenEl.current]);
|
226
|
+
return /*#__PURE__*/_jsx(ReScreen, {
|
227
|
+
ref: screenEl,
|
228
|
+
style: {
|
229
|
+
height
|
230
|
+
},
|
231
|
+
children: /*#__PURE__*/_jsx(OldScreenshot, {
|
232
|
+
...props,
|
233
|
+
style: {
|
234
|
+
transform: scale ? `scale(${scale})` : undefined
|
235
|
+
}
|
236
|
+
})
|
237
|
+
});
|
238
|
+
}
|
239
|
+
const ReScreen = styled('div')`
|
240
|
+
div[type] {
|
241
|
+
transform: scale(1);
|
242
|
+
transform-origin: 0 0;
|
243
|
+
}
|
244
|
+
`;
|
245
|
+
function Screenshot({
|
246
|
+
type,
|
247
|
+
src,
|
248
|
+
children,
|
249
|
+
style,
|
250
|
+
sx,
|
251
|
+
...rest
|
252
|
+
}) {
|
253
|
+
const _type = type.toLowerCase();
|
254
|
+
|
255
|
+
// 新版采用容器采用BaseScreenshot,svg集成,更容易拓展,响应式更好
|
256
|
+
if (['phone', 'macbook'].includes(_type)) {
|
257
|
+
return /*#__PURE__*/_jsx(BaseScreenshot, {
|
258
|
+
type: _type,
|
259
|
+
sx: {
|
260
|
+
...sx,
|
261
|
+
...style
|
262
|
+
},
|
263
|
+
...rest,
|
264
|
+
children: children || (src ? /*#__PURE__*/_jsx("img", {
|
265
|
+
src: src,
|
266
|
+
alt: "screenshot"
|
267
|
+
}) : null)
|
268
|
+
});
|
269
|
+
}
|
270
|
+
|
271
|
+
// 旧版采用纯css制作,定制性欠缺,暂时保留使用
|
272
|
+
return /*#__PURE__*/_jsx(ScreenFixer, {
|
273
|
+
type: type,
|
274
|
+
...rest,
|
275
|
+
sx: {
|
276
|
+
...sx,
|
277
|
+
...style,
|
278
|
+
margin: 'auto'
|
279
|
+
},
|
280
|
+
children: children || (src ? /*#__PURE__*/_jsx("img", {
|
281
|
+
src: src,
|
282
|
+
alt: "screenshot"
|
283
|
+
}) : null)
|
284
|
+
});
|
285
|
+
}
|
286
|
+
Screenshot.propTypes = {
|
287
|
+
type: PropTypes.string.isRequired,
|
288
|
+
src: PropTypes.string,
|
289
|
+
style: PropTypes.object,
|
290
|
+
sx: PropTypes.object,
|
291
|
+
children: PropTypes.any
|
292
|
+
};
|
293
|
+
Screenshot.defaultProps = {
|
294
|
+
src: '',
|
295
|
+
children: null,
|
296
|
+
style: {},
|
297
|
+
sx: {}
|
298
|
+
};
|
299
|
+
export default Screenshot;
|
@@ -0,0 +1,166 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import { useCallback, useState } from 'react';
|
3
|
+
import Box from '@mui/material/Box';
|
4
|
+
import Chip from '@mui/material/Chip';
|
5
|
+
import Divider from '@mui/material/Divider';
|
6
|
+
import SvgIcon from '@mui/material/SvgIcon';
|
7
|
+
import ShieldCheck from 'mdi-material-ui/ShieldCheck';
|
8
|
+
import UserPopper from './user-popper';
|
9
|
+
import DidAvatar from '../Avatar';
|
10
|
+
import DidAddress from '../Address';
|
11
|
+
import Button from '../Button';
|
12
|
+
import Toast from '../Toast';
|
13
|
+
import { getUserAvatar } from '../Util';
|
14
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
15
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
17
|
+
const translations = {
|
18
|
+
en: {
|
19
|
+
useToConnect({
|
20
|
+
master,
|
21
|
+
member
|
22
|
+
}) {
|
23
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
24
|
+
children: ["Use ", master, " account to connect ", member]
|
25
|
+
});
|
26
|
+
},
|
27
|
+
connect: 'Connect Account',
|
28
|
+
loginFederatedFailed: 'Login federated account failed'
|
29
|
+
},
|
30
|
+
zh: {
|
31
|
+
useToConnect({
|
32
|
+
master,
|
33
|
+
member
|
34
|
+
}) {
|
35
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
36
|
+
children: ["\u4F7F\u7528 ", master, " \u8D26\u53F7\u8FDE\u63A5 ", member]
|
37
|
+
});
|
38
|
+
},
|
39
|
+
connect: '连接账号',
|
40
|
+
loginFederatedFailed: '登录统一登录账号失败'
|
41
|
+
}
|
42
|
+
};
|
43
|
+
export default function FederatedLoginDetecter({
|
44
|
+
session,
|
45
|
+
anchorEl,
|
46
|
+
dark,
|
47
|
+
locale: _locale
|
48
|
+
}) {
|
49
|
+
const [federatedLoginOpen, setFederatedLoginOpen] = useState(true);
|
50
|
+
const siteInfo = session.federatedMaster?.site;
|
51
|
+
const userInfo = session.federatedMaster?.user;
|
52
|
+
const localeList = Object.keys(translations);
|
53
|
+
const locale = localeList.includes(_locale) ? _locale : localeList[0];
|
54
|
+
const onLoginFederated = useCallback(() => {
|
55
|
+
session?.loginFederated(err => {
|
56
|
+
if (err) {
|
57
|
+
Toast.error(err || translations[_locale].loginFederatedFailed);
|
58
|
+
} else {
|
59
|
+
setFederatedLoginOpen(false);
|
60
|
+
}
|
61
|
+
}, {
|
62
|
+
mode: userInfo ? 'auto' : 'manual'
|
63
|
+
});
|
64
|
+
}, [session, userInfo, _locale]);
|
65
|
+
return siteInfo && /*#__PURE__*/_jsx(UserPopper, {
|
66
|
+
open: federatedLoginOpen,
|
67
|
+
anchorEl: anchorEl,
|
68
|
+
dark: dark,
|
69
|
+
onClose: () => setFederatedLoginOpen(false),
|
70
|
+
children: /*#__PURE__*/_jsxs(Box, {
|
71
|
+
p: 2,
|
72
|
+
children: [siteInfo && /*#__PURE__*/_jsxs(Box, {
|
73
|
+
display: "flex",
|
74
|
+
alignItems: "center",
|
75
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
76
|
+
component: "img",
|
77
|
+
mr: 2,
|
78
|
+
src: `${siteInfo.appUrl}${siteInfo.appLogo}`,
|
79
|
+
alt: siteInfo.appName,
|
80
|
+
width: "30px",
|
81
|
+
height: "30px"
|
82
|
+
}), /*#__PURE__*/_jsx(Box, {
|
83
|
+
children: translations[locale].useToConnect({
|
84
|
+
master: /*#__PURE__*/_jsx(Box, {
|
85
|
+
component: "a",
|
86
|
+
href: siteInfo.appUrl,
|
87
|
+
target: "_blank",
|
88
|
+
sx: {
|
89
|
+
textDecoration: 'none',
|
90
|
+
fontWeight: 'bold',
|
91
|
+
color: 'primary.main',
|
92
|
+
fontSize: '1.2em'
|
93
|
+
},
|
94
|
+
children: siteInfo.appName
|
95
|
+
}),
|
96
|
+
member: window.blocklet.appName
|
97
|
+
})
|
98
|
+
})]
|
99
|
+
}), siteInfo && userInfo && /*#__PURE__*/_jsx(Divider, {
|
100
|
+
style: {
|
101
|
+
margin: '15px 0 10px 0'
|
102
|
+
}
|
103
|
+
}), userInfo && /*#__PURE__*/_jsxs(Box, {
|
104
|
+
display: "flex",
|
105
|
+
alignItems: "center",
|
106
|
+
children: [/*#__PURE__*/_jsx(DidAvatar, {
|
107
|
+
variant: "circle",
|
108
|
+
did: userInfo.did,
|
109
|
+
src: getUserAvatar(userInfo.avatar),
|
110
|
+
size: 28,
|
111
|
+
shape: "circle"
|
112
|
+
}), /*#__PURE__*/_jsxs(Box, {
|
113
|
+
ml: 2,
|
114
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
115
|
+
display: "flex",
|
116
|
+
justifyContent: "space-between",
|
117
|
+
alignItems: "center",
|
118
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
119
|
+
fontSize: 18,
|
120
|
+
children: userInfo.fullName
|
121
|
+
}), userInfo.role?.toUpperCase() && /*#__PURE__*/_jsx(Chip, {
|
122
|
+
label: userInfo.role?.toUpperCase(),
|
123
|
+
size: "small",
|
124
|
+
variant: "outlined",
|
125
|
+
sx: {
|
126
|
+
height: 'auto',
|
127
|
+
marginRight: 0,
|
128
|
+
fontSize: 12
|
129
|
+
},
|
130
|
+
icon: /*#__PURE__*/_jsx(SvgIcon, {
|
131
|
+
component: ShieldCheck,
|
132
|
+
style: {
|
133
|
+
fontSize: '14px'
|
134
|
+
}
|
135
|
+
})
|
136
|
+
})]
|
137
|
+
}), /*#__PURE__*/_jsx(DidAddress, {
|
138
|
+
responsive: false,
|
139
|
+
children: userInfo.did
|
140
|
+
})]
|
141
|
+
})]
|
142
|
+
}), siteInfo && /*#__PURE__*/_jsx(Box, {
|
143
|
+
display: "flex",
|
144
|
+
justifyContent: "center",
|
145
|
+
mt: 2,
|
146
|
+
children: /*#__PURE__*/_jsx(Button, {
|
147
|
+
variant: "contained",
|
148
|
+
size: "small",
|
149
|
+
onClick: onLoginFederated,
|
150
|
+
children: translations[locale].connect
|
151
|
+
})
|
152
|
+
})]
|
153
|
+
})
|
154
|
+
});
|
155
|
+
}
|
156
|
+
FederatedLoginDetecter.propTypes = {
|
157
|
+
session: PropTypes.object.isRequired,
|
158
|
+
anchorEl: PropTypes.instanceOf(Element),
|
159
|
+
dark: PropTypes.bool,
|
160
|
+
locale: PropTypes.string
|
161
|
+
};
|
162
|
+
FederatedLoginDetecter.defaultProps = {
|
163
|
+
dark: false,
|
164
|
+
anchorEl: null,
|
165
|
+
locale: 'en'
|
166
|
+
};
|