@blocklet/ui-react 2.9.90 → 2.10.0
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/build.config.ts +1 -6
- package/lib/@types/index.d.ts +1 -0
- package/lib/@types/index.js +0 -1
- package/lib/BlockletStudio/index.js +50 -50
- package/lib/ComponentInstaller/index.js +122 -202
- package/lib/ComponentInstaller/installer-item.js +116 -138
- package/lib/ComponentInstaller/locales.js +5 -10
- package/lib/ComponentInstaller/use-component-installed.js +37 -41
- package/lib/ComponentManager/components/add-component.js +58 -67
- package/lib/ComponentManager/components/check-component.js +2 -9
- package/lib/ComponentManager/components/publish-component.js +50 -59
- package/lib/ComponentManager/components/resource-dialog.js +42 -39
- package/lib/ComponentManager/index.js +3 -27
- package/lib/ComponentManager/libs/locales.js +2 -8
- package/lib/Dashboard/index.js +74 -99
- package/lib/Footer/brand.js +21 -43
- package/lib/Footer/copyright.js +15 -24
- package/lib/Footer/index.js +47 -71
- package/lib/Footer/internal-footer.js +72 -100
- package/lib/Footer/layout/plain.js +26 -45
- package/lib/Footer/layout/row.js +12 -29
- package/lib/Footer/layout/standard.js +34 -64
- package/lib/Footer/links.js +74 -104
- package/lib/Footer/social-media.js +35 -42
- package/lib/Header/index.js +69 -117
- package/lib/Icon/index.js +18 -53
- package/{es/UserCenter/components/notification.d.ts → lib/UserCenter/components/config-profile.d.ts} +1 -1
- package/lib/UserCenter/components/config-profile.js +67 -0
- package/lib/UserCenter/components/notification.js +203 -186
- package/lib/UserCenter/components/passport.js +70 -79
- package/lib/UserCenter/components/privacy.js +86 -88
- package/lib/UserCenter/components/settings.js +74 -84
- package/lib/UserCenter/components/storage/connect-to.js +56 -75
- package/lib/UserCenter/components/storage/connected.js +16 -37
- package/lib/UserCenter/components/storage/delete.js +42 -51
- package/lib/UserCenter/components/storage/disconnect.js +15 -29
- package/lib/UserCenter/components/storage/index.js +20 -54
- package/lib/UserCenter/components/storage/item.js +94 -122
- package/lib/UserCenter/components/storage/preview-nft.js +77 -85
- package/lib/UserCenter/components/third-party-login/index.js +49 -61
- package/lib/UserCenter/components/third-party-login/third-party-item.js +159 -176
- package/lib/UserCenter/components/user-center.js +276 -287
- package/lib/UserCenter/components/user-info/index.js +3 -27
- package/lib/UserCenter/components/user-info/user-basic-info.js +134 -129
- package/lib/UserCenter/components/user-info/user-info-item.js +43 -37
- package/lib/UserCenter/components/user-info/user-info.js +41 -74
- package/lib/UserCenter/components/webhook-item.js +184 -177
- package/lib/UserCenter/index.js +1 -13
- package/lib/UserCenter/libs/api.js +4 -16
- package/lib/UserCenter/libs/locales.d.ts +10 -0
- package/lib/UserCenter/libs/locales.js +12 -8
- package/lib/UserCenter/libs/utils.js +7 -17
- package/lib/UserSessions/components/user-session-info.js +88 -85
- package/lib/UserSessions/components/user-sessions.js +177 -213
- package/lib/UserSessions/index.js +1 -13
- package/lib/UserSessions/libs/locales.js +2 -8
- package/lib/UserSessions/libs/utils.js +4 -11
- package/lib/blocklets.js +59 -63
- package/lib/common/header-addons.js +44 -60
- package/lib/common/link-blocker.js +9 -18
- package/lib/common/overridable-theme-provider.js +10 -23
- package/lib/common/wallet-hidden-topbar.js +7 -14
- package/lib/contexts/config-user-space.js +38 -46
- package/lib/hooks/use-mobile.js +5 -13
- package/lib/index.js +10 -100
- package/lib/libs/client.js +2 -8
- package/lib/libs/spaces.js +6 -13
- package/lib/types.js +39 -41
- package/lib/utils.js +25 -44
- package/package.json +8 -38
- package/src/@types/index.ts +1 -0
- package/src/Footer/brand.jsx +6 -1
- package/src/UserCenter/components/config-profile.tsx +70 -0
- package/src/UserCenter/components/notification.tsx +63 -47
- package/src/UserCenter/components/settings.tsx +6 -0
- package/src/UserCenter/libs/locales.ts +10 -0
- package/es/@types/index.d.ts +0 -101
- package/es/@types/index.js +0 -0
- package/es/@types/shims.d.ts +0 -16
- package/es/BlockletStudio/index.d.ts +0 -28
- package/es/BlockletStudio/index.js +0 -114
- package/es/ComponentInstaller/index.d.ts +0 -37
- package/es/ComponentInstaller/index.js +0 -200
- package/es/ComponentInstaller/installer-item.d.ts +0 -21
- package/es/ComponentInstaller/installer-item.js +0 -139
- package/es/ComponentInstaller/locales.d.ts +0 -28
- package/es/ComponentInstaller/locales.js +0 -22
- package/es/ComponentInstaller/use-component-installed.d.ts +0 -12
- package/es/ComponentInstaller/use-component-installed.js +0 -88
- package/es/ComponentManager/components/add-component.d.ts +0 -16
- package/es/ComponentManager/components/add-component.js +0 -114
- package/es/ComponentManager/components/check-component.d.ts +0 -2
- package/es/ComponentManager/components/check-component.js +0 -2
- package/es/ComponentManager/components/publish-component.d.ts +0 -10
- package/es/ComponentManager/components/publish-component.js +0 -76
- package/es/ComponentManager/components/resource-dialog.d.ts +0 -14
- package/es/ComponentManager/components/resource-dialog.js +0 -74
- package/es/ComponentManager/index.d.ts +0 -3
- package/es/ComponentManager/index.js +0 -3
- package/es/ComponentManager/libs/locales.d.ts +0 -14
- package/es/ComponentManager/libs/locales.js +0 -14
- package/es/Dashboard/index.d.ts +0 -40
- package/es/Dashboard/index.js +0 -118
- package/es/Footer/brand.d.ts +0 -22
- package/es/Footer/brand.js +0 -73
- package/es/Footer/copyright.d.ts +0 -18
- package/es/Footer/copyright.js +0 -25
- package/es/Footer/index.d.ts +0 -6
- package/es/Footer/index.js +0 -82
- package/es/Footer/internal-footer.d.ts +0 -29
- package/es/Footer/internal-footer.js +0 -117
- package/es/Footer/layout/plain.d.ts +0 -15
- package/es/Footer/layout/plain.js +0 -39
- package/es/Footer/layout/row.d.ts +0 -18
- package/es/Footer/layout/row.js +0 -41
- package/es/Footer/layout/standard.d.ts +0 -15
- package/es/Footer/layout/standard.js +0 -53
- package/es/Footer/links.d.ts +0 -22
- package/es/Footer/links.js +0 -207
- package/es/Footer/social-media.d.ts +0 -14
- package/es/Footer/social-media.js +0 -60
- package/es/Header/index.d.ts +0 -10
- package/es/Header/index.js +0 -155
- package/es/Icon/index.d.ts +0 -23
- package/es/Icon/index.js +0 -55
- package/es/UserCenter/assets/banner.png +0 -0
- package/es/UserCenter/components/notification.js +0 -248
- package/es/UserCenter/components/passport.d.ts +0 -6
- package/es/UserCenter/components/passport.js +0 -88
- package/es/UserCenter/components/privacy.d.ts +0 -11
- package/es/UserCenter/components/privacy.js +0 -99
- package/es/UserCenter/components/settings.d.ts +0 -9
- package/es/UserCenter/components/settings.js +0 -89
- package/es/UserCenter/components/storage/connect-to.d.ts +0 -7
- package/es/UserCenter/components/storage/connect-to.js +0 -108
- package/es/UserCenter/components/storage/connected.d.ts +0 -7
- package/es/UserCenter/components/storage/connected.js +0 -24
- package/es/UserCenter/components/storage/delete.d.ts +0 -7
- package/es/UserCenter/components/storage/delete.js +0 -62
- package/es/UserCenter/components/storage/disconnect.d.ts +0 -3
- package/es/UserCenter/components/storage/disconnect.js +0 -23
- package/es/UserCenter/components/storage/icons/empty-spaces-nft.svg +0 -58
- package/es/UserCenter/components/storage/icons/long-arrow.svg +0 -5
- package/es/UserCenter/components/storage/icons/space-connected.svg +0 -3
- package/es/UserCenter/components/storage/icons/space-disconnect.svg +0 -3
- package/es/UserCenter/components/storage/index.d.ts +0 -3
- package/es/UserCenter/components/storage/index.js +0 -27
- package/es/UserCenter/components/storage/item.d.ts +0 -9
- package/es/UserCenter/components/storage/item.js +0 -158
- package/es/UserCenter/components/storage/preview-nft.d.ts +0 -6
- package/es/UserCenter/components/storage/preview-nft.js +0 -80
- package/es/UserCenter/components/third-party-login/index.d.ts +0 -5
- package/es/UserCenter/components/third-party-login/index.js +0 -110
- package/es/UserCenter/components/third-party-login/third-party-item.d.ts +0 -13
- package/es/UserCenter/components/third-party-login/third-party-item.js +0 -224
- package/es/UserCenter/components/user-center.d.ts +0 -15
- package/es/UserCenter/components/user-center.js +0 -414
- package/es/UserCenter/components/user-info/index.d.ts +0 -3
- package/es/UserCenter/components/user-info/index.js +0 -3
- package/es/UserCenter/components/user-info/user-basic-info.d.ts +0 -11
- package/es/UserCenter/components/user-info/user-basic-info.js +0 -151
- package/es/UserCenter/components/user-info/user-info-item.d.ts +0 -11
- package/es/UserCenter/components/user-info/user-info-item.js +0 -47
- package/es/UserCenter/components/user-info/user-info.d.ts +0 -6
- package/es/UserCenter/components/user-info/user-info.js +0 -66
- package/es/UserCenter/components/webhook-item.d.ts +0 -3
- package/es/UserCenter/components/webhook-item.js +0 -243
- package/es/UserCenter/index.d.ts +0 -1
- package/es/UserCenter/index.js +0 -1
- package/es/UserCenter/libs/api.d.ts +0 -3
- package/es/UserCenter/libs/api.js +0 -4
- package/es/UserCenter/libs/locales.d.ts +0 -162
- package/es/UserCenter/libs/locales.js +0 -162
- package/es/UserCenter/libs/utils.d.ts +0 -4
- package/es/UserCenter/libs/utils.js +0 -14
- package/es/UserSessions/components/user-session-info.d.ts +0 -6
- package/es/UserSessions/components/user-session-info.js +0 -92
- package/es/UserSessions/components/user-sessions.d.ts +0 -9
- package/es/UserSessions/components/user-sessions.js +0 -265
- package/es/UserSessions/index.d.ts +0 -1
- package/es/UserSessions/index.js +0 -1
- package/es/UserSessions/libs/locales.d.ts +0 -58
- package/es/UserSessions/libs/locales.js +0 -58
- package/es/UserSessions/libs/utils.d.ts +0 -2
- package/es/UserSessions/libs/utils.js +0 -73
- package/es/blocklets.d.ts +0 -16
- package/es/blocklets.js +0 -178
- package/es/common/header-addons.d.ts +0 -21
- package/es/common/header-addons.js +0 -83
- package/es/common/link-blocker.d.ts +0 -7
- package/es/common/link-blocker.js +0 -18
- package/es/common/overridable-theme-provider.d.ts +0 -18
- package/es/common/overridable-theme-provider.js +0 -15
- package/es/common/wallet-hidden-topbar.d.ts +0 -1
- package/es/common/wallet-hidden-topbar.js +0 -14
- package/es/contexts/config-user-space.d.ts +0 -26
- package/es/contexts/config-user-space.js +0 -53
- package/es/hooks/use-mobile.d.ts +0 -4
- package/es/hooks/use-mobile.js +0 -5
- package/es/index.d.ts +0 -10
- package/es/index.js +0 -10
- package/es/libs/client.d.ts +0 -2
- package/es/libs/client.js +0 -2
- package/es/libs/spaces.d.ts +0 -2
- package/es/libs/spaces.js +0 -13
- package/es/types.d.ts +0 -2
- package/es/types.js +0 -43
- package/es/utils.d.ts +0 -8
- package/es/utils.js +0 -78
package/lib/index.js
CHANGED
|
@@ -1,100 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
ComponentInstaller: true,
|
|
12
|
-
BlockletStudio: true,
|
|
13
|
-
useComponentInstaller: true
|
|
14
|
-
};
|
|
15
|
-
Object.defineProperty(exports, "BlockletStudio", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () {
|
|
18
|
-
return _BlockletStudio.default;
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
Object.defineProperty(exports, "ComponentInstaller", {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _ComponentInstaller.default;
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
Object.defineProperty(exports, "Dashboard", {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: function () {
|
|
30
|
-
return _Dashboard.default;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
Object.defineProperty(exports, "Footer", {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
get: function () {
|
|
36
|
-
return _Footer.default;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
Object.defineProperty(exports, "Header", {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
get: function () {
|
|
42
|
-
return _Header.default;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
Object.defineProperty(exports, "Icon", {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
get: function () {
|
|
48
|
-
return _Icon.default;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
Object.defineProperty(exports, "useComponentInstaller", {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
get: function () {
|
|
54
|
-
return _useComponentInstalled.default;
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
var _Header = _interopRequireDefault(require("./Header"));
|
|
58
|
-
var _Footer = _interopRequireDefault(require("./Footer"));
|
|
59
|
-
var _Dashboard = _interopRequireDefault(require("./Dashboard"));
|
|
60
|
-
var _Icon = _interopRequireDefault(require("./Icon"));
|
|
61
|
-
var _ComponentInstaller = _interopRequireDefault(require("./ComponentInstaller"));
|
|
62
|
-
var _BlockletStudio = _interopRequireDefault(require("./BlockletStudio"));
|
|
63
|
-
var _useComponentInstalled = _interopRequireDefault(require("./ComponentInstaller/use-component-installed"));
|
|
64
|
-
var _UserCenter = require("./UserCenter");
|
|
65
|
-
Object.keys(_UserCenter).forEach(function (key) {
|
|
66
|
-
if (key === "default" || key === "__esModule") return;
|
|
67
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
68
|
-
if (key in exports && exports[key] === _UserCenter[key]) return;
|
|
69
|
-
Object.defineProperty(exports, key, {
|
|
70
|
-
enumerable: true,
|
|
71
|
-
get: function () {
|
|
72
|
-
return _UserCenter[key];
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
var _UserSessions = require("./UserSessions");
|
|
77
|
-
Object.keys(_UserSessions).forEach(function (key) {
|
|
78
|
-
if (key === "default" || key === "__esModule") return;
|
|
79
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
80
|
-
if (key in exports && exports[key] === _UserSessions[key]) return;
|
|
81
|
-
Object.defineProperty(exports, key, {
|
|
82
|
-
enumerable: true,
|
|
83
|
-
get: function () {
|
|
84
|
-
return _UserSessions[key];
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
var _ComponentManager = require("./ComponentManager");
|
|
89
|
-
Object.keys(_ComponentManager).forEach(function (key) {
|
|
90
|
-
if (key === "default" || key === "__esModule") return;
|
|
91
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
92
|
-
if (key in exports && exports[key] === _ComponentManager[key]) return;
|
|
93
|
-
Object.defineProperty(exports, key, {
|
|
94
|
-
enumerable: true,
|
|
95
|
-
get: function () {
|
|
96
|
-
return _ComponentManager[key];
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
export { default as Header } from "./Header/index.js";
|
|
2
|
+
export { default as Footer } from "./Footer/index.js";
|
|
3
|
+
export { default as Dashboard } from "./Dashboard/index.js";
|
|
4
|
+
export { default as Icon } from "./Icon/index.js";
|
|
5
|
+
export { default as ComponentInstaller } from "./ComponentInstaller/index.js";
|
|
6
|
+
export { default as BlockletStudio } from "./BlockletStudio/index.js";
|
|
7
|
+
export { default as useComponentInstaller } from "./ComponentInstaller/use-component-installed.js";
|
|
8
|
+
export * from "./UserCenter/index.js";
|
|
9
|
+
export * from "./UserSessions/index.js";
|
|
10
|
+
export * from "./ComponentManager/index.js";
|
package/lib/libs/client.js
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.client = void 0;
|
|
7
|
-
var _jsSdk = require("@blocklet/js-sdk");
|
|
8
|
-
const client = exports.client = new _jsSdk.BlockletSDK();
|
|
1
|
+
import { BlockletSDK } from "@blocklet/js-sdk";
|
|
2
|
+
export const client = new BlockletSDK();
|
package/lib/libs/spaces.js
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getSpaceHomeUrl = getSpaceHomeUrl;
|
|
7
|
-
exports.getSpaceNftDisplayUrlFromEndpoint = getSpaceNftDisplayUrlFromEndpoint;
|
|
8
|
-
var _ufo = require("ufo");
|
|
9
|
-
function getSpaceNftDisplayUrlFromEndpoint(endpoint) {
|
|
1
|
+
import { joinURL } from "ufo";
|
|
2
|
+
export function getSpaceNftDisplayUrlFromEndpoint(endpoint) {
|
|
10
3
|
const prefix = endpoint.replace(/\/api\/space\/.+/, "");
|
|
11
4
|
const strArray = endpoint.replace(/\/$/, "").split("/");
|
|
12
5
|
const spaceDid = strArray.at(-4);
|
|
13
|
-
return
|
|
6
|
+
return joinURL(prefix, `/api/space/nft/display?spaceDid=${spaceDid}`);
|
|
14
7
|
}
|
|
15
|
-
function getSpaceHomeUrl(endpoint) {
|
|
8
|
+
export function getSpaceHomeUrl(endpoint) {
|
|
16
9
|
const baseUrl = endpoint.replace(/\/api\/space\/.+/, "");
|
|
17
10
|
const strArray = endpoint.replace(/\/$/, "").split("/");
|
|
18
11
|
const spaceDid = strArray.at(-4);
|
|
19
|
-
return
|
|
20
|
-
}
|
|
12
|
+
return joinURL(baseUrl, "space", spaceDid);
|
|
13
|
+
}
|
package/lib/types.js
CHANGED
|
@@ -1,45 +1,43 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SessionManagerProps = exports.BlockletMetaProps = void 0;
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
1
|
/* eslint-disable import/prefer-default-export */
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
10
3
|
|
|
11
|
-
const BlockletMetaProps =
|
|
12
|
-
appLogo:
|
|
13
|
-
appName:
|
|
14
|
-
theme:
|
|
15
|
-
background:
|
|
4
|
+
export const BlockletMetaProps = PropTypes.shape({
|
|
5
|
+
appLogo: PropTypes.node,
|
|
6
|
+
appName: PropTypes.string,
|
|
7
|
+
theme: PropTypes.shape({
|
|
8
|
+
background: PropTypes.string,
|
|
16
9
|
}),
|
|
17
|
-
enableConnect:
|
|
18
|
-
enableLocale:
|
|
19
|
-
navigation:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
enableConnect: PropTypes.bool,
|
|
11
|
+
enableLocale: PropTypes.bool,
|
|
12
|
+
navigation: PropTypes.arrayOf(
|
|
13
|
+
PropTypes.shape({
|
|
14
|
+
title: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
15
|
+
link: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
16
|
+
icon: PropTypes.string,
|
|
17
|
+
items: PropTypes.arrayOf(
|
|
18
|
+
PropTypes.shape({
|
|
19
|
+
title: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
20
|
+
link: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
21
|
+
})
|
|
22
|
+
),
|
|
23
|
+
})
|
|
24
|
+
),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const SessionManagerProps = PropTypes.shape({
|
|
28
|
+
showText: PropTypes.bool,
|
|
29
|
+
showRole: PropTypes.bool,
|
|
30
|
+
switchDid: PropTypes.bool,
|
|
31
|
+
switchProfile: PropTypes.bool,
|
|
32
|
+
switchPassport: PropTypes.bool,
|
|
33
|
+
disableLogout: PropTypes.bool,
|
|
34
|
+
onLogin: PropTypes.func,
|
|
35
|
+
onLogout: PropTypes.func,
|
|
36
|
+
onSwitchDid: PropTypes.func,
|
|
37
|
+
onSwitchProfile: PropTypes.func,
|
|
38
|
+
onSwitchPassport: PropTypes.func,
|
|
39
|
+
menu: PropTypes.array,
|
|
40
|
+
menuRender: PropTypes.func,
|
|
41
|
+
dark: PropTypes.bool,
|
|
42
|
+
size: PropTypes.number,
|
|
28
43
|
});
|
|
29
|
-
const SessionManagerProps = exports.SessionManagerProps = _propTypes.default.shape({
|
|
30
|
-
showText: _propTypes.default.bool,
|
|
31
|
-
showRole: _propTypes.default.bool,
|
|
32
|
-
switchDid: _propTypes.default.bool,
|
|
33
|
-
switchProfile: _propTypes.default.bool,
|
|
34
|
-
switchPassport: _propTypes.default.bool,
|
|
35
|
-
disableLogout: _propTypes.default.bool,
|
|
36
|
-
onLogin: _propTypes.default.func,
|
|
37
|
-
onLogout: _propTypes.default.func,
|
|
38
|
-
onSwitchDid: _propTypes.default.func,
|
|
39
|
-
onSwitchProfile: _propTypes.default.func,
|
|
40
|
-
onSwitchPassport: _propTypes.default.func,
|
|
41
|
-
menu: _propTypes.default.array,
|
|
42
|
-
menuRender: _propTypes.default.func,
|
|
43
|
-
dark: _propTypes.default.bool,
|
|
44
|
-
size: _propTypes.default.number
|
|
45
|
-
});
|
package/lib/utils.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.matchPaths = exports.matchPath = exports.mapRecursive = exports.isUrl = exports.isIconifyString = exports.flatRecursive = exports.filterRecursive = exports.countRecursive = void 0;
|
|
7
|
-
const mapRecursive = (array, fn, childrenKey = 'children') => {
|
|
8
|
-
return array.map(item => {
|
|
1
|
+
export const mapRecursive = (array, fn, childrenKey = 'children') => {
|
|
2
|
+
return array.map((item) => {
|
|
9
3
|
if (Array.isArray(item[childrenKey])) {
|
|
10
4
|
return fn({
|
|
11
5
|
...item,
|
|
12
|
-
[childrenKey]: mapRecursive(item[childrenKey], fn, childrenKey)
|
|
6
|
+
[childrenKey]: mapRecursive(item[childrenKey], fn, childrenKey),
|
|
13
7
|
});
|
|
14
8
|
}
|
|
15
9
|
return fn(item);
|
|
@@ -17,16 +11,14 @@ const mapRecursive = (array, fn, childrenKey = 'children') => {
|
|
|
17
11
|
};
|
|
18
12
|
|
|
19
13
|
// 展平有层级结构的 array
|
|
20
|
-
|
|
21
|
-
const flatRecursive = (array, childrenKey = 'children') => {
|
|
14
|
+
export const flatRecursive = (array, childrenKey = 'children') => {
|
|
22
15
|
const result = [];
|
|
23
|
-
mapRecursive(array, item => result.push(item), childrenKey);
|
|
16
|
+
mapRecursive(array, (item) => result.push(item), childrenKey);
|
|
24
17
|
return result;
|
|
25
18
|
};
|
|
26
19
|
|
|
27
20
|
// 对有层级结构的 array 元素计数
|
|
28
|
-
|
|
29
|
-
const countRecursive = (array, childrenKey = 'children') => {
|
|
21
|
+
export const countRecursive = (array, childrenKey = 'children') => {
|
|
30
22
|
let counter = 0;
|
|
31
23
|
mapRecursive(array, () => counter++, childrenKey);
|
|
32
24
|
return counter;
|
|
@@ -34,43 +26,37 @@ const countRecursive = (array, childrenKey = 'children') => {
|
|
|
34
26
|
|
|
35
27
|
// 对有层级结构的 array 进行 filter 处理
|
|
36
28
|
// 因为是 DFS 遍历, 可以借助 context.filteredChildren 在过滤/保留子结的同时保持父子结构 (即使父结点不满足筛选条件)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
isLeaf: !children?.length
|
|
50
|
-
};
|
|
51
|
-
return predicate(item, context);
|
|
52
|
-
});
|
|
29
|
+
export const filterRecursive = (array, predicate, childrenKey = 'children') => {
|
|
30
|
+
return array
|
|
31
|
+
.map((item) => ({ ...item }))
|
|
32
|
+
.filter((item) => {
|
|
33
|
+
const children = item[childrenKey];
|
|
34
|
+
if (Array.isArray(children)) {
|
|
35
|
+
const filtered = filterRecursive(children, predicate, childrenKey);
|
|
36
|
+
item[childrenKey] = filtered?.length ? filtered : undefined;
|
|
37
|
+
}
|
|
38
|
+
const context = { filteredChildren: item[childrenKey], isLeaf: !children?.length };
|
|
39
|
+
return predicate(item, context);
|
|
40
|
+
});
|
|
53
41
|
};
|
|
54
42
|
|
|
55
43
|
// "http://", "https://" 2 种情况
|
|
56
|
-
|
|
57
|
-
const isUrl = str => {
|
|
44
|
+
export const isUrl = (str) => {
|
|
58
45
|
return /^https?:\/\//.test(str);
|
|
59
46
|
};
|
|
60
|
-
|
|
61
|
-
const isIconifyString = str => {
|
|
47
|
+
|
|
48
|
+
export const isIconifyString = (str) => {
|
|
62
49
|
return /^[\w-]+:[\w-]+$/.test(str);
|
|
63
50
|
};
|
|
64
51
|
|
|
65
52
|
/**
|
|
66
53
|
* 检测 path 是否匹配当前 location, path 只考虑 "/" 开头的相对路径
|
|
67
54
|
*/
|
|
68
|
-
|
|
69
|
-
const matchPath = path => {
|
|
55
|
+
export const matchPath = (path) => {
|
|
70
56
|
if (!path || !path?.startsWith('/')) {
|
|
71
57
|
return false;
|
|
72
58
|
}
|
|
73
|
-
const ensureTrailingSlash = str => str.endsWith('/') ? str : `${str}
|
|
59
|
+
const ensureTrailingSlash = (str) => (str.endsWith('/') ? str : `${str}/`);
|
|
74
60
|
const pathname = ensureTrailingSlash(window.location.pathname);
|
|
75
61
|
const normalizedPath = ensureTrailingSlash(new URL(path, window.location.origin).pathname);
|
|
76
62
|
return pathname.startsWith(normalizedPath);
|
|
@@ -79,12 +65,8 @@ const matchPath = path => {
|
|
|
79
65
|
/**
|
|
80
66
|
* 从一组 paths 中, 找到匹配当前 location 的 path, 返回序号
|
|
81
67
|
*/
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
const matched = paths.map((item, index) => ({
|
|
85
|
-
path: item,
|
|
86
|
-
index
|
|
87
|
-
})).filter(item => matchPath(item.path));
|
|
68
|
+
export const matchPaths = (paths = []) => {
|
|
69
|
+
const matched = paths.map((item, index) => ({ path: item, index })).filter((item) => matchPath(item.path));
|
|
88
70
|
if (!matched?.length) {
|
|
89
71
|
return -1;
|
|
90
72
|
}
|
|
@@ -94,4 +76,3 @@ const matchPaths = (paths = []) => {
|
|
|
94
76
|
}, matched[0]);
|
|
95
77
|
return mostSpecific.index;
|
|
96
78
|
};
|
|
97
|
-
exports.matchPaths = matchPaths;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"homepage": "https://github.com/ArcBlock/ux#readme",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"main": "lib/index.js",
|
|
15
|
-
"module": "
|
|
15
|
+
"module": "lib/index.js",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
18
|
"url": "git+https://github.com/ArcBlock/ux.git"
|
|
@@ -31,45 +31,14 @@
|
|
|
31
31
|
"bugs": {
|
|
32
32
|
"url": "https://github.com/ArcBlock/ux/issues"
|
|
33
33
|
},
|
|
34
|
-
"exports": {
|
|
35
|
-
".": {
|
|
36
|
-
"import": "./es/index.js",
|
|
37
|
-
"require": "./lib/index.js"
|
|
38
|
-
},
|
|
39
|
-
"./lib/*": {
|
|
40
|
-
"import": "./es/*.js",
|
|
41
|
-
"require": "./lib/*.js"
|
|
42
|
-
},
|
|
43
|
-
"./lib/ComponentInstaller": {
|
|
44
|
-
"import": "./es/ComponentInstaller/index.js",
|
|
45
|
-
"require": "./lib/ComponentInstaller/index.js"
|
|
46
|
-
},
|
|
47
|
-
"./lib/Dashboard": {
|
|
48
|
-
"import": "./es/Dashboard/index.js",
|
|
49
|
-
"require": "./lib/Dashboard/index.js"
|
|
50
|
-
},
|
|
51
|
-
"./lib/Footer": {
|
|
52
|
-
"import": "./es/Footer/index.js",
|
|
53
|
-
"require": "./lib/Footer/index.js"
|
|
54
|
-
},
|
|
55
|
-
"./lib/Header": {
|
|
56
|
-
"import": "./es/Header/index.js",
|
|
57
|
-
"require": "./lib/Header/index.js"
|
|
58
|
-
},
|
|
59
|
-
"./lib/Icon": {
|
|
60
|
-
"import": "./es/Icon/index.js",
|
|
61
|
-
"require": "./lib/Icon/index.js"
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
34
|
"dependencies": {
|
|
65
|
-
"@arcblock/bridge": "^2.
|
|
66
|
-
"@arcblock/react-hooks": "^2.
|
|
67
|
-
"@blocklet/js-sdk": "1.16.27-beta-c450492a",
|
|
35
|
+
"@arcblock/bridge": "^2.10.0",
|
|
36
|
+
"@arcblock/react-hooks": "^2.10.0",
|
|
68
37
|
"@iconify-icons/logos": "^1.2.36",
|
|
69
38
|
"@iconify-icons/material-symbols": "^1.2.58",
|
|
70
39
|
"@iconify/react": "^4.1.1",
|
|
71
40
|
"ahooks": "^3.7.10",
|
|
72
|
-
"axios": "^
|
|
41
|
+
"axios": "^1.7.2",
|
|
73
42
|
"clsx": "^2.1.0",
|
|
74
43
|
"core-js": "^3.25.5",
|
|
75
44
|
"iconify-icon": "^1.0.8",
|
|
@@ -82,11 +51,12 @@
|
|
|
82
51
|
"react-error-boundary": "^3.1.4",
|
|
83
52
|
"react-placeholder": "^4.1.0",
|
|
84
53
|
"ua-parser-js": "^1.0.37",
|
|
85
|
-
"ufo": "^1.3
|
|
54
|
+
"ufo": "^1.5.3"
|
|
86
55
|
},
|
|
87
56
|
"peerDependencies": {
|
|
88
57
|
"@arcblock/did-connect": "^2.9.79",
|
|
89
58
|
"@arcblock/ux": "^2.9.79",
|
|
59
|
+
"@blocklet/js-sdk": "^1.16.27",
|
|
90
60
|
"@emotion/react": "^11.10.4",
|
|
91
61
|
"@emotion/styled": "^11.10.4",
|
|
92
62
|
"@mui/icons-material": "^5.15.0",
|
|
@@ -108,5 +78,5 @@
|
|
|
108
78
|
"jest": "^28.1.3",
|
|
109
79
|
"unbuild": "^2.0.0"
|
|
110
80
|
},
|
|
111
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "c4c885cb48490bcae77fb61a04e9d0bb9fbf6abc"
|
|
112
82
|
}
|
package/src/@types/index.ts
CHANGED
package/src/Footer/brand.jsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isValidElement } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { styled } from '@arcblock/ux/lib/Theme';
|
|
4
|
+
import { Box } from '@mui/material';
|
|
4
5
|
|
|
5
6
|
export default function Brand({ name, logo, description, ...rest }) {
|
|
6
7
|
if (!name && !logo && !description) {
|
|
@@ -12,7 +13,11 @@ export default function Brand({ name, logo, description, ...rest }) {
|
|
|
12
13
|
return (
|
|
13
14
|
<Root {...rest}>
|
|
14
15
|
<div>
|
|
15
|
-
{logo &&
|
|
16
|
+
{logo && (
|
|
17
|
+
<Box component="a" href="/" className="footer-brand-logo">
|
|
18
|
+
{logoElement}
|
|
19
|
+
</Box>
|
|
20
|
+
)}
|
|
16
21
|
{name && <div className="footer-brand-name">{name}</div>}
|
|
17
22
|
</div>
|
|
18
23
|
{description && <div className="footer-brand-desc">{description}</div>}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Box, MenuItem, Select, SelectChangeEvent, LinearProgress } from '@mui/material';
|
|
2
|
+
import { useMemoizedFn, useReactive } from 'ahooks';
|
|
3
|
+
import { translate } from '@arcblock/ux/lib/Locale/util';
|
|
4
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
5
|
+
import { sleep } from '@arcblock/ux/lib/Util';
|
|
6
|
+
|
|
7
|
+
import { translations } from '../libs/locales';
|
|
8
|
+
import { client } from '../../libs/client';
|
|
9
|
+
import { User } from '../../@types';
|
|
10
|
+
|
|
11
|
+
// FIXME: @zhanghan 目前仅支持中英文,后续需要支持更多语言(从 blocklet.languages 中获取)
|
|
12
|
+
const languages = [
|
|
13
|
+
{ label: 'English', value: 'en' },
|
|
14
|
+
{ label: '中文', value: 'zh' },
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
export default function ConfigProfile({ user }: { user: User }) {
|
|
18
|
+
const { locale } = useLocaleContext();
|
|
19
|
+
const t = useMemoizedFn((key, data = {}) => {
|
|
20
|
+
return translate(translations, key, locale, 'en', data);
|
|
21
|
+
});
|
|
22
|
+
const currentState = useReactive({
|
|
23
|
+
locale: user.locale,
|
|
24
|
+
loading: false,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const handleChange = useMemoizedFn(async (e: SelectChangeEvent<string>) => {
|
|
28
|
+
try {
|
|
29
|
+
const { value } = e.target;
|
|
30
|
+
currentState.loading = true;
|
|
31
|
+
await Promise.all([
|
|
32
|
+
client.user.saveProfile({
|
|
33
|
+
locale: value,
|
|
34
|
+
}),
|
|
35
|
+
sleep(350),
|
|
36
|
+
]);
|
|
37
|
+
currentState.locale = value;
|
|
38
|
+
} finally {
|
|
39
|
+
currentState.loading = false;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return (
|
|
43
|
+
<Box
|
|
44
|
+
sx={{
|
|
45
|
+
gap: 1,
|
|
46
|
+
display: 'grid',
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
gridTemplateColumns: {
|
|
49
|
+
xs: '1fr',
|
|
50
|
+
sm: 'max-content 1fr',
|
|
51
|
+
},
|
|
52
|
+
}}>
|
|
53
|
+
<Box>{t('commonSetting.locale')}</Box>
|
|
54
|
+
<Box>
|
|
55
|
+
<LinearProgress
|
|
56
|
+
color="primary"
|
|
57
|
+
sx={{
|
|
58
|
+
visibility: currentState.loading ? 'visible' : 'hidden',
|
|
59
|
+
height: 2,
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
62
|
+
<Select fullWidth value={currentState.locale} onChange={handleChange} size="small">
|
|
63
|
+
{languages.map((x) => (
|
|
64
|
+
<MenuItem value={x.value}>{x.label}</MenuItem>
|
|
65
|
+
))}
|
|
66
|
+
</Select>
|
|
67
|
+
</Box>
|
|
68
|
+
</Box>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -18,6 +18,42 @@ import { User, WebhookItemData } from '../../@types';
|
|
|
18
18
|
import { formatAxiosError } from '../libs/utils';
|
|
19
19
|
import { client } from '../../libs/client';
|
|
20
20
|
|
|
21
|
+
function NotificationItem({
|
|
22
|
+
title,
|
|
23
|
+
description,
|
|
24
|
+
value,
|
|
25
|
+
onChange,
|
|
26
|
+
}: {
|
|
27
|
+
title?: string;
|
|
28
|
+
description?: React.ReactNode;
|
|
29
|
+
value: boolean;
|
|
30
|
+
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
31
|
+
}) {
|
|
32
|
+
return (
|
|
33
|
+
<Switch
|
|
34
|
+
checked={value}
|
|
35
|
+
labelProps={{
|
|
36
|
+
label: (
|
|
37
|
+
<Typography
|
|
38
|
+
color="text.primary"
|
|
39
|
+
sx={{
|
|
40
|
+
fontSize: 14,
|
|
41
|
+
display: 'flex',
|
|
42
|
+
flexFlow: 'wrap',
|
|
43
|
+
columnGap: 1,
|
|
44
|
+
flex: 1,
|
|
45
|
+
}}>
|
|
46
|
+
{title}
|
|
47
|
+
{description}
|
|
48
|
+
</Typography>
|
|
49
|
+
),
|
|
50
|
+
}}
|
|
51
|
+
size="small"
|
|
52
|
+
onChange={onChange}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
21
57
|
export default function Notification({ user }: { user: User }) {
|
|
22
58
|
const { locale } = useLocaleContext();
|
|
23
59
|
const t = useMemoizedFn((key, data = {}) => {
|
|
@@ -42,6 +78,7 @@ export default function Notification({ user }: { user: User }) {
|
|
|
42
78
|
wallet: true,
|
|
43
79
|
email: true,
|
|
44
80
|
phone: false,
|
|
81
|
+
push: false,
|
|
45
82
|
...(notificationConfigState?.data?.notifications || {}),
|
|
46
83
|
};
|
|
47
84
|
}, [notificationConfigState?.data?.notifications]);
|
|
@@ -146,57 +183,36 @@ export default function Notification({ user }: { user: User }) {
|
|
|
146
183
|
},
|
|
147
184
|
},
|
|
148
185
|
}}>
|
|
149
|
-
<
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
label: (
|
|
153
|
-
<Typography
|
|
154
|
-
color="text.primary"
|
|
155
|
-
sx={{
|
|
156
|
-
fontSize: 14,
|
|
157
|
-
display: 'flex',
|
|
158
|
-
flexFlow: 'wrap',
|
|
159
|
-
columnGap: 1,
|
|
160
|
-
flex: 1,
|
|
161
|
-
}}>
|
|
162
|
-
{t('walletNotification')}
|
|
163
|
-
{getWalletDid(user) && (
|
|
164
|
-
<Typography component="span" color="text.secondary" fontSize={13}>
|
|
165
|
-
{getWalletDid(user)}
|
|
166
|
-
</Typography>
|
|
167
|
-
)}
|
|
168
|
-
</Typography>
|
|
169
|
-
),
|
|
170
|
-
}}
|
|
171
|
-
size="small"
|
|
186
|
+
<NotificationItem
|
|
187
|
+
value={notifications.wallet}
|
|
188
|
+
title={t('walletNotification')}
|
|
172
189
|
onChange={(event: ChangeEvent<HTMLInputElement>) => handleChangeSwitch('wallet', event.target.checked)}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
label: (
|
|
178
|
-
<Typography
|
|
179
|
-
color="text.primary"
|
|
180
|
-
sx={{
|
|
181
|
-
fontSize: 14,
|
|
182
|
-
display: 'flex',
|
|
183
|
-
flexFlow: 'wrap',
|
|
184
|
-
columnGap: 1,
|
|
185
|
-
flex: 1,
|
|
186
|
-
}}>
|
|
187
|
-
{t('emailNotification')}
|
|
188
|
-
{user?.email && (
|
|
189
|
-
<Typography component="span" color="text.secondary" fontSize={13}>
|
|
190
|
-
{user?.email}
|
|
191
|
-
</Typography>
|
|
192
|
-
)}
|
|
190
|
+
description={
|
|
191
|
+
getWalletDid(user) && (
|
|
192
|
+
<Typography component="span" color="text.secondary" fontSize={13}>
|
|
193
|
+
{getWalletDid(user)}
|
|
193
194
|
</Typography>
|
|
194
|
-
)
|
|
195
|
-
}
|
|
196
|
-
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
/>
|
|
198
|
+
<NotificationItem
|
|
199
|
+
value={notifications.email}
|
|
197
200
|
onChange={(event: ChangeEvent<HTMLInputElement>) => handleChangeSwitch('email', event.target.checked)}
|
|
201
|
+
title={t('emailNotification')}
|
|
202
|
+
description={
|
|
203
|
+
user?.email && (
|
|
204
|
+
<Typography component="span" color="text.secondary" fontSize={13}>
|
|
205
|
+
{user?.email}
|
|
206
|
+
</Typography>
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
/>
|
|
210
|
+
<NotificationItem
|
|
211
|
+
value={notifications.push}
|
|
212
|
+
title={t('pushNotification')}
|
|
213
|
+
onChange={(event: ChangeEvent<HTMLInputElement>) => handleChangeSwitch('push', event.target.checked)}
|
|
198
214
|
/>
|
|
199
|
-
{/* TODO: 实现短信通知后展示此配置项 */}
|
|
215
|
+
{/* TODO: @zhanghan 实现短信通知后展示此配置项 */}
|
|
200
216
|
{/* <Switch
|
|
201
217
|
disabled
|
|
202
218
|
checked={notifications.phone}
|