@blocklet/ui-react 2.9.13 → 2.9.14
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 +29 -0
- package/es/@types/index.d.ts +63 -0
- package/es/@types/index.js +0 -0
- package/es/@types/shims.d.ts +12 -0
- package/es/Dashboard/index.d.ts +41 -0
- package/es/Dashboard/index.js +63 -97
- package/es/Footer/brand.d.ts +22 -0
- package/es/Footer/brand.js +20 -37
- package/es/Footer/copyright.d.ts +18 -0
- package/es/Footer/copyright.js +14 -16
- package/es/Footer/index.d.ts +6 -0
- package/es/Footer/index.js +30 -56
- package/es/Footer/internal-footer.d.ts +29 -0
- package/es/Footer/internal-footer.js +67 -94
- package/es/Footer/layout/plain.d.ts +15 -0
- package/es/Footer/layout/plain.js +19 -37
- package/es/Footer/layout/row.d.ts +18 -0
- package/es/Footer/layout/row.js +9 -19
- package/es/Footer/layout/standard.d.ts +15 -0
- package/es/Footer/layout/standard.js +29 -57
- package/es/Footer/links.d.ts +22 -0
- package/es/Footer/links.js +72 -104
- package/es/Footer/social-media.d.ts +14 -0
- package/es/Footer/social-media.js +35 -35
- package/es/Header/index.d.ts +9 -0
- package/es/Header/index.js +55 -100
- package/es/Icon/index.d.ts +23 -0
- package/es/Icon/index.js +23 -58
- package/es/UserCenter/assets/banner.png +0 -0
- package/es/UserCenter/components/notification.d.ts +5 -0
- package/es/UserCenter/components/notification.js +276 -0
- package/es/UserCenter/components/passport.d.ts +6 -0
- package/es/UserCenter/components/passport.js +69 -0
- package/es/UserCenter/components/privacy.d.ts +11 -0
- package/es/UserCenter/components/privacy.js +99 -0
- package/es/UserCenter/components/settings.d.ts +10 -0
- package/es/UserCenter/components/settings.js +68 -0
- package/es/UserCenter/components/user-basic-info.d.ts +8 -0
- package/es/UserCenter/components/user-basic-info.js +66 -0
- package/es/UserCenter/components/user-center.d.ts +9 -0
- package/es/UserCenter/components/user-center.js +397 -0
- package/es/UserCenter/components/user-info-item.d.ts +10 -0
- package/es/UserCenter/components/user-info-item.js +54 -0
- package/es/UserCenter/components/user-info.d.ts +6 -0
- package/es/UserCenter/components/user-info.js +68 -0
- package/es/UserCenter/components/webhook-item.d.ts +3 -0
- package/es/UserCenter/components/webhook-item.js +243 -0
- package/es/UserCenter/index.d.ts +1 -0
- package/es/UserCenter/index.js +1 -0
- package/es/UserCenter/libs/client.d.ts +2 -0
- package/es/UserCenter/libs/client.js +2 -0
- package/es/UserCenter/libs/locales.d.ts +72 -0
- package/es/UserCenter/libs/locales.js +72 -0
- package/es/UserCenter/libs/utils.d.ts +4 -0
- package/es/UserCenter/libs/utils.js +14 -0
- package/es/blocklets.d.ts +16 -0
- package/es/blocklets.js +56 -45
- package/es/common/header-addons.d.ts +22 -0
- package/es/common/header-addons.js +41 -59
- package/es/common/link-blocker.d.ts +7 -0
- package/es/common/link-blocker.js +10 -17
- package/es/common/overridable-theme-provider.d.ts +18 -0
- package/es/common/overridable-theme-provider.js +6 -16
- package/es/common/wallet-hidden-topbar.d.ts +1 -0
- package/es/common/wallet-hidden-topbar.js +12 -10
- package/es/index.d.ts +5 -0
- package/es/index.js +5 -0
- package/es/types.d.ts +2 -0
- package/es/types.js +17 -11
- package/es/utils.d.ts +8 -0
- package/es/utils.js +21 -26
- package/lib/@types/index.d.ts +63 -0
- package/lib/@types/index.js +1 -0
- package/lib/@types/shims.d.ts +12 -0
- package/lib/Dashboard/index.d.ts +41 -0
- package/lib/Dashboard/index.js +44 -71
- package/lib/Footer/brand.d.ts +22 -0
- package/lib/Footer/brand.js +65 -30
- package/lib/Footer/copyright.d.ts +18 -0
- package/lib/Footer/copyright.js +18 -23
- package/lib/Footer/index.d.ts +6 -0
- package/lib/Footer/index.js +33 -42
- package/lib/Footer/internal-footer.d.ts +29 -0
- package/lib/Footer/internal-footer.js +43 -59
- package/lib/Footer/layout/plain.d.ts +15 -0
- package/lib/Footer/layout/plain.js +25 -30
- package/lib/Footer/layout/row.d.ts +18 -0
- package/lib/Footer/layout/row.js +34 -23
- package/lib/Footer/layout/standard.d.ts +15 -0
- package/lib/Footer/layout/standard.js +35 -41
- package/lib/Footer/links.d.ts +22 -0
- package/lib/Footer/links.js +163 -60
- package/lib/Footer/social-media.d.ts +14 -0
- package/lib/Footer/social-media.js +31 -25
- package/lib/Header/index.d.ts +9 -0
- package/lib/Header/index.js +83 -76
- package/lib/Icon/index.d.ts +23 -0
- package/lib/Icon/index.js +37 -51
- package/lib/UserCenter/assets/banner.png +0 -0
- package/lib/UserCenter/components/notification.d.ts +5 -0
- package/lib/UserCenter/components/notification.js +261 -0
- package/lib/UserCenter/components/passport.d.ts +6 -0
- package/lib/UserCenter/components/passport.js +86 -0
- package/lib/UserCenter/components/privacy.d.ts +11 -0
- package/lib/UserCenter/components/privacy.js +101 -0
- package/lib/UserCenter/components/settings.d.ts +10 -0
- package/lib/UserCenter/components/settings.js +81 -0
- package/lib/UserCenter/components/user-basic-info.d.ts +8 -0
- package/lib/UserCenter/components/user-basic-info.js +67 -0
- package/lib/UserCenter/components/user-center.d.ts +9 -0
- package/lib/UserCenter/components/user-center.js +376 -0
- package/lib/UserCenter/components/user-info-item.d.ts +10 -0
- package/lib/UserCenter/components/user-info-item.js +46 -0
- package/lib/UserCenter/components/user-info.d.ts +6 -0
- package/lib/UserCenter/components/user-info.js +94 -0
- package/lib/UserCenter/components/webhook-item.d.ts +3 -0
- package/lib/UserCenter/components/webhook-item.js +236 -0
- package/lib/UserCenter/index.d.ts +1 -0
- package/lib/UserCenter/index.js +13 -0
- package/lib/UserCenter/libs/client.d.ts +2 -0
- package/lib/UserCenter/libs/client.js +8 -0
- package/lib/UserCenter/libs/locales.d.ts +72 -0
- package/lib/UserCenter/libs/locales.js +78 -0
- package/lib/UserCenter/libs/utils.d.ts +4 -0
- package/lib/UserCenter/libs/utils.js +25 -0
- package/lib/blocklets.d.ts +16 -0
- package/lib/blocklets.js +28 -36
- package/lib/common/header-addons.d.ts +22 -0
- package/lib/common/header-addons.js +24 -36
- package/lib/common/link-blocker.d.ts +7 -0
- package/lib/common/link-blocker.js +10 -18
- package/lib/common/overridable-theme-provider.d.ts +18 -0
- package/lib/common/overridable-theme-provider.js +9 -14
- package/lib/common/wallet-hidden-topbar.d.ts +1 -0
- package/lib/common/wallet-hidden-topbar.js +1 -3
- package/lib/index.d.ts +5 -0
- package/lib/index.js +52 -0
- package/lib/types.d.ts +2 -0
- package/lib/types.js +3 -5
- package/lib/utils.d.ts +8 -0
- package/lib/utils.js +16 -23
- package/package.json +17 -11
- package/src/@types/index.ts +70 -0
- package/src/@types/shims.d.ts +12 -0
- package/src/UserCenter/assets/banner.png +0 -0
- package/src/UserCenter/components/notification.tsx +275 -0
- package/src/UserCenter/components/passport.tsx +83 -0
- package/src/UserCenter/components/privacy.tsx +107 -0
- package/src/UserCenter/components/settings.tsx +78 -0
- package/src/UserCenter/components/user-basic-info.tsx +70 -0
- package/src/UserCenter/components/user-center.tsx +410 -0
- package/src/UserCenter/components/user-info-item.tsx +50 -0
- package/src/UserCenter/components/user-info.tsx +85 -0
- package/src/UserCenter/components/webhook-item.tsx +243 -0
- package/src/UserCenter/index.tsx +1 -0
- package/src/UserCenter/libs/client.ts +3 -0
- package/src/UserCenter/libs/locales.ts +72 -0
- package/src/UserCenter/libs/utils.ts +21 -0
- package/src/blocklets.js +2 -0
- package/src/index.ts +9 -0
- /package/src/common/{link-blocker.js → link-blocker.jsx} +0 -0
package/lib/blocklets.js
CHANGED
|
@@ -5,21 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.publicPath = exports.parseNavigation = exports.getLocalizedNavigation = exports.formatTheme = exports.formatNavigation = exports.formatBlockletInfo = exports.filterValidNavItems = exports.filterNavByRole = void 0;
|
|
7
7
|
var _utils = require("./utils");
|
|
8
|
-
|
|
9
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
13
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
14
|
-
const publicPath = ((_window = window) === null || _window === void 0 ? void 0 : (_window$blocklet = _window.blocklet) === null || _window$blocklet === void 0 ? void 0 : _window$blocklet.groupPrefix) || ((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$blocklet = _window2.blocklet) === null || _window2$blocklet === void 0 ? void 0 : _window2$blocklet.prefix) || '/';
|
|
8
|
+
const publicPath = exports.publicPath = window?.blocklet?.groupPrefix || window?.blocklet?.prefix || '/';
|
|
15
9
|
|
|
16
10
|
/**
|
|
17
11
|
* 格式化 theme (目前仅考虑 background)
|
|
18
12
|
*/
|
|
19
|
-
exports.publicPath = publicPath;
|
|
20
13
|
const formatTheme = theme => {
|
|
21
|
-
const formatted =
|
|
22
|
-
|
|
14
|
+
const formatted = {
|
|
15
|
+
...theme
|
|
16
|
+
};
|
|
17
|
+
const background = theme?.background;
|
|
23
18
|
if (typeof background === 'string') {
|
|
24
19
|
formatted.background = {
|
|
25
20
|
header: background,
|
|
@@ -40,9 +35,8 @@ const formatTheme = theme => {
|
|
|
40
35
|
* 获取指定 locale 对应的 navigation 数据, 仅考虑 zh/en
|
|
41
36
|
*/
|
|
42
37
|
exports.formatTheme = formatTheme;
|
|
43
|
-
const getLocalizedNavigation =
|
|
44
|
-
|
|
45
|
-
if (!(navigation !== null && navigation !== void 0 && navigation.length)) {
|
|
38
|
+
const getLocalizedNavigation = (navigation, locale = 'en') => {
|
|
39
|
+
if (!navigation?.length) {
|
|
46
40
|
return navigation;
|
|
47
41
|
}
|
|
48
42
|
// eslint-disable-next-line no-shadow
|
|
@@ -51,7 +45,7 @@ const getLocalizedNavigation = function getLocalizedNavigation(navigation) {
|
|
|
51
45
|
return title;
|
|
52
46
|
}
|
|
53
47
|
if (typeof title === 'object') {
|
|
54
|
-
return title[locale] ||
|
|
48
|
+
return title[locale] || title?.en || title?.zh;
|
|
55
49
|
}
|
|
56
50
|
return title;
|
|
57
51
|
};
|
|
@@ -69,17 +63,18 @@ const getLocalizedNavigation = function getLocalizedNavigation(navigation) {
|
|
|
69
63
|
return url.pathname + url.search;
|
|
70
64
|
}
|
|
71
65
|
if (typeof link === 'object') {
|
|
72
|
-
return link[locale] ||
|
|
66
|
+
return link[locale] || link?.en || link?.zh;
|
|
73
67
|
}
|
|
74
68
|
return link;
|
|
75
69
|
};
|
|
76
70
|
return (0, _utils.mapRecursive)(navigation, item => {
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
return {
|
|
72
|
+
...item,
|
|
79
73
|
title: getTitle(item.title, locale),
|
|
80
74
|
// 仅对叶结点进行处理
|
|
81
|
-
link: !
|
|
82
|
-
|
|
75
|
+
link: !item.items?.length ? getLink(item.link, locale) : item.link,
|
|
76
|
+
_rawLink: item.link
|
|
77
|
+
};
|
|
83
78
|
}, 'items');
|
|
84
79
|
};
|
|
85
80
|
|
|
@@ -92,16 +87,17 @@ exports.getLocalizedNavigation = getLocalizedNavigation;
|
|
|
92
87
|
const formatNavigation = navigation => {
|
|
93
88
|
return (0, _utils.mapRecursive)(navigation, item => {
|
|
94
89
|
if (item.role) {
|
|
95
|
-
return
|
|
90
|
+
return {
|
|
91
|
+
...item,
|
|
96
92
|
role: Array.isArray(item.role) ? item.role : [item.role]
|
|
97
|
-
}
|
|
93
|
+
};
|
|
98
94
|
}
|
|
99
95
|
return item;
|
|
100
96
|
}, 'items');
|
|
101
97
|
};
|
|
102
98
|
exports.formatNavigation = formatNavigation;
|
|
103
99
|
const parseNavigation = navigation => {
|
|
104
|
-
if (!
|
|
100
|
+
if (!navigation?.length) {
|
|
105
101
|
return null;
|
|
106
102
|
}
|
|
107
103
|
const formattedNav = formatNavigation(navigation);
|
|
@@ -115,7 +111,8 @@ const parseNavigation = navigation => {
|
|
|
115
111
|
// 对应 dashboard#sidenav 导航
|
|
116
112
|
dashboard: [],
|
|
117
113
|
// session manager menus
|
|
118
|
-
sessionManager: []
|
|
114
|
+
sessionManager: [],
|
|
115
|
+
userCenter: []
|
|
119
116
|
};
|
|
120
117
|
|
|
121
118
|
// 对 navigation 顶层元素按 section 分组
|
|
@@ -126,13 +123,11 @@ const parseNavigation = navigation => {
|
|
|
126
123
|
// item 出现在指定几个 section 中 (array)
|
|
127
124
|
} else if (Array.isArray(item.section)) {
|
|
128
125
|
item.section.forEach(sectionKey => {
|
|
129
|
-
|
|
130
|
-
(_sections$sectionKey = sections[sectionKey]) === null || _sections$sectionKey === void 0 ? void 0 : _sections$sectionKey.push(item);
|
|
126
|
+
sections[sectionKey]?.push(item);
|
|
131
127
|
});
|
|
132
128
|
// item 出现在指定的一个 section 中 (string)
|
|
133
129
|
} else if (typeof item.section === 'string') {
|
|
134
|
-
|
|
135
|
-
(_sections$item$sectio = sections[item.section]) === null || _sections$item$sectio === void 0 ? void 0 : _sections$item$sectio.push(item);
|
|
130
|
+
sections[item.section]?.push(item);
|
|
136
131
|
}
|
|
137
132
|
});
|
|
138
133
|
return sections;
|
|
@@ -146,7 +141,9 @@ const formatBlockletInfo = blockletInfo => {
|
|
|
146
141
|
if (!blockletInfo) {
|
|
147
142
|
return null;
|
|
148
143
|
}
|
|
149
|
-
const formatted =
|
|
144
|
+
const formatted = {
|
|
145
|
+
...blockletInfo
|
|
146
|
+
};
|
|
150
147
|
// theme
|
|
151
148
|
formatted.theme = formatTheme(formatted.theme);
|
|
152
149
|
// navigation
|
|
@@ -158,12 +155,8 @@ const formatBlockletInfo = blockletInfo => {
|
|
|
158
155
|
* 过滤掉无效结点 (无 link 且子元素为空)
|
|
159
156
|
*/
|
|
160
157
|
exports.formatBlockletInfo = formatBlockletInfo;
|
|
161
|
-
const filterValidNavItems =
|
|
162
|
-
|
|
163
|
-
return (0, _utils.filterRecursive)(navigation, (item, context) => {
|
|
164
|
-
var _context$filteredChil;
|
|
165
|
-
return !!item.link || ((_context$filteredChil = context.filteredChildren) === null || _context$filteredChil === void 0 ? void 0 : _context$filteredChil.length);
|
|
166
|
-
}, 'items');
|
|
158
|
+
const filterValidNavItems = (navigation = []) => {
|
|
159
|
+
return (0, _utils.filterRecursive)(navigation, (item, context) => !!item.link || context.filteredChildren?.length, 'items');
|
|
167
160
|
};
|
|
168
161
|
|
|
169
162
|
/**
|
|
@@ -181,8 +174,7 @@ const filterNavByRole = (nav, userRole) => {
|
|
|
181
174
|
return (0, _utils.filterRecursive)(nav, (item, context) => {
|
|
182
175
|
const isRoleMatched = !item.role || userRole && item.role.includes(userRole);
|
|
183
176
|
if (!context.isLeaf) {
|
|
184
|
-
|
|
185
|
-
return isRoleMatched && ((_context$filteredChil2 = context.filteredChildren) === null || _context$filteredChil2 === void 0 ? void 0 : _context$filteredChil2.length);
|
|
177
|
+
return isRoleMatched && context.filteredChildren?.length;
|
|
186
178
|
}
|
|
187
179
|
return isRoleMatched;
|
|
188
180
|
}, 'items');
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare function HeaderAddons({ formattedBlocklet, addons, sessionManagerProps }: {
|
|
2
|
+
formattedBlocklet: any;
|
|
3
|
+
addons: any;
|
|
4
|
+
sessionManagerProps: any;
|
|
5
|
+
}): import("react").DetailedReactHTMLElement<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
6
|
+
declare namespace HeaderAddons {
|
|
7
|
+
namespace propTypes {
|
|
8
|
+
export let formattedBlocklet: any;
|
|
9
|
+
export let addons: any;
|
|
10
|
+
export { sessionManagerProps };
|
|
11
|
+
}
|
|
12
|
+
namespace defaultProps {
|
|
13
|
+
let addons_1: null;
|
|
14
|
+
export { addons_1 as addons };
|
|
15
|
+
export namespace sessionManagerProps_1 {
|
|
16
|
+
let showRole: boolean;
|
|
17
|
+
}
|
|
18
|
+
export { sessionManagerProps_1 as sessionManagerProps };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export default HeaderAddons;
|
|
22
|
+
import { sessionManagerProps } from '../types';
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
module.exports = HeaderAddons;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
8
|
require("iconify-icon");
|
|
8
9
|
var _react = require("react");
|
|
9
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
var _Session = require("@arcblock/did-connect/lib/Session");
|
|
12
12
|
var _SessionUser = _interopRequireDefault(require("@arcblock/ux/lib/SessionUser"));
|
|
13
13
|
var _SessionBlocklet = _interopRequireDefault(require("@arcblock/ux/lib/SessionBlocklet"));
|
|
@@ -16,19 +16,11 @@ var _context = require("@arcblock/ux/lib/Locale/context");
|
|
|
16
16
|
var _types = require("../types");
|
|
17
17
|
var _blocklets = require("../blocklets");
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// eslint-disable-next-line no-shadow
|
|
25
|
-
function HeaderAddons(_ref) {
|
|
26
|
-
var _sessionCtx$session, _formattedBlocklet$na, _sessionCtx$session2, _sessionCtx$session2$;
|
|
27
|
-
let {
|
|
28
|
-
formattedBlocklet,
|
|
29
|
-
addons,
|
|
30
|
-
sessionManagerProps
|
|
31
|
-
} = _ref;
|
|
19
|
+
function HeaderAddons({
|
|
20
|
+
formattedBlocklet,
|
|
21
|
+
addons,
|
|
22
|
+
sessionManagerProps: sessionManagerProps2
|
|
23
|
+
}) {
|
|
32
24
|
const sessionCtx = (0, _react.useContext)(_Session.SessionContext);
|
|
33
25
|
const {
|
|
34
26
|
locale
|
|
@@ -37,23 +29,19 @@ function HeaderAddons(_ref) {
|
|
|
37
29
|
enableConnect = true,
|
|
38
30
|
enableLocale = true
|
|
39
31
|
} = formattedBlocklet;
|
|
40
|
-
const authenticated = !!
|
|
41
|
-
let localizedNav = (0, _blocklets.getLocalizedNavigation)(formattedBlocklet
|
|
42
|
-
|
|
43
|
-
localizedNav = (0, _blocklets.filterNavByRole)(localizedNav, sessionCtx === null || sessionCtx === void 0 ? void 0 : (_sessionCtx$session2 = sessionCtx.session) === null || _sessionCtx$session2 === void 0 ? void 0 : (_sessionCtx$session2$ = _sessionCtx$session2.user) === null || _sessionCtx$session2$ === void 0 ? void 0 : _sessionCtx$session2$.role);
|
|
32
|
+
const authenticated = !!sessionCtx?.session?.user;
|
|
33
|
+
let localizedNav = (0, _blocklets.getLocalizedNavigation)(formattedBlocklet?.navigation?.sessionManager, locale) || [];
|
|
34
|
+
localizedNav = (0, _blocklets.filterNavByRole)(localizedNav, sessionCtx?.session?.user?.role);
|
|
44
35
|
const renderAddons = () => {
|
|
45
|
-
|
|
46
|
-
if (addons && typeof addons !== 'function') {
|
|
36
|
+
if (addons && typeof addons !== "function") {
|
|
47
37
|
return Array.isArray(addons) ? addons : [addons];
|
|
48
38
|
}
|
|
49
39
|
let addonsArray = [];
|
|
50
|
-
// 启用了多语言并且检测到了 locale context
|
|
51
40
|
if (enableLocale && locale) {
|
|
52
|
-
addonsArray.push(
|
|
41
|
+
addonsArray.push( /* @__PURE__ */(0, _jsxRuntime.jsx)(_selector.default, {
|
|
53
42
|
showText: false
|
|
54
43
|
}, "locale-selector"));
|
|
55
44
|
}
|
|
56
|
-
// 启用了连接钱包并且检测到了 session context
|
|
57
45
|
if (enableConnect && sessionCtx) {
|
|
58
46
|
const menu = [];
|
|
59
47
|
if (authenticated) {
|
|
@@ -61,38 +49,38 @@ function HeaderAddons(_ref) {
|
|
|
61
49
|
navList.forEach(x => {
|
|
62
50
|
menu.push({
|
|
63
51
|
label: x.title,
|
|
64
|
-
icon: x.icon ?
|
|
52
|
+
icon: x.icon ? /* @__PURE__ */(0, _jsxRuntime.jsx)("iconify-icon", {
|
|
65
53
|
icon: x.icon,
|
|
66
54
|
height: 24,
|
|
67
55
|
style: {
|
|
68
56
|
marginRight: 8
|
|
69
57
|
}
|
|
70
58
|
}) : null,
|
|
71
|
-
component:
|
|
59
|
+
component: "a",
|
|
72
60
|
href: x.link,
|
|
73
61
|
key: x.link
|
|
74
62
|
});
|
|
75
63
|
});
|
|
76
64
|
}
|
|
77
|
-
addonsArray.push(
|
|
65
|
+
addonsArray.push( /* @__PURE__ */(0, _jsxRuntime.jsx)(_SessionBlocklet.default, {
|
|
78
66
|
session: sessionCtx.session,
|
|
79
|
-
locale
|
|
67
|
+
locale
|
|
80
68
|
}, "session-blocklet"));
|
|
81
|
-
addonsArray.push(
|
|
69
|
+
addonsArray.push( /* @__PURE__ */(0, _jsxRuntime.jsx)(_SessionUser.default, {
|
|
82
70
|
session: sessionCtx.session,
|
|
83
|
-
locale
|
|
84
|
-
menu
|
|
85
|
-
showRole: true
|
|
86
|
-
|
|
71
|
+
locale,
|
|
72
|
+
menu,
|
|
73
|
+
showRole: true,
|
|
74
|
+
...sessionManagerProps2
|
|
75
|
+
}, "session-user"));
|
|
87
76
|
}
|
|
88
|
-
|
|
89
|
-
if (typeof addons === 'function') {
|
|
77
|
+
if (typeof addons === "function") {
|
|
90
78
|
addonsArray = addons(addonsArray) || [];
|
|
91
79
|
}
|
|
92
80
|
return addonsArray;
|
|
93
81
|
};
|
|
94
82
|
const renderedAddons = renderAddons();
|
|
95
|
-
const addonList =
|
|
83
|
+
const addonList = (0, _react.createElement)(_jsxRuntime.Fragment, null, ...(Array.isArray(renderedAddons) ? renderedAddons : [renderedAddons]));
|
|
96
84
|
return addonList;
|
|
97
85
|
}
|
|
98
86
|
HeaderAddons.propTypes = {
|
|
@@ -3,33 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
12
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
8
|
function hasParentOfType(node, type) {
|
|
14
9
|
if (!node) return false;
|
|
15
10
|
if (type === node.nodeName) return true;
|
|
16
11
|
return hasParentOfType(node.parentNode, type);
|
|
17
12
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*/
|
|
22
|
-
function LinkBlocker(_ref) {
|
|
23
|
-
let rest = Object.assign({}, _ref);
|
|
13
|
+
function LinkBlocker({
|
|
14
|
+
...rest
|
|
15
|
+
}) {
|
|
24
16
|
const handleOnClick = e => {
|
|
25
|
-
const isInsideLink = hasParentOfType(e.target,
|
|
17
|
+
const isInsideLink = hasParentOfType(e.target, "A");
|
|
26
18
|
if (isInsideLink) {
|
|
27
19
|
e.preventDefault();
|
|
28
20
|
}
|
|
29
21
|
};
|
|
30
|
-
return
|
|
31
|
-
onClick: handleOnClick
|
|
32
|
-
|
|
22
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)("div", {
|
|
23
|
+
onClick: handleOnClick,
|
|
24
|
+
...rest
|
|
25
|
+
});
|
|
33
26
|
}
|
|
34
|
-
|
|
35
|
-
exports.default = _default;
|
|
27
|
+
module.exports = LinkBlocker;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 允许 theme 被覆盖的 ThemeProvider 组件, 默认使用 ux default theme, 可以传入 theme 进行覆盖
|
|
3
|
+
*/
|
|
4
|
+
declare function OverridableThemeProvider({ theme: themeOverrides, children }: {
|
|
5
|
+
theme: any;
|
|
6
|
+
children: any;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
8
|
+
declare namespace OverridableThemeProvider {
|
|
9
|
+
namespace propTypes {
|
|
10
|
+
let children: any;
|
|
11
|
+
let theme: any;
|
|
12
|
+
}
|
|
13
|
+
namespace defaultProps {
|
|
14
|
+
let theme_1: null;
|
|
15
|
+
export { theme_1 as theme };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export default OverridableThemeProvider;
|
|
@@ -3,25 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
module.exports = OverridableThemeProvider;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
9
|
var _Theme = require("@arcblock/ux/lib/Theme");
|
|
9
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
const defaultTheme = (0, _Theme.createTheme)();
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function OverridableThemeProvider(_ref) {
|
|
17
|
-
let {
|
|
18
|
-
theme: themeOverrides,
|
|
19
|
-
children
|
|
20
|
-
} = _ref;
|
|
12
|
+
function OverridableThemeProvider({
|
|
13
|
+
theme: themeOverrides,
|
|
14
|
+
children
|
|
15
|
+
}) {
|
|
21
16
|
const theme = themeOverrides ? (0, _Theme.createTheme)(themeOverrides) : defaultTheme;
|
|
22
|
-
return
|
|
23
|
-
theme
|
|
24
|
-
children
|
|
17
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_Theme.ThemeProvider, {
|
|
18
|
+
theme,
|
|
19
|
+
children
|
|
25
20
|
});
|
|
26
21
|
}
|
|
27
22
|
OverridableThemeProvider.propTypes = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function useWalletHiddenTopbar(): void;
|
|
@@ -7,15 +7,13 @@ exports.useWalletHiddenTopbar = void 0;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _useBrowser = _interopRequireDefault(require("@arcblock/react-hooks/lib/useBrowser"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
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); }
|
|
11
|
-
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; }
|
|
12
10
|
// 在 wallet webview 环境中, 隐藏 wallet topbar
|
|
13
11
|
// eslint-disable-next-line import/prefer-default-export
|
|
14
12
|
const useWalletHiddenTopbar = () => {
|
|
15
13
|
const browser = (0, _useBrowser.default)();
|
|
16
14
|
(0, _react.useEffect)(() => {
|
|
17
15
|
if (browser.wallet) {
|
|
18
|
-
Promise.resolve().then(() =>
|
|
16
|
+
Promise.resolve().then(() => require('dsbridge')).then(dsbridge => {
|
|
19
17
|
if (!dsbridge.call) {
|
|
20
18
|
// eslint-disable-next-line no-param-reassign
|
|
21
19
|
dsbridge = dsbridge.default;
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
Header: true,
|
|
8
|
+
Footer: true,
|
|
9
|
+
Dashboard: true,
|
|
10
|
+
Icon: true
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "Dashboard", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _Dashboard.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "Footer", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _Footer.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "Header", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _Header.default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "Icon", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _Icon.default;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var _Header = _interopRequireDefault(require("./Header"));
|
|
37
|
+
var _Footer = _interopRequireDefault(require("./Footer"));
|
|
38
|
+
var _Dashboard = _interopRequireDefault(require("./Dashboard"));
|
|
39
|
+
var _Icon = _interopRequireDefault(require("./Icon"));
|
|
40
|
+
var _UserCenter = require("./UserCenter");
|
|
41
|
+
Object.keys(_UserCenter).forEach(function (key) {
|
|
42
|
+
if (key === "default" || key === "__esModule") return;
|
|
43
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
44
|
+
if (key in exports && exports[key] === _UserCenter[key]) return;
|
|
45
|
+
Object.defineProperty(exports, key, {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () {
|
|
48
|
+
return _UserCenter[key];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/lib/types.d.ts
ADDED
package/lib/types.js
CHANGED
|
@@ -8,7 +8,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
9
|
/* eslint-disable import/prefer-default-export */
|
|
10
10
|
|
|
11
|
-
const blockletMetaProps = _propTypes.default.shape({
|
|
11
|
+
const blockletMetaProps = exports.blockletMetaProps = _propTypes.default.shape({
|
|
12
12
|
appLogo: _propTypes.default.node,
|
|
13
13
|
appName: _propTypes.default.string,
|
|
14
14
|
theme: _propTypes.default.shape({
|
|
@@ -26,8 +26,7 @@ const blockletMetaProps = _propTypes.default.shape({
|
|
|
26
26
|
}))
|
|
27
27
|
}))
|
|
28
28
|
});
|
|
29
|
-
exports.
|
|
30
|
-
const sessionManagerProps = _propTypes.default.shape({
|
|
29
|
+
const sessionManagerProps = exports.sessionManagerProps = _propTypes.default.shape({
|
|
31
30
|
showText: _propTypes.default.bool,
|
|
32
31
|
showRole: _propTypes.default.bool,
|
|
33
32
|
switchDid: _propTypes.default.bool,
|
|
@@ -43,5 +42,4 @@ const sessionManagerProps = _propTypes.default.shape({
|
|
|
43
42
|
menuRender: _propTypes.default.func,
|
|
44
43
|
dark: _propTypes.default.bool,
|
|
45
44
|
size: _propTypes.default.number
|
|
46
|
-
});
|
|
47
|
-
exports.sessionManagerProps = sessionManagerProps;
|
|
45
|
+
});
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function mapRecursive(array: any, fn: any, childrenKey?: string): any;
|
|
2
|
+
export function flatRecursive(array: any, childrenKey?: string): any[];
|
|
3
|
+
export function countRecursive(array: any, childrenKey?: string): number;
|
|
4
|
+
export function filterRecursive(array: any, predicate: any, childrenKey?: string): any;
|
|
5
|
+
export function isUrl(str: any): boolean;
|
|
6
|
+
export function isIconifyString(str: any): boolean;
|
|
7
|
+
export function matchPath(path: any): any;
|
|
8
|
+
export function matchPaths(paths?: any[]): number;
|
package/lib/utils.js
CHANGED
|
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.matchPaths = exports.matchPath = exports.mapRecursive = exports.isUrl = exports.isIconifyString = exports.flatRecursive = exports.filterRecursive = exports.countRecursive = void 0;
|
|
7
|
-
|
|
8
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
-
const mapRecursive = function mapRecursive(array, fn) {
|
|
13
|
-
let childrenKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'children';
|
|
7
|
+
const mapRecursive = (array, fn, childrenKey = 'children') => {
|
|
14
8
|
return array.map(item => {
|
|
15
9
|
if (Array.isArray(item[childrenKey])) {
|
|
16
|
-
return fn(
|
|
10
|
+
return fn({
|
|
11
|
+
...item,
|
|
17
12
|
[childrenKey]: mapRecursive(item[childrenKey], fn, childrenKey)
|
|
18
|
-
})
|
|
13
|
+
});
|
|
19
14
|
}
|
|
20
15
|
return fn(item);
|
|
21
16
|
});
|
|
@@ -23,8 +18,7 @@ const mapRecursive = function mapRecursive(array, fn) {
|
|
|
23
18
|
|
|
24
19
|
// 展平有层级结构的 array
|
|
25
20
|
exports.mapRecursive = mapRecursive;
|
|
26
|
-
const flatRecursive =
|
|
27
|
-
let childrenKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'children';
|
|
21
|
+
const flatRecursive = (array, childrenKey = 'children') => {
|
|
28
22
|
const result = [];
|
|
29
23
|
mapRecursive(array, item => result.push(item), childrenKey);
|
|
30
24
|
return result;
|
|
@@ -32,8 +26,7 @@ const flatRecursive = function flatRecursive(array) {
|
|
|
32
26
|
|
|
33
27
|
// 对有层级结构的 array 元素计数
|
|
34
28
|
exports.flatRecursive = flatRecursive;
|
|
35
|
-
const countRecursive =
|
|
36
|
-
let childrenKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'children';
|
|
29
|
+
const countRecursive = (array, childrenKey = 'children') => {
|
|
37
30
|
let counter = 0;
|
|
38
31
|
mapRecursive(array, () => counter++, childrenKey);
|
|
39
32
|
return counter;
|
|
@@ -42,17 +35,18 @@ const countRecursive = function countRecursive(array) {
|
|
|
42
35
|
// 对有层级结构的 array 进行 filter 处理
|
|
43
36
|
// 因为是 DFS 遍历, 可以借助 context.filteredChildren 在过滤/保留子结的同时保持父子结构 (即使父结点不满足筛选条件)
|
|
44
37
|
exports.countRecursive = countRecursive;
|
|
45
|
-
const filterRecursive =
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
const filterRecursive = (array, predicate, childrenKey = 'children') => {
|
|
39
|
+
return array.map(item => ({
|
|
40
|
+
...item
|
|
41
|
+
})).filter(item => {
|
|
48
42
|
const children = item[childrenKey];
|
|
49
43
|
if (Array.isArray(children)) {
|
|
50
44
|
const filtered = filterRecursive(children, predicate, childrenKey);
|
|
51
|
-
item[childrenKey] = filtered
|
|
45
|
+
item[childrenKey] = filtered?.length ? filtered : undefined;
|
|
52
46
|
}
|
|
53
47
|
const context = {
|
|
54
48
|
filteredChildren: item[childrenKey],
|
|
55
|
-
isLeaf: !
|
|
49
|
+
isLeaf: !children?.length
|
|
56
50
|
};
|
|
57
51
|
return predicate(item, context);
|
|
58
52
|
});
|
|
@@ -73,10 +67,10 @@ const isIconifyString = str => {
|
|
|
73
67
|
*/
|
|
74
68
|
exports.isIconifyString = isIconifyString;
|
|
75
69
|
const matchPath = path => {
|
|
76
|
-
if (!path || !
|
|
70
|
+
if (!path || !path?.startsWith('/')) {
|
|
77
71
|
return false;
|
|
78
72
|
}
|
|
79
|
-
const ensureTrailingSlash = str => str.endsWith('/') ? str :
|
|
73
|
+
const ensureTrailingSlash = str => str.endsWith('/') ? str : `${str}/`;
|
|
80
74
|
const pathname = ensureTrailingSlash(window.location.pathname);
|
|
81
75
|
const normalizedPath = ensureTrailingSlash(new URL(path, window.location.origin).pathname);
|
|
82
76
|
return pathname.startsWith(normalizedPath);
|
|
@@ -86,13 +80,12 @@ const matchPath = path => {
|
|
|
86
80
|
* 从一组 paths 中, 找到匹配当前 location 的 path, 返回序号
|
|
87
81
|
*/
|
|
88
82
|
exports.matchPath = matchPath;
|
|
89
|
-
const matchPaths =
|
|
90
|
-
let paths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
83
|
+
const matchPaths = (paths = []) => {
|
|
91
84
|
const matched = paths.map((item, index) => ({
|
|
92
85
|
path: item,
|
|
93
86
|
index
|
|
94
87
|
})).filter(item => matchPath(item.path));
|
|
95
|
-
if (!
|
|
88
|
+
if (!matched?.length) {
|
|
96
89
|
return -1;
|
|
97
90
|
}
|
|
98
91
|
// 多个 path 都匹配时, 取一个最具体 (最长的) path
|