@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,22 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- module.exports = InstallerItem;
7
- var _jsxRuntime = require("react/jsx-runtime");
8
- var _Colors = require("@arcblock/ux/lib/Colors");
9
- var _react = require("@iconify/react");
10
- var _material = require("@mui/material");
11
- var _propTypes = _interopRequireDefault(require("prop-types"));
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
- function InstallerItem({
14
- optionalComponent,
15
- index,
16
- installStatus,
17
- hasPermission,
18
- t
19
- }) {
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { temp as colors } from "@arcblock/ux/lib/Colors";
3
+ import { Icon } from "@iconify/react";
4
+ import { Box, Button } from "@mui/material";
5
+ import PropTypes from "prop-types";
6
+ export default function InstallerItem({ optionalComponent, index, installStatus, hasPermission, t }) {
20
7
  const handleInstall = () => {
21
8
  window.open(optionalComponent?.installUrl, "_blank");
22
9
  };
@@ -28,134 +15,125 @@ function InstallerItem({
28
15
  };
29
16
  const installStatusDone = installStatus === "stopped" || installStatus === "running";
30
17
  const size = 60;
31
- return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
32
- children: [index === 0 ? null : /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
33
- sx: {
34
- width: "100%",
35
- height: "1px",
36
- backgroundColor: _Colors.temp.gray6
37
- }
38
- }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
39
- sx: {
40
- padding: "20px 24px",
41
- paddingTop: 0.5,
42
- marginTop: 2,
43
- display: "flex",
44
- flexDirection: "row",
45
- justifyContent: "start",
46
- alignItems: "flex-start"
47
- },
48
- children: [/* @__PURE__ */(0, _jsxRuntime.jsx)("img", {
49
- style: {
50
- width: size,
51
- height: size,
52
- minWidth: size,
53
- minHeight: size
54
- },
55
- src: optionalComponent.logoUrl,
56
- alt: optionalComponent.meta.title
57
- }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
18
+ return /* @__PURE__ */ jsxs(Box, { children: [
19
+ index === 0 ? null : /* @__PURE__ */ jsx(Box, { sx: { width: "100%", height: "1px", backgroundColor: colors.gray6 } }),
20
+ /* @__PURE__ */ jsxs(
21
+ Box,
22
+ {
58
23
  sx: {
24
+ padding: "20px 24px",
25
+ paddingTop: 0.5,
26
+ marginTop: 2,
59
27
  display: "flex",
60
- flexDirection: "column",
28
+ flexDirection: "row",
61
29
  justifyContent: "start",
62
- alignItems: "start",
63
- marginLeft: 2
30
+ alignItems: "flex-start"
64
31
  },
65
- children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
66
- sx: {
67
- fontSize: "16px",
68
- fontWeight: "bold",
69
- cursor: "pointer",
70
- ".link-icon": {
71
- opacity: 0
72
- },
73
- ":hover .link-icon": {
74
- opacity: 1
32
+ children: [
33
+ /* @__PURE__ */ jsx(
34
+ "img",
35
+ {
36
+ style: { width: size, height: size, minWidth: size, minHeight: size },
37
+ src: optionalComponent.logoUrl,
38
+ alt: optionalComponent.meta.title
75
39
  }
76
- },
77
- onClick: () => handleOpenStore(optionalComponent.meta?.did),
78
- children: [optionalComponent.meta.title, /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
79
- sx: {
80
- paddingLeft: 1,
81
- fontSize: "13px",
82
- fontWeight: "400"
83
- },
84
- component: "span",
85
- children: [optionalComponent.meta.version, /* @__PURE__ */(0, _jsxRuntime.jsx)(_react.Icon, {
86
- className: "link-icon",
87
- icon: "fluent:open-20-filled",
88
- style: {
89
- color: _Colors.temp.primaryBase,
90
- fontSize: 16,
91
- transform: "translate(6px, 3px)",
92
- transition: "all 0.3s"
93
- }
94
- })]
95
- })]
96
- }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
97
- sx: {
98
- marginTop: 0,
99
- opacity: 0.7
100
- },
101
- children: optionalComponent.meta.description
102
- }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
103
- sx: {
104
- display: hasPermission ? "flex" : "none",
105
- flexDirection: "row",
106
- gap: 1
107
- },
108
- children: installStatus ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
109
- sx: {
110
- marginTop: 2,
111
- opacity: 0.7
112
- },
113
- children: installStatusDone ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
114
- variant: "contained",
115
- onClick: handleRefresh,
116
- children: t("componentInstallerRefresh")
117
- }, "refresh") : /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
118
- disabled: true,
40
+ ),
41
+ /* @__PURE__ */ jsxs(
42
+ Box,
43
+ {
119
44
  sx: {
120
- color: "#333"
45
+ display: "flex",
46
+ flexDirection: "column",
47
+ justifyContent: "start",
48
+ alignItems: "start",
49
+ marginLeft: 2
121
50
  },
122
- startIcon: /* @__PURE__ */(0, _jsxRuntime.jsx)(_react.Icon, {
123
- icon: "line-md:loading-loop",
124
- style: {
125
- color: "#333",
126
- fontSize: 16
127
- }
128
- }),
129
- variant: "contained",
130
- children: installStatus
131
- }, "status")
132
- }) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
133
- sx: {
134
- marginTop: 2
135
- },
136
- variant: "contained",
137
- className: "button",
138
- onClick: () => handleInstall(optionalComponent.meta?.did),
139
- children: t("componentInstallerInstall")
140
- }, "install")
141
- }), installStatusDone ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
142
- sx: {
143
- marginTop: 2,
144
- opacity: 0.7
145
- },
146
- children: t("componentInstallerSuccessInstalled")
147
- }) : null]
148
- })]
149
- })]
150
- });
51
+ children: [
52
+ /* @__PURE__ */ jsxs(
53
+ Box,
54
+ {
55
+ sx: {
56
+ fontSize: "16px",
57
+ fontWeight: "bold",
58
+ cursor: "pointer",
59
+ ".link-icon": {
60
+ opacity: 0
61
+ },
62
+ ":hover .link-icon": {
63
+ opacity: 1
64
+ }
65
+ },
66
+ onClick: () => handleOpenStore(optionalComponent.meta?.did),
67
+ children: [
68
+ optionalComponent.meta.title,
69
+ /* @__PURE__ */ jsxs(
70
+ Box,
71
+ {
72
+ sx: {
73
+ paddingLeft: 1,
74
+ fontSize: "13px",
75
+ fontWeight: "400"
76
+ },
77
+ component: "span",
78
+ children: [
79
+ optionalComponent.meta.version,
80
+ /* @__PURE__ */ jsx(
81
+ Icon,
82
+ {
83
+ className: "link-icon",
84
+ icon: "fluent:open-20-filled",
85
+ style: {
86
+ color: colors.primaryBase,
87
+ fontSize: 16,
88
+ transform: "translate(6px, 3px)",
89
+ transition: "all 0.3s"
90
+ }
91
+ }
92
+ )
93
+ ]
94
+ }
95
+ )
96
+ ]
97
+ }
98
+ ),
99
+ /* @__PURE__ */ jsx(Box, { sx: { marginTop: 0, opacity: 0.7 }, children: optionalComponent.meta.description }),
100
+ /* @__PURE__ */ jsx(Box, { sx: { display: hasPermission ? "flex" : "none", flexDirection: "row", gap: 1 }, children: installStatus ? /* @__PURE__ */ jsx(Box, { sx: { marginTop: 2, opacity: 0.7 }, children: installStatusDone ? /* @__PURE__ */ jsx(Button, { variant: "contained", onClick: handleRefresh, children: t("componentInstallerRefresh") }, "refresh") : /* @__PURE__ */ jsx(
101
+ Button,
102
+ {
103
+ disabled: true,
104
+ sx: { color: "#333" },
105
+ startIcon: /* @__PURE__ */ jsx(Icon, { icon: "line-md:loading-loop", style: { color: "#333", fontSize: 16 } }),
106
+ variant: "contained",
107
+ children: installStatus
108
+ },
109
+ "status"
110
+ ) }) : /* @__PURE__ */ jsx(
111
+ Button,
112
+ {
113
+ sx: { marginTop: 2 },
114
+ variant: "contained",
115
+ className: "button",
116
+ onClick: () => handleInstall(optionalComponent.meta?.did),
117
+ children: t("componentInstallerInstall")
118
+ },
119
+ "install"
120
+ ) }),
121
+ installStatusDone ? /* @__PURE__ */ jsx(Box, { sx: { marginTop: 2, opacity: 0.7 }, children: t("componentInstallerSuccessInstalled") }) : null
122
+ ]
123
+ }
124
+ )
125
+ ]
126
+ }
127
+ )
128
+ ] });
151
129
  }
152
130
  InstallerItem.propTypes = {
153
- t: _propTypes.default.func.isRequired,
154
- optionalComponent: _propTypes.default.object.isRequired,
155
- index: _propTypes.default.number.isRequired,
156
- installStatus: _propTypes.default.string,
157
- hasPermission: _propTypes.default.bool.isRequired
131
+ t: PropTypes.func.isRequired,
132
+ optionalComponent: PropTypes.object.isRequired,
133
+ index: PropTypes.number.isRequired,
134
+ installStatus: PropTypes.string,
135
+ hasPermission: PropTypes.bool.isRequired
158
136
  };
159
137
  InstallerItem.defaultProps = {
160
138
  installStatus: ""
161
- };
139
+ };
@@ -1,9 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
1
  const translations = {
8
2
  zh: {
9
3
  componentInstallerTitle: '缺少组件',
@@ -12,7 +6,7 @@ const translations = {
12
6
  componentInstallerRefresh: '重载页面',
13
7
  componentInstallerSuccessInstalled: '安装成功,请重载页面查看变化。',
14
8
  componentInstallerSuggestions: '请联系系统管理员安装该组件。',
15
- componentInstallerNoDefinedInBlockletYML: '组件未在 blocklet.yml 中定义'
9
+ componentInstallerNoDefinedInBlockletYML: '组件未在 blocklet.yml 中定义',
16
10
  },
17
11
  en: {
18
12
  componentInstallerTitle: 'Missing component',
@@ -21,7 +15,8 @@ const translations = {
21
15
  componentInstallerRefresh: 'Refresh',
22
16
  componentInstallerSuccessInstalled: 'Successfully installed, please refresh the page to see the changes.',
23
17
  componentInstallerSuggestions: 'Please contact the system administrator to install the component.',
24
- componentInstallerNoDefinedInBlockletYML: 'The component is not defined in blocklet.yml'
25
- }
18
+ componentInstallerNoDefinedInBlockletYML: 'The component is not defined in blocklet.yml',
19
+ },
26
20
  };
27
- module.exports = translations;
21
+
22
+ export default translations;
@@ -1,72 +1,65 @@
1
- "use strict";
1
+ import { AUTH_SERVICE_PREFIX } from '@arcblock/did-connect/lib/constant';
2
+ import { useEffect, useMemo, useRef, useState } from 'react';
3
+ import { joinURL } from 'ufo';
2
4
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _constant = require("@arcblock/did-connect/lib/constant");
8
- var _react = require("react");
9
- var _ufo = require("ufo");
10
- const parseDidToSet = did => {
5
+ const parseDidToSet = (did) => {
11
6
  if (typeof did === 'string') {
12
7
  return new Set(did.split(';;'));
13
8
  }
14
9
  return new Set(did);
15
10
  };
16
- function useComponentInstalled({
17
- did,
18
- onInstalled,
19
- onError
20
- }) {
11
+
12
+ function useComponentInstalled({ did, onInstalled, onError }) {
21
13
  const didKeys = Array.isArray(did) ? did.join(';;') : did;
22
- const [installStatus, setInstallStatus] = (0, _react.useState)({});
23
- const onInstalledRef = (0, _react.useRef)({
24
- onInstalled,
25
- onError
26
- });
27
- onInstalledRef.current = {
28
- onInstalled,
29
- onError
30
- };
31
- const {
32
- optionalComponents,
33
- componentMountPoints
34
- } = window.blocklet;
35
- const optComponents = (0, _react.useMemo)(() => {
14
+ const [installStatus, setInstallStatus] = useState({});
15
+ const onInstalledRef = useRef({ onInstalled, onError });
16
+ onInstalledRef.current = { onInstalled, onError };
17
+
18
+ const { optionalComponents, componentMountPoints } = window.blocklet;
19
+
20
+ const optComponents = useMemo(() => {
36
21
  if (!optionalComponents || !optionalComponents.length) {
37
22
  return [];
38
23
  }
39
24
  const didSet = parseDidToSet(didKeys);
40
- const components = optionalComponents.filter(c => didSet.has(c.meta.did));
25
+ const components = optionalComponents.filter((c) => didSet.has(c.meta.did));
41
26
  (components ? onInstalledRef.current.onError : onInstalledRef.current.onInstalled)?.(components);
42
27
  return components;
43
28
  }, [didKeys, optionalComponents]);
44
- const definedInBlockletYML = (0, _react.useMemo)(() => {
29
+
30
+ const definedInBlockletYML = useMemo(() => {
45
31
  if (optComponents.length) {
46
32
  return true;
47
33
  }
48
34
  const didSet = parseDidToSet(didKeys);
49
- return (componentMountPoints || []).find(item => didSet.has(item.did));
35
+ return (componentMountPoints || []).find((item) => didSet.has(item.did));
50
36
  }, [optComponents, componentMountPoints, didKeys]);
51
- optComponents.forEach(item => {
52
- item.storeUrl = (0, _ufo.joinURL)(item.meta.homepage, 'blocklets', item.meta.did);
53
- item.installUrl = (0, _ufo.joinURL)(window.blocklet.appUrl, _constant.AUTH_SERVICE_PREFIX, `/admin/components?install-component=${item.meta.did}`);
37
+
38
+ optComponents.forEach((item) => {
39
+ item.storeUrl = joinURL(item.meta.homepage, 'blocklets', item.meta.did);
40
+ item.installUrl = joinURL(
41
+ window.blocklet.appUrl,
42
+ AUTH_SERVICE_PREFIX,
43
+ `/admin/components?install-component=${item.meta.did}`
44
+ );
54
45
  });
55
- (0, _react.useEffect)(() => {
56
- const handle = event => {
46
+
47
+ useEffect(() => {
48
+ const handle = (event) => {
57
49
  if (event.origin !== window.blocklet.appUrl) {
58
50
  return;
59
51
  }
52
+
60
53
  if (event.data?.kind === 'component-installer' && event.data?.blocklet?.children) {
61
54
  let hasChild = false;
62
55
  const didSet = parseDidToSet(didKeys);
63
- event.data?.blocklet?.children.forEach(item => {
56
+ event.data?.blocklet?.children.forEach((item) => {
64
57
  if (didSet.has(item.meta?.did)) {
65
58
  hasChild = true;
66
- setInstallStatus(value => {
59
+ setInstallStatus((value) => {
67
60
  return {
68
61
  ...value,
69
- [item.meta?.did]: item.status || 'waiting'
62
+ [item.meta?.did]: item.status || 'waiting',
70
63
  };
71
64
  });
72
65
  }
@@ -76,17 +69,20 @@ function useComponentInstalled({
76
69
  }
77
70
  }
78
71
  };
72
+
79
73
  window.addEventListener('message', handle);
80
74
  return () => {
81
75
  window.removeEventListener('message', handle);
82
76
  };
83
77
  }, [didKeys]);
78
+
84
79
  return {
85
80
  optComponents,
86
81
  installed: !optComponents.length && definedInBlockletYML,
87
82
  installStatus,
88
83
  setInstallStatus,
89
- definedInBlockletYML
84
+ definedInBlockletYML,
90
85
  };
91
86
  }
92
- module.exports = useComponentInstalled;
87
+
88
+ export default useComponentInstalled;
@@ -1,23 +1,16 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- module.exports = AddComponent;
7
- var _jsxRuntime = require("react/jsx-runtime");
8
- var _react = require("react");
9
- var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
10
- var _context = require("@arcblock/ux/lib/Locale/context");
11
- var _constant = require("@arcblock/ux/lib/Util/constant");
12
- var _ahooks = require("ahooks");
13
- var _util = require("@arcblock/ux/lib/Locale/util");
14
- var _ufo = require("ufo");
15
- var _Session = require("@arcblock/did-connect/lib/Session");
16
- var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
17
- var _resourceDialog = _interopRequireDefault(require("./resource-dialog"));
18
- var _locales = require("../libs/locales");
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
- function AddComponent({
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useContext } from "react";
3
+ import Button from "@arcblock/ux/lib/Button";
4
+ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
5
+ import { WELLKNOWN_SERVICE_PATH_PREFIX } from "@arcblock/ux/lib/Util/constant";
6
+ import { useMemoizedFn, useReactive } from "ahooks";
7
+ import { translate } from "@arcblock/ux/lib/Locale/util";
8
+ import { joinURL, withQuery } from "ufo";
9
+ import { SessionContext } from "@arcblock/did-connect/lib/Session";
10
+ import Toast from "@arcblock/ux/lib/Toast";
11
+ import ResourceDialog from "./resource-dialog.js";
12
+ import { translations } from "../libs/locales.js";
13
+ export default function AddComponent({
21
14
  componentDid,
22
15
  resourceType,
23
16
  resourceDid,
@@ -29,21 +22,17 @@ function AddComponent({
29
22
  onClose,
30
23
  render
31
24
  }) {
32
- const {
33
- session
34
- } = (0, _react.useContext)(_Session.SessionContext);
35
- const {
36
- locale
37
- } = (0, _context.useLocaleContext)();
38
- const t = (0, _ahooks.useMemoizedFn)((key, data = {}) => {
39
- return (0, _util.translate)(_locales.translations, key, locale, "en", data);
25
+ const { session } = useContext(SessionContext);
26
+ const { locale } = useLocaleContext();
27
+ const t = useMemoizedFn((key, data = {}) => {
28
+ return translate(translations, key, locale, "en", data);
40
29
  });
41
- const refIframe = (0, _react.useRef)(null);
42
- const currentState = (0, _ahooks.useReactive)({
30
+ const refIframe = useRef(null);
31
+ const currentState = useReactive({
43
32
  loading: false,
44
33
  showDialog: false
45
34
  });
46
- const importUrl = (0, _ufo.withQuery)((0, _ufo.joinURL)(_constant.WELLKNOWN_SERVICE_PATH_PREFIX, "embed/resources", componentDid, "add"), {
35
+ const importUrl = withQuery(joinURL(WELLKNOWN_SERVICE_PATH_PREFIX, "embed/resources", componentDid, "add"), {
47
36
  resourceDid,
48
37
  resourceType,
49
38
  mode: "dialog",
@@ -52,72 +41,74 @@ function AddComponent({
52
41
  enableRunBackground: "false",
53
42
  showCategory: "false"
54
43
  });
55
- const handleClose = (0, _ahooks.useMemoizedFn)(() => {
44
+ const handleClose = useMemoizedFn(() => {
56
45
  currentState.showDialog = false;
57
46
  onClose?.();
58
47
  });
59
- const handleComplete = (0, _ahooks.useMemoizedFn)(() => {
48
+ const handleComplete = useMemoizedFn(() => {
60
49
  currentState.showDialog = false;
61
50
  onComplete?.();
62
51
  });
63
- const handleOpen = (0, _ahooks.useMemoizedFn)(() => {
52
+ const handleOpen = useMemoizedFn(() => {
64
53
  if (!session.user) {
65
- _Toast.default.warning(t("needLogin"));
54
+ Toast.warning(t("needLogin"));
66
55
  return;
67
56
  }
68
57
  if (!grantedRoles.includes(session.user?.role)) {
69
- _Toast.default.warning(t("noPermission"));
58
+ Toast.warning(t("noPermission"));
70
59
  return;
71
60
  }
72
61
  currentState.loading = true;
73
62
  currentState.showDialog = true;
74
63
  });
75
- const handleLoad = (0, _ahooks.useMemoizedFn)(() => {
64
+ const handleLoad = useMemoizedFn(() => {
76
65
  currentState.loading = false;
77
66
  if (refIframe.current) {
78
67
  refIframe.current?.selectBlocklet(selectedMeta);
79
68
  }
80
69
  });
81
- const handleIframeMessage = (0, _ahooks.useMemoizedFn)(event => {
70
+ const handleIframeMessage = useMemoizedFn((event) => {
82
71
  if (event?.data?.event === "component.installed" && event.data.componentDid === componentDid) {
83
72
  if (autoClose || event.data.manual) {
84
73
  handleComplete();
85
74
  }
86
75
  }
87
76
  });
88
- (0, _react.useEffect)(() => {
77
+ useEffect(() => {
89
78
  if (currentState.showDialog) {
90
79
  window.addEventListener("message", handleIframeMessage);
91
80
  } else {
92
81
  window.removeEventListener("message", handleIframeMessage);
93
82
  }
94
83
  }, [currentState.showDialog]);
95
- return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
96
- children: [render ? render({
97
- onClick: handleOpen,
98
- loading: currentState.loading
99
- }) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_Button.default, {
100
- variant: "outlined",
101
- color: "secondary",
102
- type: "button",
103
- className: "submit",
104
- onClick: handleOpen,
105
- loading: currentState.loading,
106
- sx: {
107
- mr: 1,
108
- ml: 1
84
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
85
+ render ? render({ onClick: handleOpen, loading: currentState.loading }) : /* @__PURE__ */ jsx(
86
+ Button,
87
+ {
88
+ variant: "outlined",
89
+ color: "secondary",
90
+ type: "button",
91
+ className: "submit",
92
+ onClick: handleOpen,
93
+ loading: currentState.loading,
94
+ sx: { mr: 1, ml: 1 },
95
+ children: t("importResource")
109
96
  },
110
- children: t("importResource")
111
- }, "button"), currentState.showDialog && /* @__PURE__ */(0, _jsxRuntime.jsx)(_resourceDialog.default, {
112
- ref: refIframe,
113
- src: importUrl,
114
- storeUrl,
115
- open: true,
116
- componentDid,
117
- loading: currentState.loading,
118
- onClose: handleClose,
119
- onComplete: handleComplete,
120
- onLoad: handleLoad
121
- })]
122
- });
123
- }
97
+ "button"
98
+ ),
99
+ currentState.showDialog && /* @__PURE__ */ jsx(
100
+ ResourceDialog,
101
+ {
102
+ ref: refIframe,
103
+ src: importUrl,
104
+ storeUrl,
105
+ open: true,
106
+ componentDid,
107
+ loading: currentState.loading,
108
+ onClose: handleClose,
109
+ onComplete: handleComplete,
110
+ onLoad: handleLoad
111
+ }
112
+ )
113
+ ] });
114
+ }
@@ -1,9 +1,2 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _ComponentInstaller = _interopRequireDefault(require("../../ComponentInstaller"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- module.exports = _ComponentInstaller.default;
1
+ import CheckComponent from "../../ComponentInstaller/index.js";
2
+ export default CheckComponent;