@arcblock/ux 2.13.27 → 2.13.29

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.
Files changed (33) hide show
  1. package/lib/Config/config-provider.d.ts +1 -0
  2. package/lib/DIDConnect/did-connect-container.d.ts +2 -1
  3. package/lib/DIDConnect/did-connect-container.js +4 -2
  4. package/lib/DIDConnect/index.d.ts +1 -0
  5. package/lib/DIDConnect/index.js +2 -1
  6. package/lib/DIDConnect/request-storage-access-api-dialog.d.ts +12 -0
  7. package/lib/DIDConnect/request-storage-access-api-dialog.js +325 -0
  8. package/lib/RelativeTime/index.d.ts +2 -1
  9. package/lib/RelativeTime/index.js +11 -5
  10. package/lib/SessionUser/components/un-login.js +29 -37
  11. package/lib/SharedBridge/index.d.ts +5 -6
  12. package/lib/SharedBridge/index.js +34 -48
  13. package/lib/Tabs/index.js +2 -2
  14. package/lib/Theme/theme-provider.d.ts +5 -2
  15. package/lib/Theme/theme-provider.js +28 -9
  16. package/lib/Theme/theme.d.ts +6 -4
  17. package/lib/Theme/theme.js +15 -9
  18. package/package.json +6 -6
  19. package/src/DIDConnect/did-connect-container.tsx +4 -1
  20. package/src/DIDConnect/index.ts +1 -0
  21. package/src/DIDConnect/request-storage-access-api-dialog.tsx +280 -0
  22. package/src/RelativeTime/index.tsx +25 -4
  23. package/src/SessionUser/components/un-login.tsx +21 -29
  24. package/src/SharedBridge/index.tsx +91 -97
  25. package/src/Tabs/index.tsx +2 -2
  26. package/src/Theme/theme-provider.tsx +36 -10
  27. package/src/Theme/theme.ts +21 -15
  28. package/lib/LoginButton/index.d.ts +0 -12
  29. package/lib/LoginButton/index.js +0 -74
  30. package/lib/SharedBridge/need-storage-access-api-dialog.d.ts +0 -6
  31. package/lib/SharedBridge/need-storage-access-api-dialog.js +0 -191
  32. package/src/LoginButton/index.tsx +0 -73
  33. package/src/SharedBridge/need-storage-access-api-dialog.tsx +0 -149
@@ -1,6 +0,0 @@
1
- import { Locale } from '../type';
2
- export default function NeedStorageAccessApiDialog({ locale, origin, host, }: {
3
- locale?: Locale;
4
- origin: string;
5
- host: string;
6
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,191 +0,0 @@
1
- import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { Box, Typography, Chip, List, ListItem } from '@mui/material';
3
- import { Icon } from '@iconify/react';
4
- import externalLinkIcon from '@iconify-icons/tabler/external-link';
5
- import lockOutlineIcon from '@iconify-icons/material-symbols/lock-outline';
6
- import checkCircleIcon from '@iconify-icons/material-symbols/check-circle';
7
- import rocketLaunchRoundedIcon from '@iconify-icons/material-symbols/rocket-launch-rounded';
8
- import { useMemoizedFn } from 'ahooks';
9
- import { translate } from '../Locale/util';
10
- const translations = {
11
- en: {
12
- allow: 'Allow',
13
- dataUsage: 'Your data is only used for identity authentication, and will not be collected or used for any other purpose.',
14
- title: 'Cross-site authorization request',
15
- clickAllow: ({
16
- allowButton
17
- }) => {
18
- return /*#__PURE__*/_jsxs(_Fragment, {
19
- children: ["You only need to click the ", allowButton, " button above, and you will not see this request again."]
20
- });
21
- },
22
- reason: ({
23
- site
24
- }) => {
25
- return /*#__PURE__*/_jsxs(_Fragment, {
26
- children: ["For a better login experience, we need to apply for the storage permission of the ", site, " site."]
27
- });
28
- },
29
- afterAllow: {
30
- title: 'After authorization, you will enjoy:',
31
- list1: 'More convenient login experience',
32
- list2: 'Faster access speed'
33
- }
34
- },
35
- zh: {
36
- allow: '允许',
37
- dataUsage: '您的数据仅用于身份认证,不会被收集或用于其他用途。',
38
- title: '跨站授权请求',
39
- clickAllow: ({
40
- allowButton
41
- }) => {
42
- return /*#__PURE__*/_jsxs(_Fragment, {
43
- children: ["\u60A8\u53EA\u9700\u8981\u70B9\u51FB\u5C4F\u5E55\u4E0A\u65B9\u7684 ", allowButton, " \u6309\u94AE\uFF0C\u540E\u7EED\u5C06\u4E0D\u4F1A\u518D\u770B\u5230\u8FD9\u4E2A\u8BF7\u6C42\u3002"]
44
- });
45
- },
46
- reason: ({
47
- site
48
- }) => {
49
- return /*#__PURE__*/_jsxs(_Fragment, {
50
- children: ["\u4E3A\u4E86\u8BA9\u60A8\u83B7\u5F97\u66F4\u597D\u7684\u767B\u5F55\u4F53\u9A8C\uFF0C\u6211\u4EEC\u9700\u8981\u7533\u8BF7 ", site, " \u7AD9\u70B9\u5B58\u50A8\u6743\u9650\u3002"]
51
- });
52
- },
53
- afterAllow: {
54
- title: '授权后,您将享受:',
55
- list1: '更便捷的登录体验',
56
- list2: '更快的访问速度'
57
- }
58
- }
59
- };
60
- export default function NeedStorageAccessApiDialog({
61
- locale = 'en',
62
- origin,
63
- host
64
- }) {
65
- const t = useMemoizedFn((key, data = {}) => {
66
- return translate(translations, key, locale, 'en', data);
67
- });
68
- return /*#__PURE__*/_jsxs(Box, {
69
- sx: {
70
- backgroundColor: 'background.default',
71
- display: 'flex',
72
- flexDirection: 'column',
73
- height: '100%',
74
- position: 'relative',
75
- maxWidth: '100%',
76
- transition: 'width 0.2s ease-in-out',
77
- margin: 'auto',
78
- p: 3,
79
- gap: 2
80
- },
81
- children: [/*#__PURE__*/_jsxs(Typography, {
82
- component: "h1",
83
- variant: "h4",
84
- sx: {
85
- fontWeight: 700,
86
- fontFamily: 'Lexend',
87
- display: 'flex',
88
- alignItems: 'center',
89
- gap: 1
90
- },
91
- children: [/*#__PURE__*/_jsx(Box, {
92
- component: Icon,
93
- icon: lockOutlineIcon,
94
- fontSize: 28,
95
- sx: {
96
- color: 'warning.main'
97
- }
98
- }), t('title')]
99
- }), /*#__PURE__*/_jsxs(Box, {
100
- sx: {
101
- display: 'flex',
102
- flexDirection: 'column',
103
- gap: 1
104
- },
105
- children: [/*#__PURE__*/_jsx(Typography, {
106
- children: t('reason', {
107
- site: /*#__PURE__*/_jsx(Chip, {
108
- clickable: true,
109
- component: "a",
110
- href: origin,
111
- label: host,
112
- size: "small",
113
- deleteIcon: /*#__PURE__*/_jsx(Icon, {
114
- icon: externalLinkIcon
115
- }),
116
- onDelete: () => {},
117
- target: "_blank"
118
- })
119
- })
120
- }), /*#__PURE__*/_jsx(Typography, {
121
- children: t('clickAllow', {
122
- allowButton: /*#__PURE__*/_jsx(Chip, {
123
- label: t('allow'),
124
- size: "small",
125
- color: "success"
126
- })
127
- })
128
- }), /*#__PURE__*/_jsxs(Box, {
129
- sx: {
130
- mt: 2
131
- },
132
- children: [/*#__PURE__*/_jsxs(Typography, {
133
- sx: {
134
- display: 'flex',
135
- alignItems: 'center',
136
- gap: 1,
137
- mb: 0.5
138
- },
139
- children: [/*#__PURE__*/_jsx(Box, {
140
- component: Icon,
141
- icon: checkCircleIcon,
142
- fontSize: 24,
143
- sx: {
144
- color: 'success.main'
145
- }
146
- }), t('afterAllow.title')]
147
- }), /*#__PURE__*/_jsxs(List, {
148
- dense: true,
149
- sx: {
150
- py: 0,
151
- pl: 2
152
- },
153
- children: [/*#__PURE__*/_jsxs(ListItem, {
154
- sx: {
155
- display: 'flex',
156
- alignItems: 'center',
157
- gap: 0.8
158
- },
159
- children: [/*#__PURE__*/_jsx(Box, {
160
- component: Icon,
161
- icon: rocketLaunchRoundedIcon,
162
- fontSize: 20,
163
- sx: {
164
- color: 'success.main'
165
- }
166
- }), t('afterAllow.list1')]
167
- }), /*#__PURE__*/_jsxs(ListItem, {
168
- sx: {
169
- display: 'flex',
170
- alignItems: 'center',
171
- gap: 0.8
172
- },
173
- children: [/*#__PURE__*/_jsx(Box, {
174
- component: Icon,
175
- icon: rocketLaunchRoundedIcon,
176
- fontSize: 20,
177
- sx: {
178
- color: 'success.main'
179
- }
180
- }), t('afterAllow.list2')]
181
- })]
182
- })]
183
- }), /*#__PURE__*/_jsx(Typography, {
184
- component: "div",
185
- variant: "body2",
186
- color: "grey.700",
187
- children: t('dataUsage')
188
- })]
189
- })]
190
- });
191
- }
@@ -1,73 +0,0 @@
1
- import { Box } from '@mui/material';
2
- import { joinURL } from 'ufo';
3
- import { useRef, useState } from 'react';
4
- import { useMemoizedFn } from 'ahooks';
5
- import { useBrowser } from '@arcblock/react-hooks';
6
-
7
- import SharedBridge from '../SharedBridge';
8
- import { setVisitorId } from '../Util';
9
- import { getFederatedEnabled, getMaster } from '../Util/federated';
10
- import { callIframe } from '../Util/iframe';
11
- import { Locale } from '../type';
12
-
13
- type LoginButtonProps = {
14
- onClick: (options?: { openMode?: 'popup' | 'window' }) => void;
15
- render: (options: { onClick: () => void }) => React.ReactNode;
16
- locale?: Locale;
17
- };
18
-
19
- export default function LoginButton({ onClick, render, locale }: LoginButtonProps) {
20
- const blocklet = window?.blocklet;
21
- const federatedEnabled = getFederatedEnabled(blocklet);
22
- const masterSite = getMaster(blocklet);
23
- const sharedBridgeRef = useRef<HTMLIFrameElement>(null);
24
- const [hasStorageAccess, setHasStorageAccess] = useState(false);
25
- const browser = useBrowser();
26
-
27
- const handleClick = useMemoizedFn(() => {
28
- if (hasStorageAccess) {
29
- onClick({ openMode: 'popup' });
30
- } else {
31
- onClick();
32
- }
33
- });
34
- const handleLoad = useMemoizedFn(async () => {
35
- const { value: visitorId } = await callIframe(sharedBridgeRef.current as HTMLIFrameElement, 'getVisitorId');
36
- if (visitorId) {
37
- setHasStorageAccess(true);
38
- setVisitorId(visitorId);
39
- }
40
- });
41
- const handleClickBridge = useMemoizedFn(({ value, visitorId }) => {
42
- if (visitorId) {
43
- setVisitorId(visitorId);
44
- }
45
- if (value) {
46
- onClick({ openMode: 'popup' });
47
- } else {
48
- onClick();
49
- }
50
- });
51
-
52
- if (browser.arcSphere || browser.wallet) {
53
- return render({ onClick });
54
- }
55
-
56
- return (
57
- <Box
58
- sx={{
59
- position: 'relative',
60
- }}>
61
- {render({ onClick: handleClick })}
62
- {masterSite?.appUrl && federatedEnabled ? (
63
- <SharedBridge
64
- locale={locale}
65
- iframeRef={sharedBridgeRef}
66
- onLoad={handleLoad}
67
- onClick={handleClickBridge}
68
- src={joinURL(masterSite.appUrl, '/.well-known/service/share/shared-bridge.html')}
69
- />
70
- ) : null}
71
- </Box>
72
- );
73
- }
@@ -1,149 +0,0 @@
1
- import { Box, Typography, Chip, List, ListItem } from '@mui/material';
2
- import { Icon } from '@iconify/react';
3
- import externalLinkIcon from '@iconify-icons/tabler/external-link';
4
- import lockOutlineIcon from '@iconify-icons/material-symbols/lock-outline';
5
- import checkCircleIcon from '@iconify-icons/material-symbols/check-circle';
6
- import rocketLaunchRoundedIcon from '@iconify-icons/material-symbols/rocket-launch-rounded';
7
- import { useMemoizedFn } from 'ahooks';
8
-
9
- import { Locale } from '../type';
10
- import { translate } from '../Locale/util';
11
- import { DIDConnectFooter } from '../DIDConnect';
12
-
13
- const translations: Record<
14
- Locale,
15
- {
16
- allow: string;
17
- dataUsage: string;
18
- title: string;
19
- clickAllow: ({ allowButton }: { allowButton: React.ReactNode }) => React.ReactNode;
20
- reason: ({ site }: { site: React.ReactNode }) => React.ReactNode;
21
- afterAllow: {
22
- title: string;
23
- list1: string;
24
- list2: string;
25
- };
26
- }
27
- > = {
28
- en: {
29
- allow: 'Allow',
30
- dataUsage:
31
- 'Your data is only used for identity authentication, and will not be collected or used for any other purpose.',
32
- title: 'Cross-site authorization request',
33
- clickAllow: ({ allowButton }: { allowButton: React.ReactNode }) => {
34
- return <>You only need to click the {allowButton} button above, and you will not see this request again.</>;
35
- },
36
- reason: ({ site }) => {
37
- return <>For a better login experience, we need to apply for the storage permission of the {site} site.</>;
38
- },
39
- afterAllow: {
40
- title: 'After authorization, you will enjoy:',
41
- list1: 'More convenient login experience',
42
- list2: 'Faster access speed',
43
- },
44
- },
45
- zh: {
46
- allow: '允许',
47
- dataUsage: '您的数据仅用于身份认证,不会被收集或用于其他用途。',
48
- title: '跨站授权请求',
49
- clickAllow: ({ allowButton }) => {
50
- return <>您只需要点击屏幕上方的 {allowButton} 按钮,后续将不会再看到这个请求。</>;
51
- },
52
- reason: ({ site }) => {
53
- return <>为了让您获得更好的登录体验,我们需要申请 {site} 站点存储权限。</>;
54
- },
55
- afterAllow: {
56
- title: '授权后,您将享受:',
57
- list1: '更便捷的登录体验',
58
- list2: '更快的访问速度',
59
- },
60
- },
61
- };
62
-
63
- export default function NeedStorageAccessApiDialog({
64
- locale = 'en',
65
- origin,
66
- host,
67
- }: {
68
- locale?: Locale;
69
- origin: string;
70
- host: string;
71
- }) {
72
- const t = useMemoizedFn((key, data = {}) => {
73
- return translate(translations, key, locale, 'en', data);
74
- });
75
-
76
- return (
77
- <Box
78
- sx={{
79
- backgroundColor: 'background.default',
80
- display: 'flex',
81
- flexDirection: 'column',
82
- height: '100%',
83
- position: 'relative',
84
- maxWidth: '100%',
85
- transition: 'width 0.2s ease-in-out',
86
- margin: 'auto',
87
- p: 3,
88
- gap: 2,
89
- }}>
90
- <Typography
91
- component="h1"
92
- variant="h4"
93
- sx={{
94
- fontWeight: 700,
95
- fontFamily: 'Lexend',
96
- display: 'flex',
97
- alignItems: 'center',
98
- gap: 1,
99
- }}>
100
- <Box component={Icon} icon={lockOutlineIcon} fontSize={28} sx={{ color: 'warning.main' }} />
101
- {t('title')}
102
- </Typography>
103
- <Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
104
- {/* 不需要随意更改以下内容的格式化,否则会影响到 UI 的展示 */}
105
- <Typography>
106
- {t('reason', {
107
- site: (
108
- <Chip
109
- clickable
110
- component="a"
111
- href={origin}
112
- label={host}
113
- size="small"
114
- deleteIcon={<Icon icon={externalLinkIcon} />}
115
- onDelete={() => {}}
116
- target="_blank"
117
- />
118
- ),
119
- })}
120
- </Typography>
121
- <Typography>
122
- {t('clickAllow', {
123
- allowButton: <Chip label={t('allow')} size="small" color="success" />,
124
- })}
125
- </Typography>
126
- <Box sx={{ mt: 2 }}>
127
- <Typography sx={{ display: 'flex', alignItems: 'center', gap: 1, mb: 0.5 }}>
128
- <Box component={Icon} icon={checkCircleIcon} fontSize={24} sx={{ color: 'success.main' }} />
129
- {t('afterAllow.title')}
130
- </Typography>
131
- <List dense sx={{ py: 0, pl: 2 }}>
132
- <ListItem sx={{ display: 'flex', alignItems: 'center', gap: 0.8 }}>
133
- <Box component={Icon} icon={rocketLaunchRoundedIcon} fontSize={20} sx={{ color: 'success.main' }} />
134
- {t('afterAllow.list1')}
135
- </ListItem>
136
- <ListItem sx={{ display: 'flex', alignItems: 'center', gap: 0.8 }}>
137
- <Box component={Icon} icon={rocketLaunchRoundedIcon} fontSize={20} sx={{ color: 'success.main' }} />
138
- {t('afterAllow.list2')}
139
- </ListItem>
140
- </List>
141
- </Box>
142
-
143
- <Typography component="div" variant="body2" color="grey.700">
144
- {t('dataUsage')}
145
- </Typography>
146
- </Box>
147
- </Box>
148
- );
149
- }