@blocklet/ui-react 2.9.91 → 2.10.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.
Files changed (209) hide show
  1. package/build.config.ts +1 -6
  2. package/lib/@types/index.d.ts +1 -0
  3. package/lib/@types/index.js +0 -1
  4. package/lib/BlockletStudio/index.js +50 -50
  5. package/lib/ComponentInstaller/index.js +122 -202
  6. package/lib/ComponentInstaller/installer-item.js +116 -138
  7. package/lib/ComponentInstaller/locales.js +5 -10
  8. package/lib/ComponentInstaller/use-component-installed.js +37 -41
  9. package/lib/ComponentManager/components/add-component.js +58 -67
  10. package/lib/ComponentManager/components/check-component.js +2 -9
  11. package/lib/ComponentManager/components/publish-component.js +50 -59
  12. package/lib/ComponentManager/components/resource-dialog.js +42 -39
  13. package/lib/ComponentManager/index.js +3 -27
  14. package/lib/ComponentManager/libs/locales.js +2 -8
  15. package/lib/Dashboard/index.js +74 -99
  16. package/lib/Footer/brand.js +21 -43
  17. package/lib/Footer/copyright.js +15 -24
  18. package/lib/Footer/index.js +47 -71
  19. package/lib/Footer/internal-footer.js +72 -100
  20. package/lib/Footer/layout/plain.js +26 -45
  21. package/lib/Footer/layout/row.js +12 -29
  22. package/lib/Footer/layout/standard.js +34 -64
  23. package/lib/Footer/links.js +74 -104
  24. package/lib/Footer/social-media.js +35 -42
  25. package/lib/Header/index.js +69 -117
  26. package/lib/Icon/index.js +18 -53
  27. package/{es/UserCenter/components/notification.d.ts → lib/UserCenter/components/config-profile.d.ts} +1 -1
  28. package/lib/UserCenter/components/config-profile.js +67 -0
  29. package/lib/UserCenter/components/notification.js +203 -186
  30. package/lib/UserCenter/components/passport.js +70 -79
  31. package/lib/UserCenter/components/privacy.js +86 -88
  32. package/lib/UserCenter/components/settings.js +74 -84
  33. package/lib/UserCenter/components/storage/connect-to.js +56 -75
  34. package/lib/UserCenter/components/storage/connected.js +16 -37
  35. package/lib/UserCenter/components/storage/delete.js +42 -51
  36. package/lib/UserCenter/components/storage/disconnect.js +15 -29
  37. package/lib/UserCenter/components/storage/index.js +20 -54
  38. package/lib/UserCenter/components/storage/item.js +94 -122
  39. package/lib/UserCenter/components/storage/preview-nft.js +77 -85
  40. package/lib/UserCenter/components/third-party-login/index.js +49 -61
  41. package/lib/UserCenter/components/third-party-login/third-party-item.js +159 -176
  42. package/lib/UserCenter/components/user-center.js +276 -287
  43. package/lib/UserCenter/components/user-info/index.js +3 -27
  44. package/lib/UserCenter/components/user-info/user-basic-info.js +134 -129
  45. package/lib/UserCenter/components/user-info/user-info-item.js +43 -37
  46. package/lib/UserCenter/components/user-info/user-info.js +41 -74
  47. package/lib/UserCenter/components/webhook-item.js +184 -177
  48. package/lib/UserCenter/index.js +1 -13
  49. package/lib/UserCenter/libs/api.js +4 -16
  50. package/lib/UserCenter/libs/locales.d.ts +10 -0
  51. package/lib/UserCenter/libs/locales.js +12 -8
  52. package/lib/UserCenter/libs/utils.js +7 -17
  53. package/lib/UserSessions/components/user-session-info.js +88 -85
  54. package/lib/UserSessions/components/user-sessions.js +177 -213
  55. package/lib/UserSessions/index.js +1 -13
  56. package/lib/UserSessions/libs/locales.js +2 -8
  57. package/lib/UserSessions/libs/utils.js +4 -11
  58. package/lib/blocklets.js +59 -63
  59. package/lib/common/header-addons.js +44 -60
  60. package/lib/common/link-blocker.js +9 -18
  61. package/lib/common/overridable-theme-provider.js +10 -23
  62. package/lib/common/wallet-hidden-topbar.js +7 -14
  63. package/lib/contexts/config-user-space.js +38 -46
  64. package/lib/hooks/use-mobile.js +5 -13
  65. package/lib/index.js +10 -100
  66. package/lib/libs/client.js +2 -8
  67. package/lib/libs/spaces.js +6 -13
  68. package/lib/types.js +39 -41
  69. package/lib/utils.js +25 -44
  70. package/package.json +8 -38
  71. package/src/@types/index.ts +1 -0
  72. package/src/Footer/brand.jsx +6 -1
  73. package/src/UserCenter/components/config-profile.tsx +70 -0
  74. package/src/UserCenter/components/notification.tsx +63 -47
  75. package/src/UserCenter/components/settings.tsx +6 -0
  76. package/src/UserCenter/libs/locales.ts +10 -0
  77. package/es/@types/index.d.ts +0 -101
  78. package/es/@types/index.js +0 -0
  79. package/es/@types/shims.d.ts +0 -16
  80. package/es/BlockletStudio/index.d.ts +0 -28
  81. package/es/BlockletStudio/index.js +0 -114
  82. package/es/ComponentInstaller/index.d.ts +0 -37
  83. package/es/ComponentInstaller/index.js +0 -200
  84. package/es/ComponentInstaller/installer-item.d.ts +0 -21
  85. package/es/ComponentInstaller/installer-item.js +0 -139
  86. package/es/ComponentInstaller/locales.d.ts +0 -28
  87. package/es/ComponentInstaller/locales.js +0 -22
  88. package/es/ComponentInstaller/use-component-installed.d.ts +0 -12
  89. package/es/ComponentInstaller/use-component-installed.js +0 -88
  90. package/es/ComponentManager/components/add-component.d.ts +0 -16
  91. package/es/ComponentManager/components/add-component.js +0 -114
  92. package/es/ComponentManager/components/check-component.d.ts +0 -2
  93. package/es/ComponentManager/components/check-component.js +0 -2
  94. package/es/ComponentManager/components/publish-component.d.ts +0 -10
  95. package/es/ComponentManager/components/publish-component.js +0 -76
  96. package/es/ComponentManager/components/resource-dialog.d.ts +0 -14
  97. package/es/ComponentManager/components/resource-dialog.js +0 -74
  98. package/es/ComponentManager/index.d.ts +0 -3
  99. package/es/ComponentManager/index.js +0 -3
  100. package/es/ComponentManager/libs/locales.d.ts +0 -14
  101. package/es/ComponentManager/libs/locales.js +0 -14
  102. package/es/Dashboard/index.d.ts +0 -40
  103. package/es/Dashboard/index.js +0 -118
  104. package/es/Footer/brand.d.ts +0 -22
  105. package/es/Footer/brand.js +0 -73
  106. package/es/Footer/copyright.d.ts +0 -18
  107. package/es/Footer/copyright.js +0 -25
  108. package/es/Footer/index.d.ts +0 -6
  109. package/es/Footer/index.js +0 -82
  110. package/es/Footer/internal-footer.d.ts +0 -29
  111. package/es/Footer/internal-footer.js +0 -117
  112. package/es/Footer/layout/plain.d.ts +0 -15
  113. package/es/Footer/layout/plain.js +0 -39
  114. package/es/Footer/layout/row.d.ts +0 -18
  115. package/es/Footer/layout/row.js +0 -41
  116. package/es/Footer/layout/standard.d.ts +0 -15
  117. package/es/Footer/layout/standard.js +0 -53
  118. package/es/Footer/links.d.ts +0 -22
  119. package/es/Footer/links.js +0 -207
  120. package/es/Footer/social-media.d.ts +0 -14
  121. package/es/Footer/social-media.js +0 -60
  122. package/es/Header/index.d.ts +0 -10
  123. package/es/Header/index.js +0 -155
  124. package/es/Icon/index.d.ts +0 -23
  125. package/es/Icon/index.js +0 -55
  126. package/es/UserCenter/assets/banner.png +0 -0
  127. package/es/UserCenter/components/notification.js +0 -248
  128. package/es/UserCenter/components/passport.d.ts +0 -6
  129. package/es/UserCenter/components/passport.js +0 -88
  130. package/es/UserCenter/components/privacy.d.ts +0 -11
  131. package/es/UserCenter/components/privacy.js +0 -99
  132. package/es/UserCenter/components/settings.d.ts +0 -9
  133. package/es/UserCenter/components/settings.js +0 -89
  134. package/es/UserCenter/components/storage/connect-to.d.ts +0 -7
  135. package/es/UserCenter/components/storage/connect-to.js +0 -108
  136. package/es/UserCenter/components/storage/connected.d.ts +0 -7
  137. package/es/UserCenter/components/storage/connected.js +0 -24
  138. package/es/UserCenter/components/storage/delete.d.ts +0 -7
  139. package/es/UserCenter/components/storage/delete.js +0 -62
  140. package/es/UserCenter/components/storage/disconnect.d.ts +0 -3
  141. package/es/UserCenter/components/storage/disconnect.js +0 -23
  142. package/es/UserCenter/components/storage/icons/empty-spaces-nft.svg +0 -58
  143. package/es/UserCenter/components/storage/icons/long-arrow.svg +0 -5
  144. package/es/UserCenter/components/storage/icons/space-connected.svg +0 -3
  145. package/es/UserCenter/components/storage/icons/space-disconnect.svg +0 -3
  146. package/es/UserCenter/components/storage/index.d.ts +0 -3
  147. package/es/UserCenter/components/storage/index.js +0 -27
  148. package/es/UserCenter/components/storage/item.d.ts +0 -9
  149. package/es/UserCenter/components/storage/item.js +0 -158
  150. package/es/UserCenter/components/storage/preview-nft.d.ts +0 -6
  151. package/es/UserCenter/components/storage/preview-nft.js +0 -80
  152. package/es/UserCenter/components/third-party-login/index.d.ts +0 -5
  153. package/es/UserCenter/components/third-party-login/index.js +0 -110
  154. package/es/UserCenter/components/third-party-login/third-party-item.d.ts +0 -13
  155. package/es/UserCenter/components/third-party-login/third-party-item.js +0 -224
  156. package/es/UserCenter/components/user-center.d.ts +0 -15
  157. package/es/UserCenter/components/user-center.js +0 -414
  158. package/es/UserCenter/components/user-info/index.d.ts +0 -3
  159. package/es/UserCenter/components/user-info/index.js +0 -3
  160. package/es/UserCenter/components/user-info/user-basic-info.d.ts +0 -11
  161. package/es/UserCenter/components/user-info/user-basic-info.js +0 -151
  162. package/es/UserCenter/components/user-info/user-info-item.d.ts +0 -11
  163. package/es/UserCenter/components/user-info/user-info-item.js +0 -47
  164. package/es/UserCenter/components/user-info/user-info.d.ts +0 -6
  165. package/es/UserCenter/components/user-info/user-info.js +0 -66
  166. package/es/UserCenter/components/webhook-item.d.ts +0 -3
  167. package/es/UserCenter/components/webhook-item.js +0 -243
  168. package/es/UserCenter/index.d.ts +0 -1
  169. package/es/UserCenter/index.js +0 -1
  170. package/es/UserCenter/libs/api.d.ts +0 -3
  171. package/es/UserCenter/libs/api.js +0 -4
  172. package/es/UserCenter/libs/locales.d.ts +0 -162
  173. package/es/UserCenter/libs/locales.js +0 -162
  174. package/es/UserCenter/libs/utils.d.ts +0 -4
  175. package/es/UserCenter/libs/utils.js +0 -14
  176. package/es/UserSessions/components/user-session-info.d.ts +0 -6
  177. package/es/UserSessions/components/user-session-info.js +0 -92
  178. package/es/UserSessions/components/user-sessions.d.ts +0 -9
  179. package/es/UserSessions/components/user-sessions.js +0 -265
  180. package/es/UserSessions/index.d.ts +0 -1
  181. package/es/UserSessions/index.js +0 -1
  182. package/es/UserSessions/libs/locales.d.ts +0 -58
  183. package/es/UserSessions/libs/locales.js +0 -58
  184. package/es/UserSessions/libs/utils.d.ts +0 -2
  185. package/es/UserSessions/libs/utils.js +0 -73
  186. package/es/blocklets.d.ts +0 -16
  187. package/es/blocklets.js +0 -178
  188. package/es/common/header-addons.d.ts +0 -21
  189. package/es/common/header-addons.js +0 -83
  190. package/es/common/link-blocker.d.ts +0 -7
  191. package/es/common/link-blocker.js +0 -18
  192. package/es/common/overridable-theme-provider.d.ts +0 -18
  193. package/es/common/overridable-theme-provider.js +0 -15
  194. package/es/common/wallet-hidden-topbar.d.ts +0 -1
  195. package/es/common/wallet-hidden-topbar.js +0 -14
  196. package/es/contexts/config-user-space.d.ts +0 -26
  197. package/es/contexts/config-user-space.js +0 -53
  198. package/es/hooks/use-mobile.d.ts +0 -4
  199. package/es/hooks/use-mobile.js +0 -5
  200. package/es/index.d.ts +0 -10
  201. package/es/index.js +0 -10
  202. package/es/libs/client.d.ts +0 -2
  203. package/es/libs/client.js +0 -2
  204. package/es/libs/spaces.d.ts +0 -2
  205. package/es/libs/spaces.js +0 -13
  206. package/es/types.d.ts +0 -2
  207. package/es/types.js +0 -43
  208. package/es/utils.d.ts +0 -8
  209. package/es/utils.js +0 -78
@@ -1,92 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Box, Chip, Tooltip, Typography } from "@mui/material";
3
- import Avatar from "@arcblock/ux/lib/Avatar";
4
- import { useCreation } from "ahooks";
5
- import { temp as colors } from "@arcblock/ux/lib/Colors";
6
- export default function UserSessionInfo({ user, sessionUser }) {
7
- const currentRole = useCreation(() => {
8
- return (user?.passports || [])?.find((item) => item.name === sessionUser.role);
9
- }, [user?.passports, sessionUser?.role]);
10
- return /* @__PURE__ */ jsxs(
11
- Box,
12
- {
13
- sx: {
14
- display: "flex",
15
- alignItems: "center",
16
- gap: 1
17
- },
18
- children: [
19
- /* @__PURE__ */ jsx(
20
- Avatar,
21
- {
22
- size: 40,
23
- variant: "circle",
24
- shape: "circle",
25
- src: sessionUser.avatar,
26
- did: sessionUser.did,
27
- sx: { flexShrink: 0 }
28
- }
29
- ),
30
- /* @__PURE__ */ jsxs(Box, { sx: { flex: 1, overflow: "hidden" }, children: [
31
- /* @__PURE__ */ jsxs(
32
- Box,
33
- {
34
- sx: {
35
- display: "flex",
36
- alignItems: "center",
37
- gap: 1
38
- },
39
- children: [
40
- /* @__PURE__ */ jsx(Tooltip, { title: sessionUser.fullName, children: /* @__PURE__ */ jsx(
41
- Typography,
42
- {
43
- sx: {
44
- whiteSpace: "nowrap",
45
- overflow: "hidden",
46
- textOverflow: "ellipsis",
47
- flex: 1
48
- },
49
- children: sessionUser.fullName
50
- }
51
- ) }),
52
- /* @__PURE__ */ jsx(
53
- Chip,
54
- {
55
- label: currentRole?.title || currentRole?.name || "Guest",
56
- size: "small",
57
- variant: "outlined",
58
- sx: {
59
- flexShrink: 0,
60
- fontWeight: "bold",
61
- fontSize: "12px",
62
- color: colors.textBase,
63
- borderColor: colors.strokeBorderStrong,
64
- backgroundColor: "transparent",
65
- textTransform: "capitalize",
66
- pr: 0.5,
67
- pl: 0,
68
- height: "auto"
69
- }
70
- }
71
- )
72
- ]
73
- }
74
- ),
75
- /* @__PURE__ */ jsx(Tooltip, { title: sessionUser.email, children: /* @__PURE__ */ jsx(
76
- Typography,
77
- {
78
- variant: "body2",
79
- color: "grey",
80
- sx: {
81
- whiteSpace: "nowrap",
82
- overflow: "hidden",
83
- textOverflow: "ellipsis"
84
- },
85
- children: sessionUser.email
86
- }
87
- ) })
88
- ] })
89
- ]
90
- }
91
- );
92
- }
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import { User } from '../../@types';
3
- export default function UserSessions({ user, showAction, showUser, }: {
4
- readonly user: User & {
5
- userSessions?: any[];
6
- };
7
- readonly showAction?: boolean;
8
- readonly showUser?: boolean;
9
- }): import("react").JSX.Element;
@@ -1,265 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import Datatable from "@arcblock/ux/lib/Datatable";
3
- import { useCreation, useMemoizedFn, useRequest } from "ahooks";
4
- import { translate } from "@arcblock/ux/lib/Locale/util";
5
- import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
6
- import RelativeTime from "@arcblock/ux/lib/RelativeTime";
7
- import sortBy from "lodash/sortBy";
8
- import UAParser from "ua-parser-js";
9
- import { getVisitorId } from "@arcblock/ux/lib/Util";
10
- import { useConfirm } from "@arcblock/ux/lib/Dialog";
11
- import pAll from "p-all";
12
- import { Box, Button, Tooltip, Typography } from "@mui/material";
13
- import UserSessionInfo from "./user-session-info.js";
14
- import { client } from "../../libs/client.js";
15
- import { translations } from "../libs/locales.js";
16
- import { batchIp2Region } from "../libs/utils.js";
17
- const parseUa = (ua) => {
18
- const parser = new UAParser(ua, {
19
- // eslint-disable-next-line no-useless-escape
20
- browser: [[/(ArcWallet)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION]]
21
- });
22
- const result = parser.getResult();
23
- return result;
24
- };
25
- export default function UserSessions({
26
- user,
27
- showAction = true,
28
- showUser = true
29
- }) {
30
- const currentVisitorId = getVisitorId();
31
- const { locale } = useLocaleContext();
32
- const { confirmApi, confirmHolder } = useConfirm();
33
- const t = useMemoizedFn((key, data = {}) => {
34
- return translate(translations, key, locale, "en", data);
35
- });
36
- const getData = useMemoizedFn(async () => {
37
- let data = user?.userSessions;
38
- if (!data) {
39
- data = await client.userSession.getUserSessions({ did: user.did });
40
- }
41
- try {
42
- const ipIndexList = data?.map((x, index) => [index, x.lastLoginIp]).filter((x) => !!x[1]);
43
- const ipList = ipIndexList?.map((x) => x[1]);
44
- const result = await batchIp2Region(ipList);
45
- for (let index = 0; index < result.length; index++) {
46
- const x = result[index];
47
- const ipIndexItem = ipIndexList[index];
48
- const dataItem = data[ipIndexItem[0]];
49
- dataItem.ipRegion = x;
50
- }
51
- } catch (e) {
52
- console.warn("Failed to convert ip to region");
53
- console.error(e);
54
- }
55
- const now = (/* @__PURE__ */ new Date()).getTime();
56
- return sortBy(data, (x) => {
57
- if (x.visitorId === currentVisitorId) {
58
- return -1;
59
- }
60
- return now - new Date(x.updatedAt).getTime();
61
- });
62
- });
63
- const pageState = useRequest(getData);
64
- const safeData = useCreation(() => {
65
- return pageState.data || [];
66
- }, [pageState.data]);
67
- const ipRegionMap = useCreation(() => {
68
- return safeData.reduce((acc, x) => {
69
- acc[x.lastLoginIp] = x.ipRegion;
70
- return acc;
71
- }, {});
72
- }, [safeData]);
73
- const logout = useMemoizedFn(({ visitorId }) => {
74
- confirmApi.open({
75
- title: t("logoutThisSession"),
76
- content: t("logoutThisSessionConfirm"),
77
- confirmButtonText: t("confirm"),
78
- cancelButtonText: t("cancel"),
79
- onConfirm: async () => {
80
- await client.user.logout({ visitorId });
81
- pageState.refresh();
82
- confirmApi.close();
83
- }
84
- });
85
- });
86
- const otherUserSessions = useCreation(() => {
87
- const list = safeData.filter((x) => x.visitorId !== currentVisitorId);
88
- return list;
89
- }, [safeData]);
90
- const logoutAll = useMemoizedFn(() => {
91
- confirmApi.open({
92
- title: t("logoutAllSession"),
93
- content: t("logoutAllSessionConfirm"),
94
- confirmButtonText: t("confirm"),
95
- cancelButtonText: t("cancel"),
96
- onConfirm: async () => {
97
- const list = otherUserSessions.map((x) => {
98
- return () => client.user.logout({ visitorId: x.visitorId });
99
- });
100
- await pAll(list, {
101
- concurrency: 3,
102
- stopOnError: false
103
- });
104
- pageState.refresh();
105
- confirmApi.close();
106
- }
107
- });
108
- });
109
- const customButtons = [];
110
- if (showAction) {
111
- customButtons.push(
112
- /* @__PURE__ */ jsx(Tooltip, { title: t("logoutAllTips"), children: /* @__PURE__ */ jsx(
113
- Button,
114
- {
115
- sx: { ml: 0.5 },
116
- size: "small",
117
- variant: "contained",
118
- color: "error",
119
- onClick: logoutAll,
120
- disabled: otherUserSessions.length === 0,
121
- children: t("logoutAll")
122
- }
123
- ) }, "logoutAll")
124
- );
125
- }
126
- const tableOptions = useCreation(() => {
127
- return {
128
- // viewColumns: false,
129
- search: false,
130
- sort: false,
131
- download: false,
132
- filter: false,
133
- print: false,
134
- expandableRowsOnClick: false,
135
- searchDebounceTime: 600
136
- };
137
- }, []);
138
- const columns = [
139
- {
140
- label: t("platform"),
141
- name: "platform",
142
- options: {
143
- customBodyRenderLite: (rawIndex) => {
144
- const x = safeData[rawIndex];
145
- const result = parseUa(x.ua);
146
- return /* @__PURE__ */ jsx(Box, { children: [result.os?.name, result.os?.version].filter(Boolean).join("/") || t("unknown") });
147
- }
148
- }
149
- },
150
- {
151
- label: t("deviceType"),
152
- name: "deviceType",
153
- options: {
154
- customBodyRenderLite: (rawIndex) => {
155
- const x = safeData[rawIndex];
156
- const result = parseUa(x.ua);
157
- return /* @__PURE__ */ jsx(Box, { children: [result.browser?.name, result.browser?.version].filter(Boolean).join("/") || t("unknown") });
158
- }
159
- }
160
- },
161
- {
162
- label: t("walletOS"),
163
- name: "walletOS",
164
- options: {
165
- customBodyRenderLite: (rawIndex) => {
166
- const x = safeData[rawIndex];
167
- return /* @__PURE__ */ jsx(Box, { children: x.extra?.walletOS || t("unknown") });
168
- }
169
- }
170
- },
171
- showUser && {
172
- label: t("user"),
173
- name: "user",
174
- options: {
175
- customBodyRenderLite: (rawIndex) => {
176
- const x = safeData[rawIndex];
177
- return /* @__PURE__ */ jsx(Box, { sx: { minWidth: 150, maxWidth: 250 }, children: /* @__PURE__ */ jsx(UserSessionInfo, { sessionUser: x.user, user }) });
178
- }
179
- }
180
- },
181
- {
182
- label: t("createdAt"),
183
- name: "createdAt",
184
- options: {
185
- customBodyRenderLite: (rawIndex) => {
186
- const x = safeData[rawIndex];
187
- return x.createdAt ? /* @__PURE__ */ jsx(RelativeTime, { value: x.createdAt, relativeRange: 3 * 86400 * 1e3, locale }) : t("unknown");
188
- }
189
- }
190
- },
191
- {
192
- label: t("updatedAt"),
193
- name: "updatedAt",
194
- options: {
195
- customBodyRenderLite: (rawIndex) => {
196
- const x = safeData[rawIndex];
197
- return x.status === "expired" ? t("expired") : /* @__PURE__ */ jsx(RelativeTime, { value: x.updatedAt, relativeRange: 3 * 86400 * 1e3, locale });
198
- }
199
- }
200
- },
201
- {
202
- label: t("lastLoginIp"),
203
- name: "lastLoginIp",
204
- options: {
205
- customBodyRenderLite: (rawIndex) => {
206
- const x = safeData[rawIndex];
207
- return /* @__PURE__ */ jsx(Box, { children: ipRegionMap[x.lastLoginIp] ? /* @__PURE__ */ jsxs(Fragment, { children: [
208
- /* @__PURE__ */ jsx(Typography, { variant: "body2", children: ipRegionMap[x.lastLoginIp] }),
209
- /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "grey", children: x.lastLoginIp || t("unknown") })
210
- ] }) : /* @__PURE__ */ jsx(Typography, { children: x.lastLoginIp || t("unknown") }) });
211
- }
212
- }
213
- },
214
- showAction && {
215
- label: t("actions"),
216
- name: "actions",
217
- options: {
218
- customBodyRenderLite: (rawIndex) => {
219
- const x = safeData[rawIndex];
220
- return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
221
- Button,
222
- {
223
- sx: {
224
- whiteSpace: "nowrap",
225
- fontSize: "12px",
226
- px: 1
227
- },
228
- disabled: currentVisitorId === x.visitorId,
229
- variant: "outlined",
230
- size: "small",
231
- color: "error",
232
- onClick: () => logout({ visitorId: x.visitorId }),
233
- children: x.status === "expired" ? t("remove") : currentVisitorId === x.visitorId ? t("currentSession") : t("logout")
234
- }
235
- ) });
236
- }
237
- }
238
- }
239
- ].filter(Boolean);
240
- return /* @__PURE__ */ jsxs(
241
- Box,
242
- {
243
- sx: {
244
- ".MuiTableCell-head": {
245
- whiteSpace: "nowrap",
246
- fontWeight: "bold"
247
- }
248
- },
249
- children: [
250
- confirmHolder,
251
- /* @__PURE__ */ jsx(
252
- Datatable,
253
- {
254
- locale,
255
- data: safeData,
256
- columns,
257
- customButtons,
258
- options: tableOptions,
259
- loading: pageState.loading
260
- }
261
- )
262
- ]
263
- }
264
- );
265
- }
@@ -1 +0,0 @@
1
- export { default as UserSessions } from './components/user-sessions';
@@ -1 +0,0 @@
1
- export { default as UserSessions } from "./components/user-sessions.js";
@@ -1,58 +0,0 @@
1
- export declare const translations: {
2
- zh: {
3
- confirm: string;
4
- cancel: string;
5
- visitorId: string;
6
- deviceType: string;
7
- platform: string;
8
- walletOS: string;
9
- role: string;
10
- fullname: string;
11
- email: string;
12
- avatar: string;
13
- user: string;
14
- createdAt: string;
15
- updatedAt: string;
16
- lastLoginIp: string;
17
- actions: string;
18
- logoutAll: string;
19
- logoutAllTips: string;
20
- logout: string;
21
- currentSession: string;
22
- unknown: string;
23
- expired: string;
24
- remove: string;
25
- logoutThisSession: string;
26
- logoutThisSessionConfirm: string;
27
- logoutAllSession: string;
28
- logoutAllSessionConfirm: string;
29
- };
30
- en: {
31
- confirm: string;
32
- cancel: string;
33
- visitorId: string;
34
- deviceType: string;
35
- platform: string;
36
- walletOS: string;
37
- role: string;
38
- fullname: string;
39
- email: string;
40
- avatar: string;
41
- user: string;
42
- createdAt: string;
43
- updatedAt: string;
44
- actions: string;
45
- lastLoginIp: string;
46
- logoutAll: string;
47
- logoutAllTips: string;
48
- logout: string;
49
- currentSession: string;
50
- unknown: string;
51
- expired: string;
52
- remove: string;
53
- logoutThisSession: string;
54
- logoutThisSessionConfirm: string;
55
- logoutAllSession: string;
56
- logoutAllSessionConfirm: string;
57
- };
58
- };
@@ -1,58 +0,0 @@
1
- export const translations = {
2
- zh: {
3
- confirm: "\u786E\u8BA4",
4
- cancel: "\u53D6\u6D88",
5
- visitorId: "\u8BBE\u5907\u6807\u8BC6",
6
- deviceType: "\u8BBE\u5907\u7C7B\u578B",
7
- platform: "\u64CD\u4F5C\u7CFB\u7EDF",
8
- walletOS: "\u94B1\u5305\u7C7B\u578B",
9
- role: "\u89D2\u8272",
10
- fullname: "\u59D3\u540D",
11
- email: "\u90AE\u7BB1",
12
- avatar: "\u5934\u50CF",
13
- user: "\u7528\u6237",
14
- createdAt: "\u9996\u6B21\u6D3B\u52A8\u65F6\u95F4",
15
- updatedAt: "\u6700\u8FD1\u6D3B\u52A8\u65F6\u95F4",
16
- lastLoginIp: "\u6700\u8FD1\u6D3B\u52A8\u5730\u5740",
17
- actions: "\u64CD\u4F5C",
18
- logoutAll: "\u6CE8\u9500\u6240\u6709\u4F1A\u8BDD",
19
- logoutAllTips: "\u4E0D\u4F1A\u6CE8\u9500\u5F53\u524D\u4F1A\u8BDD",
20
- logout: "\u6CE8\u9500",
21
- currentSession: "\u5F53\u524D\u4F1A\u8BDD",
22
- unknown: "\u672A\u77E5",
23
- expired: "\u5DF2\u8FC7\u671F",
24
- remove: "\u5220\u9664",
25
- logoutThisSession: "\u6CE8\u9500\u6307\u5B9A\u4F1A\u8BDD",
26
- logoutThisSessionConfirm: "\u786E\u5B9A\u8981\u6CE8\u9500\u6B64\u4F1A\u8BDD\u5417?",
27
- logoutAllSession: "\u6CE8\u9500\u6240\u6709\u4F1A\u8BDD",
28
- logoutAllSessionConfirm: "\u786E\u5B9A\u8981\u6CE8\u9500\u6240\u6709\u4F1A\u8BDD\u5417?"
29
- },
30
- en: {
31
- confirm: "Confirm",
32
- cancel: "Cancel",
33
- visitorId: "Device ID",
34
- deviceType: "Device Type",
35
- platform: "Platform",
36
- walletOS: "Wallet OS",
37
- role: "Role",
38
- fullname: "Fullname",
39
- email: "Email",
40
- avatar: "Avatar",
41
- user: "User",
42
- createdAt: "First Active Time",
43
- updatedAt: "Last Active Time",
44
- actions: "Actions",
45
- lastLoginIp: "Last Login IP",
46
- logoutAll: "Logout all",
47
- logoutAllTips: "Will not logout current session",
48
- logout: "Logout",
49
- currentSession: "Current Session",
50
- unknown: "Unknown",
51
- expired: "Expired",
52
- remove: "Remove",
53
- logoutThisSession: "Logout this session",
54
- logoutThisSessionConfirm: "Are you sure to logout this session?",
55
- logoutAllSession: "Logout all sessions",
56
- logoutAllSessionConfirm: "Are you sure to logout all sessions?"
57
- }
58
- };
@@ -1,2 +0,0 @@
1
- export declare function ip2Region(ip: string): Promise<string>;
2
- export declare function batchIp2Region(ips: string[]): Promise<string[]>;
@@ -1,73 +0,0 @@
1
- const RESERVED_IP = "Reserved IP";
2
- const IP_REGION_CACHE = "ip-region-cache";
3
- async function getIpRegionFromIpApi(ip) {
4
- const url = `https://ipapi.co/${ip}/json/`;
5
- const result = await fetch(url);
6
- const data = await result.json();
7
- let region = "";
8
- if (data.error) {
9
- if (data.reserved) {
10
- region = RESERVED_IP;
11
- }
12
- } else {
13
- region = [data.country_name, data.region, data.city].filter(Boolean).join("/");
14
- }
15
- return region;
16
- }
17
- async function getIpRegionFromIpSb(ip) {
18
- const url = `https://api.ip.sb/geoip/${ip}`;
19
- const result = await fetch(url);
20
- const data = await result.json();
21
- let region = "";
22
- if (data.error) {
23
- if (data.reserved) {
24
- region = RESERVED_IP;
25
- }
26
- } else {
27
- region = [data.country, data.region, data.city].filter(Boolean).join("/");
28
- }
29
- return region;
30
- }
31
- export async function ip2Region(ip) {
32
- let region = "";
33
- let ipRegionCache = {};
34
- try {
35
- const tmpCache = localStorage.getItem(IP_REGION_CACHE);
36
- if (tmpCache) {
37
- ipRegionCache = JSON.parse(tmpCache);
38
- }
39
- } catch {
40
- ipRegionCache = {};
41
- }
42
- if (ipRegionCache[ip]) {
43
- region = ipRegionCache[ip];
44
- } else {
45
- try {
46
- region = await getIpRegionFromIpSb(ip);
47
- } catch {
48
- console.warn("Fail to get ip region from ip.sb");
49
- }
50
- if (!region) {
51
- try {
52
- region = await getIpRegionFromIpApi(ip);
53
- } catch {
54
- console.warn("Fail to get ip region from ip-api.co");
55
- }
56
- }
57
- }
58
- if (region) {
59
- const ipList = Object.keys(ipRegionCache);
60
- if (ipList.length > 100) {
61
- delete ipRegionCache[ipList[0]];
62
- }
63
- if (ipRegionCache[ip]) {
64
- delete ipRegionCache[ip];
65
- }
66
- ipRegionCache[ip] = region;
67
- localStorage.setItem(IP_REGION_CACHE, JSON.stringify(ipRegionCache));
68
- }
69
- return region;
70
- }
71
- export async function batchIp2Region(ips) {
72
- return Promise.all(ips.map((ip) => ip2Region(ip)));
73
- }
package/es/blocklets.d.ts DELETED
@@ -1,16 +0,0 @@
1
- export const publicPath: any;
2
- export function formatTheme(theme: any): any;
3
- export function getLocalizedNavigation(navigation: any, locale?: string): any;
4
- export function formatNavigation(navigation: any): any;
5
- export function parseNavigation(navigation: any): {
6
- header: never[];
7
- footer: never[];
8
- social: never[];
9
- bottom: never[];
10
- dashboard: never[];
11
- sessionManager: never[];
12
- userCenter: never[];
13
- } | null;
14
- export function formatBlockletInfo(blockletInfo: any): any;
15
- export function filterValidNavItems(navigation?: any[]): any;
16
- export function filterNavByRole(nav: object[], userRole: string): any;