@abtnode/ux 1.16.14-beta-c308dc3b → 1.16.14-beta-963cb583

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 (213) hide show
  1. package/es/actions.js +97 -0
  2. package/es/analytics/card.js +92 -0
  3. package/es/analytics/chart.js +96 -0
  4. package/es/analytics/cpu.js +36 -0
  5. package/es/analytics/disk.js +111 -0
  6. package/es/analytics/memory.js +72 -0
  7. package/es/analytics/runtime.js +173 -0
  8. package/es/analytics/traffic.js +259 -0
  9. package/es/blocklet/access/config-access.js +307 -0
  10. package/es/blocklet/access/index.js +216 -0
  11. package/es/blocklet/actions.js +474 -0
  12. package/es/blocklet/add-cert.js +177 -0
  13. package/es/blocklet/agreement-app.js +21 -0
  14. package/es/blocklet/agreement.js +127 -0
  15. package/es/blocklet/app-avatar.js +57 -0
  16. package/es/blocklet/audit-logs.js +259 -0
  17. package/es/blocklet/blocklet-source.js +48 -0
  18. package/es/blocklet/bundle-avatar.js +64 -0
  19. package/es/blocklet/component/add.js +1313 -0
  20. package/es/blocklet/component/configuration.js +122 -0
  21. package/es/blocklet/component/delete.js +134 -0
  22. package/es/blocklet/component/environment.js +370 -0
  23. package/es/blocklet/component/index.js +975 -0
  24. package/es/blocklet/component/line.js +20 -0
  25. package/es/blocklet/component/navigation/locale-tabs.js +225 -0
  26. package/es/blocklet/component/navigation/navigation-actions.js +112 -0
  27. package/es/blocklet/component/navigation/navigation-dialog.js +607 -0
  28. package/es/blocklet/component/navigation/navigation-preview.js +101 -0
  29. package/es/blocklet/component/navigation/simple-select.js +124 -0
  30. package/es/blocklet/component/select-store.js +155 -0
  31. package/es/blocklet/component/selected/index.js +94 -0
  32. package/es/blocklet/component/setting.js +109 -0
  33. package/es/blocklet/component/sortable-tree.js +126 -0
  34. package/es/blocklet/component/space-connector.js +199 -0
  35. package/es/blocklet/component/space-selector.js +178 -0
  36. package/es/blocklet/component/start.js +101 -0
  37. package/es/blocklet/component/store-blocklet-list.js +200 -0
  38. package/es/blocklet/component/switch-control.js +57 -0
  39. package/es/blocklet/config-navigation.js +331 -0
  40. package/es/blocklet/configuration.js +603 -0
  41. package/es/blocklet/disk-info.js +75 -0
  42. package/es/blocklet/icons.js +18 -0
  43. package/es/blocklet/install-from-url.js +337 -0
  44. package/es/blocklet/log.js +90 -0
  45. package/es/blocklet/migration.js +149 -0
  46. package/es/blocklet/mode.js +19 -0
  47. package/es/blocklet/notification/email.js +257 -0
  48. package/es/blocklet/notification/index.js +49 -0
  49. package/es/blocklet/oauth/auth0.js +145 -0
  50. package/es/blocklet/oauth/common-settings.js +133 -0
  51. package/es/blocklet/oauth/federated-detail-dialog.js +175 -0
  52. package/es/blocklet/oauth/federated-invite-dialog.js +83 -0
  53. package/es/blocklet/oauth/federated-join-dialog.js +111 -0
  54. package/es/blocklet/oauth/federated-site-list.js +338 -0
  55. package/es/blocklet/oauth/federated.js +81 -0
  56. package/es/blocklet/oauth/index.js +69 -0
  57. package/es/blocklet/overview.js +293 -0
  58. package/es/blocklet/page-group.js +19 -0
  59. package/es/blocklet/preferences/app-sk.js +142 -0
  60. package/es/blocklet/preferences/index.js +305 -0
  61. package/es/blocklet/purchase/common.js +95 -0
  62. package/es/blocklet/purchase/component-purchase.js +237 -0
  63. package/es/blocklet/purchase/index.js +4 -0
  64. package/es/blocklet/router/action/add-domain-alias.js +167 -0
  65. package/es/blocklet/router/action/add-rule.js +211 -0
  66. package/es/blocklet/router/action/config-routing-rule.js +232 -0
  67. package/es/blocklet/router/action/delete-domain-alias.js +99 -0
  68. package/es/blocklet/router/action/delete-rule.js +108 -0
  69. package/es/blocklet/router/action/update-rule.js +209 -0
  70. package/es/blocklet/router/domain-actions.js +64 -0
  71. package/es/blocklet/router/domain-status.js +88 -0
  72. package/es/blocklet/router/rule-actions.js +66 -0
  73. package/es/blocklet/router/rule-list.js +190 -0
  74. package/es/blocklet/router/util.js +131 -0
  75. package/es/blocklet/runtime-info.js +68 -0
  76. package/es/blocklet/status.js +91 -0
  77. package/es/blocklet/storage/action.js +134 -0
  78. package/es/blocklet/storage/backups.js +241 -0
  79. package/es/blocklet/storage/connect-to.js +372 -0
  80. package/es/blocklet/storage/connected.js +198 -0
  81. package/es/blocklet/storage/delete.js +113 -0
  82. package/es/blocklet/storage/disconnect.js +243 -0
  83. package/es/blocklet/storage/index.js +19 -0
  84. package/es/blocklet/storage/item.js +558 -0
  85. package/es/blocklet/storage/preview-nft.js +286 -0
  86. package/es/blocklet/transfer-owner.js +198 -0
  87. package/es/blocklet/types.js +18 -0
  88. package/es/blocklet/util.js +145 -0
  89. package/es/blocklet/version.js +141 -0
  90. package/es/card-selector.js +134 -0
  91. package/es/certificate.js +105 -0
  92. package/es/chain.js +13 -0
  93. package/es/click-to-copy.js +22 -0
  94. package/es/confirm.js +149 -0
  95. package/es/contexts/audit-log.js +152 -0
  96. package/es/contexts/blocklet.js +10 -0
  97. package/es/contexts/deleting-blocklets.js +70 -0
  98. package/es/contexts/node.js +17 -0
  99. package/es/contexts/session.js +8 -0
  100. package/es/contexts/team.js +10 -0
  101. package/es/delete-confirm.js +121 -0
  102. package/es/did-address.js +46 -0
  103. package/es/dot.js +14 -0
  104. package/es/exchange-passport.js +102 -0
  105. package/es/form/form-select-input.js +184 -0
  106. package/es/form/form-text-input.js +178 -0
  107. package/es/form/form-wrapper.js +88 -0
  108. package/es/form/input-triggers.js +98 -0
  109. package/es/form/required.js +8 -0
  110. package/es/hooks/blocklet.js +229 -0
  111. package/es/hooks/confirm.js +90 -0
  112. package/es/hooks/mobile-width.js +11 -0
  113. package/es/hooks/url-evaluation.js +155 -0
  114. package/es/hooks/use-app-logo.js +16 -0
  115. package/es/hooks/use-backup-progress.js +31 -0
  116. package/es/hooks/use-blocklet-info-for-connect-did-spaces.js +50 -0
  117. package/es/hooks/use-bundle-logo.js +27 -0
  118. package/es/hooks/use-navigation.js +347 -0
  119. package/es/hooks/use-passport-id.js +14 -0
  120. package/es/hooks/use-subscription.js +22 -0
  121. package/es/icons/empty-space-nft.svg +59 -0
  122. package/es/icons/empty-spaces-nft.svg +58 -0
  123. package/es/icons/long-arrow.svg +5 -0
  124. package/es/icons/space-connected.svg +3 -0
  125. package/es/icons/space-disconnect.svg +3 -0
  126. package/es/index.js +3 -0
  127. package/es/invitation/invitation-app.js +58 -0
  128. package/es/invitation/invitation-login.js +68 -0
  129. package/es/invitation/invitation-passport.js +146 -0
  130. package/es/invitation/invitation-receive.js +138 -0
  131. package/es/invitation/invitation-success.js +93 -0
  132. package/es/invitation/invitation-user.js +90 -0
  133. package/es/invitation/invitation.js +90 -0
  134. package/es/issue-passport.js +142 -0
  135. package/es/launch-blocklet/content-layout.js +58 -0
  136. package/es/launch-blocklet/page-header.js +43 -0
  137. package/es/layout/addon.js +114 -0
  138. package/es/layout/feedback.js +55 -0
  139. package/es/locales/en.js +1541 -0
  140. package/es/locales/index.js +9 -0
  141. package/es/locales/zh.js +1544 -0
  142. package/es/logs/clock.js +11 -0
  143. package/es/logs/download.js +132 -0
  144. package/es/logs/log-terminal.js +253 -0
  145. package/es/lost-passport.js +452 -0
  146. package/es/nav-logo.js +219 -0
  147. package/es/passport-tag.js +43 -0
  148. package/es/permission.js +57 -0
  149. package/es/relative-time.js +53 -0
  150. package/es/result-message.js +11 -0
  151. package/es/schema-form/color-input.js +98 -0
  152. package/es/schema-form/common-prop-types.js +13 -0
  153. package/es/schema-form/index.js +215 -0
  154. package/es/schema-form/passport-input.js +55 -0
  155. package/es/schema-form/text-input.js +57 -0
  156. package/es/store/add.js +179 -0
  157. package/es/store/delete.js +96 -0
  158. package/es/store/item.js +76 -0
  159. package/es/subscription.js +144 -0
  160. package/es/table-icons.js +34 -0
  161. package/es/table.js +52 -0
  162. package/es/tag.js +21 -0
  163. package/es/team/members/actions.js +89 -0
  164. package/es/team/members/index.js +636 -0
  165. package/es/team/members/invitations.js +188 -0
  166. package/es/team/members/invite-member.js +208 -0
  167. package/es/team/members/issue-passport.js +152 -0
  168. package/es/team/members/member.js +408 -0
  169. package/es/team/members/passport-issuances.js +155 -0
  170. package/es/team/members/passports.js +364 -0
  171. package/es/team/members/toggle-user-approval.js +122 -0
  172. package/es/team/members/transfer-node.js +256 -0
  173. package/es/team/members/util.js +14 -0
  174. package/es/team/passports/color.js +127 -0
  175. package/es/team/passports/detail.js +312 -0
  176. package/es/team/passports/index.js +282 -0
  177. package/es/team/passports/mutate-role.js +198 -0
  178. package/es/team/passports/trusted-factories.js +221 -0
  179. package/es/team/passports/trusted-factory.js +343 -0
  180. package/es/team/passports/trusted-issuer.js +296 -0
  181. package/es/team/passports/trusted-issuers.js +226 -0
  182. package/es/team/search-input.js +46 -0
  183. package/es/team/styles/dialog.js +72 -0
  184. package/es/team/styles/list-header.js +31 -0
  185. package/es/util/api.js +6 -0
  186. package/es/util/constants.js +2 -0
  187. package/es/util/index.js +598 -0
  188. package/es/util/mode.js +4 -0
  189. package/es/util/space-gateway.js +51 -0
  190. package/es/util/spaces.js +160 -0
  191. package/es/who-can-access/config.js +38 -0
  192. package/es/wrap-locale.js +15 -0
  193. package/lib/blocklet/component/add.js +5 -0
  194. package/lib/blocklet/component/selected/index.js +47 -0
  195. package/lib/blocklet/component/space-connector.js +1 -1
  196. package/lib/blocklet/component/space-selector.js +1 -1
  197. package/lib/blocklet/storage/backups.js +1 -1
  198. package/lib/blocklet/storage/connect-to.js +6 -7
  199. package/lib/blocklet/storage/connected.js +1 -1
  200. package/lib/blocklet/storage/disconnect.js +1 -1
  201. package/lib/blocklet/storage/index.js +1 -1
  202. package/lib/blocklet/storage/item.js +1 -1
  203. package/lib/card-selector.js +14 -14
  204. package/lib/invitation/invitation-passport.js +7 -6
  205. package/lib/invitation/invitation-receive.js +1 -1
  206. package/lib/locales/en.js +12 -5
  207. package/lib/locales/zh.js +10 -3
  208. package/lib/lost-passport.js +2 -2
  209. package/lib/schema-form/passport-input.js +12 -11
  210. package/lib/team/passports/color.js +14 -14
  211. package/lib/team/passports/trusted-factory.js +1 -1
  212. package/lib/util/spaces.js +13 -1
  213. package/package.json +88 -21
@@ -0,0 +1,152 @@
1
+ import { createContext, useState, useContext, useEffect } from 'react';
2
+ import useLocalStorage from 'react-use/lib/useLocalStorage';
3
+ import Toast from '@arcblock/ux/lib/Toast';
4
+ import { useNodeContext } from './node';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const AuditLogContext = /*#__PURE__*/createContext({});
7
+ const {
8
+ Provider,
9
+ Consumer
10
+ } = AuditLogContext;
11
+
12
+ // eslint-disable-next-line react/prop-types
13
+ function AuditLogProvider({
14
+ children,
15
+ scope = '',
16
+ categories = [],
17
+ showScope,
18
+ scopeFormatter
19
+ }) {
20
+ const {
21
+ api: client,
22
+ info: nodeInfo
23
+ } = useNodeContext();
24
+ const [auditLogs, setAuditLogs] = useState([]);
25
+ const [paging, setPaging] = useState({
26
+ total: 0,
27
+ pageSize: 20,
28
+ pageCount: 0,
29
+ page: 1
30
+ });
31
+ const [loading, setLoading] = useState(false);
32
+ const [category, setCategory] = useLocalStorage(`audit-log-category-${scope}`, 'all');
33
+ const categoryList = [{
34
+ value: 'all',
35
+ label: 'All',
36
+ description: ''
37
+ }, {
38
+ value: 'blocklet',
39
+ label: 'Blocklet Management',
40
+ description: ''
41
+ }, {
42
+ value: 'server',
43
+ label: 'Server Management',
44
+ description: ''
45
+ }, {
46
+ value: 'team',
47
+ label: 'Team Management',
48
+ description: ''
49
+ }, {
50
+ value: 'security',
51
+ label: 'Security',
52
+ description: ''
53
+ }, {
54
+ value: 'certificates',
55
+ label: 'Certificate Management',
56
+ description: ''
57
+ }, {
58
+ value: 'integrations',
59
+ label: 'Integration Management',
60
+ description: ''
61
+ }, {
62
+ value: 'gateway',
63
+ label: 'Gateway',
64
+ description: ''
65
+ }];
66
+ const filterCategories = categoryList.filter(item => {
67
+ if (categories.length) {
68
+ return item.value === 'all' || categories.includes(item.value);
69
+ }
70
+ return true;
71
+ });
72
+ const fetchLogs = async ({
73
+ page = 1,
74
+ silent = true
75
+ } = {}) => {
76
+ if (loading) {
77
+ return;
78
+ }
79
+ if (!silent) {
80
+ setLoading(true);
81
+ }
82
+ try {
83
+ // eslint-disable-next-line no-shadow
84
+ const res = await client.getAuditLogs({
85
+ // 由于 blocklet 中的 audit-log 本身就不包含 server 类型的,所以这里的 category 查询不需要对 server 类型的做额外的处理
86
+ input: {
87
+ paging: {
88
+ page
89
+ },
90
+ category: category === 'all' ? '' : category,
91
+ scope
92
+ }
93
+ });
94
+
95
+ // add link for blocklet audit logs
96
+ if (showScope) {
97
+ (res.list || []).forEach(x => {
98
+ if (x.scope !== nodeInfo.did) {
99
+ x.link = `/blocklets/${x.scope}/components`;
100
+ }
101
+ });
102
+ }
103
+ setAuditLogs(res.list);
104
+ setPaging(res.paging);
105
+ setLoading(false);
106
+ } catch (err) {
107
+ Toast.error(err.message);
108
+ setLoading(false);
109
+ }
110
+ };
111
+ useEffect(() => {
112
+ fetchLogs({
113
+ page: 1,
114
+ silent: false
115
+ });
116
+ }, []); // eslint-disable-line
117
+
118
+ useEffect(() => {
119
+ fetchLogs({
120
+ page: 1,
121
+ silent: false
122
+ });
123
+ }, [category]); // eslint-disable-line
124
+
125
+ const value = {
126
+ loading,
127
+ fetch: fetchLogs,
128
+ filter: {
129
+ category,
130
+ scope
131
+ },
132
+ categories: filterCategories,
133
+ setCategory,
134
+ data: auditLogs,
135
+ paging,
136
+ showScope,
137
+ scopeFormatter
138
+ };
139
+ return /*#__PURE__*/_jsx(Provider, {
140
+ value: {
141
+ auditLogs: value
142
+ },
143
+ children: children
144
+ });
145
+ }
146
+ function useAuditLogContext() {
147
+ const {
148
+ auditLogs
149
+ } = useContext(AuditLogContext);
150
+ return auditLogs;
151
+ }
152
+ export { AuditLogContext, AuditLogProvider, Consumer as AuditLogConsumer, useAuditLogContext };
@@ -0,0 +1,10 @@
1
+ import { createContext, useContext } from 'react';
2
+ const BlockletContext = /*#__PURE__*/createContext({});
3
+ const {
4
+ Provider,
5
+ Consumer
6
+ } = BlockletContext;
7
+ function useBlockletContext() {
8
+ return useContext(BlockletContext);
9
+ }
10
+ export { BlockletContext, Provider as BlockletProvider, Consumer as BlockletConsumer, useBlockletContext };
@@ -0,0 +1,70 @@
1
+ import { createContext, useState, useContext, useRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import xorWith from 'lodash/xorWith';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const DeletingBlockletContext = /*#__PURE__*/createContext({});
6
+ function DeletingBlockletProvider({
7
+ children,
8
+ type
9
+ }) {
10
+ const [deletingBlocklets, setDeletingBlocklets] = useState([]);
11
+ const deletingBlockletsDid = useRef([]); // use in onActionComplete
12
+
13
+ /**
14
+ * 添加删除中的 blocklet did
15
+ * @param {String} did 删除中的did
16
+ */
17
+ const addDeletingDid = did => {
18
+ if (!deletingBlockletsDid.current.includes(did)) {
19
+ const reDeleteings = [...deletingBlockletsDid.current, did];
20
+ setDeletingBlocklets(reDeleteings);
21
+ deletingBlockletsDid.current = reDeleteings;
22
+ }
23
+ };
24
+
25
+ /**
26
+ * 去除删除中的 blocklet did
27
+ * @param {String} did 删除中的did
28
+ */
29
+ const removeDeletingDid = did => {
30
+ if (deletingBlockletsDid.current.includes(did)) {
31
+ const reDeleteings = deletingBlockletsDid.current.filter(d => {
32
+ return d !== did;
33
+ });
34
+ setDeletingBlocklets(reDeleteings);
35
+ deletingBlockletsDid.current = reDeleteings;
36
+ }
37
+ };
38
+
39
+ /**
40
+ * 将不在的 blocklet id 移出 deleting 数组
41
+ * @param {Array} existDids 已存在的 blocklet did 数组集
42
+ */
43
+ const matchDeletingDid = existDids => {
44
+ const inDeleting = deletingBlocklets.filter(did => existDids.find(e => e === did));
45
+ const needMoveoutDeleting = xorWith(inDeleting, deletingBlocklets);
46
+ needMoveoutDeleting.forEach(did => removeDeletingDid(did));
47
+ };
48
+ return /*#__PURE__*/_jsx(DeletingBlockletContext.Provider, {
49
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
50
+ value: {
51
+ type,
52
+ deletingBlocklets,
53
+ addDeletingDid,
54
+ removeDeletingDid,
55
+ matchDeletingDid
56
+ },
57
+ children: children
58
+ });
59
+ }
60
+ DeletingBlockletProvider.propTypes = {
61
+ type: PropTypes.string,
62
+ children: PropTypes.node.isRequired
63
+ };
64
+ DeletingBlockletProvider.defaultProps = {
65
+ type: 'blocklets'
66
+ };
67
+ function useDeletingBlockletContext() {
68
+ return useContext(DeletingBlockletContext);
69
+ }
70
+ export { DeletingBlockletProvider, useDeletingBlockletContext };
@@ -0,0 +1,17 @@
1
+ import { createContext, useContext } from 'react';
2
+ const NodeContext = /*#__PURE__*/createContext({});
3
+ const {
4
+ Provider,
5
+ Consumer
6
+ } = NodeContext;
7
+ function useNodeContext() {
8
+ const {
9
+ node
10
+ } = useContext(NodeContext);
11
+ return {
12
+ ...node,
13
+ inService: node.type === 'service',
14
+ inDaemon: node.type === 'daemon'
15
+ };
16
+ }
17
+ export { NodeContext, Provider as NodeProvider, Consumer as NodeConsumer, useNodeContext };
@@ -0,0 +1,8 @@
1
+ /* eslint-disable object-curly-newline */
2
+ import { useContext } from 'react';
3
+ import { SessionContext } from '@arcblock/did-connect/lib/Session';
4
+ function useSessionContext() {
5
+ const info = useContext(SessionContext);
6
+ return info;
7
+ }
8
+ export { SessionContext, useSessionContext };
@@ -0,0 +1,10 @@
1
+ import { createContext, useContext } from 'react';
2
+ const TeamContext = /*#__PURE__*/createContext({});
3
+ const {
4
+ Provider,
5
+ Consumer
6
+ } = TeamContext;
7
+ function useTeamContext() {
8
+ return useContext(TeamContext);
9
+ }
10
+ export { TeamContext, Provider as TeamProvider, Consumer as TeamConsumer, useTeamContext };
@@ -0,0 +1,121 @@
1
+ /* eslint-disable react/no-unstable-nested-components */
2
+ /* eslint-disable react/no-danger */
3
+ /* eslint-disable react/prop-types */
4
+ import PropTypes from 'prop-types';
5
+ import Typography from '@mui/material/Typography';
6
+ import TextField from '@mui/material/TextField';
7
+ import Alert from '@mui/material/Alert';
8
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
9
+ import ClickToCopy from './click-to-copy';
10
+ import Confirm from './confirm';
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ export default function CancelConfirm({
14
+ title,
15
+ description,
16
+ confirmPlaceholder,
17
+ cancel,
18
+ confirm,
19
+ params: initialParams,
20
+ onCancel,
21
+ onConfirm,
22
+ keyName
23
+ }) {
24
+ const {
25
+ t
26
+ } = useLocaleContext();
27
+ const confirmSetting = {
28
+ title: () => /*#__PURE__*/_jsxs("div", {
29
+ children: [title, ` (${keyName})`]
30
+ }),
31
+ description: (params, setParams) => {
32
+ const setValue = value => {
33
+ // eslint-disable-next-line no-underscore-dangle
34
+ setParams({
35
+ ...value,
36
+ __disableConfirm: value.__disableConfirm
37
+ });
38
+ };
39
+ return /*#__PURE__*/_jsxs("div", {
40
+ children: [/*#__PURE__*/_jsx(Alert, {
41
+ severity: "warning",
42
+ style: {
43
+ width: '100%'
44
+ },
45
+ children: t('common.notice')
46
+ }), /*#__PURE__*/_jsx("div", {
47
+ style: {
48
+ marginTop: 24,
49
+ marginBottom: 24
50
+ },
51
+ dangerouslySetInnerHTML: {
52
+ __html: description
53
+ }
54
+ }), /*#__PURE__*/_jsxs("div", {
55
+ style: {
56
+ marginBottom: 24
57
+ },
58
+ children: [t('common.click'), "\uFF1A", /*#__PURE__*/_jsx(ClickToCopy, {
59
+ "data-cy": "click-copy",
60
+ children: keyName
61
+ })]
62
+ }), /*#__PURE__*/_jsx(Typography, {
63
+ component: "div",
64
+ children: /*#__PURE__*/_jsx(TextField, {
65
+ label: confirmPlaceholder,
66
+ autoComplete: "off",
67
+ "data-cy": "delete-confirm-input",
68
+ variant: "outlined",
69
+ fullWidth: true,
70
+ autoFocus: true,
71
+ value: params.inputVal,
72
+ onChange: e => {
73
+ setValue({
74
+ ...params,
75
+ inputVal: e.target.value,
76
+ __disableConfirm: keyName !== e.target.value
77
+ });
78
+ }
79
+ })
80
+ })]
81
+ });
82
+ },
83
+ confirm,
84
+ cancel,
85
+ onConfirm,
86
+ onCancel,
87
+ params: {
88
+ inputVal: '',
89
+ __disableConfirm: true,
90
+ ...initialParams
91
+ }
92
+ };
93
+ return /*#__PURE__*/_jsx(Confirm, {
94
+ title: confirmSetting.title,
95
+ description: confirmSetting.description,
96
+ confirm: confirmSetting.confirm,
97
+ cancel: confirmSetting.cancel,
98
+ params: confirmSetting.params,
99
+ onConfirm: confirmSetting.onConfirm,
100
+ onCancel: confirmSetting.onCancel
101
+ });
102
+ }
103
+ CancelConfirm.propTypes = {
104
+ title: PropTypes.any.isRequired,
105
+ keyName: PropTypes.any.isRequired,
106
+ description: PropTypes.any.isRequired,
107
+ // can be a function that renders different content based on params
108
+ confirmPlaceholder: PropTypes.any.isRequired,
109
+ cancel: PropTypes.string,
110
+ confirm: PropTypes.string,
111
+ params: PropTypes.object,
112
+ // This object holds states managed in the dialog
113
+ onCancel: PropTypes.func,
114
+ onConfirm: PropTypes.func.isRequired
115
+ };
116
+ CancelConfirm.defaultProps = {
117
+ onCancel: () => {},
118
+ cancel: '',
119
+ confirm: 'Confirm',
120
+ params: {}
121
+ };
@@ -0,0 +1,46 @@
1
+ import PropTypes from 'prop-types';
2
+ import { Link } from 'react-router-dom';
3
+ import ExternalLink from '@mui/material/Link';
4
+ import DidAddress from '@arcblock/ux/lib/DID';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ function WrappedDidAddress({
7
+ did,
8
+ href,
9
+ external,
10
+ avatarProps,
11
+ ...rest
12
+ }) {
13
+ const content = /*#__PURE__*/_jsx(DidAddress, {
14
+ did: did,
15
+ ...rest
16
+ });
17
+ if (href) {
18
+ if (external) {
19
+ return /*#__PURE__*/_jsx(ExternalLink, {
20
+ target: "_blank",
21
+ href: href,
22
+ underline: "hover",
23
+ children: content
24
+ });
25
+ }
26
+ return /*#__PURE__*/_jsx(Link, {
27
+ to: href,
28
+ children: content
29
+ });
30
+ }
31
+ return content;
32
+ }
33
+ WrappedDidAddress.propTypes = {
34
+ did: PropTypes.string.isRequired,
35
+ to: PropTypes.string,
36
+ href: PropTypes.string,
37
+ avatarProps: PropTypes.object,
38
+ external: PropTypes.bool
39
+ };
40
+ WrappedDidAddress.defaultProps = {
41
+ to: '',
42
+ href: '',
43
+ avatarProps: {},
44
+ external: false
45
+ };
46
+ export default WrappedDidAddress;
package/es/dot.js ADDED
@@ -0,0 +1,14 @@
1
+ import styled from '@emotion/styled';
2
+ const color = {
3
+ success: '#3ab39d',
4
+ error: '#D0021B'
5
+ };
6
+ const defaultSize = '10px';
7
+ const Dot = styled.div`
8
+ display: inline-block;
9
+ width: ${props => props.size || defaultSize};
10
+ height: ${props => props.size || defaultSize};
11
+ background: ${props => color[props.color] || props.color || color.success};
12
+ border-radius: 100%;
13
+ `;
14
+ export default Dot;
@@ -0,0 +1,102 @@
1
+ /* eslint-disable react/prop-types */
2
+ /* eslint-disable react/jsx-one-expression-per-line */
3
+ import React, { useContext } from 'react';
4
+ import styled from '@emotion/styled';
5
+ import { useNavigate } from 'react-router-dom';
6
+ import Spinner from '@mui/material/CircularProgress';
7
+ import Center from '@arcblock/ux/lib/Center';
8
+ import Toast from '@arcblock/ux/lib/Toast';
9
+ import DidConnect from '@arcblock/did-connect/lib/Connect';
10
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
11
+ import { WELLKNOWN_SERVICE_PATH_PREFIX } from '@abtnode/constant';
12
+ import wrapLocale from './wrap-locale';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ function ExchangePassport({
15
+ SessionContext,
16
+ webWalletUrl,
17
+ onSuccess
18
+ }) {
19
+ const {
20
+ api,
21
+ session
22
+ } = useContext(SessionContext);
23
+ const {
24
+ t,
25
+ locale
26
+ } = useLocaleContext();
27
+ const navigate = useNavigate();
28
+ const {
29
+ searchParams
30
+ } = new URL(window.location.href);
31
+ const redirect = searchParams.get('redirect');
32
+ const onDone = async (result, decrypt) => {
33
+ onSuccess(result, decrypt);
34
+ await session.refresh();
35
+ Toast.success(t('exchangePassport.success'));
36
+ setTimeout(() => {
37
+ if (redirect) {
38
+ const url = decodeURIComponent(redirect);
39
+ if (url.startsWith(WELLKNOWN_SERVICE_PATH_PREFIX)) {
40
+ navigate(url, {
41
+ replace: true
42
+ });
43
+ } else {
44
+ window.location = url;
45
+ }
46
+ } else {
47
+ window.location = window.env.pathPrefix || window.env.apiPrefix || '/';
48
+ }
49
+ }, 3000);
50
+ };
51
+ const onError = err => {
52
+ Toast.error(err.message);
53
+ };
54
+ const extraParams = {};
55
+ const componentId = searchParams.get('componentId');
56
+ if (componentId) {
57
+ extraParams.componentId = componentId;
58
+ }
59
+ if (session.loading) {
60
+ return /*#__PURE__*/_jsx(Center, {
61
+ children: /*#__PURE__*/_jsx(Spinner, {})
62
+ });
63
+ }
64
+ return /*#__PURE__*/_jsx(Div, {
65
+ children: /*#__PURE__*/_jsx("div", {
66
+ className: "connect-wrapper",
67
+ children: /*#__PURE__*/_jsx(DidConnect, {
68
+ className: "connect",
69
+ action: "exchange-passport",
70
+ checkFn: api.get,
71
+ checkTimeout: 10 * 60 * 1000,
72
+ webWalletUrl: webWalletUrl,
73
+ onSuccess: onDone,
74
+ onError: onError,
75
+ locale: locale,
76
+ messages: {
77
+ title: t('exchangePassport.dialog.title'),
78
+ scan: t('exchangePassport.dialog.scan'),
79
+ confirm: t('exchangePassport.dialog.confirm'),
80
+ success: t('exchangePassport.dialog.success')
81
+ },
82
+ extraParams: extraParams,
83
+ extraContent: null
84
+ })
85
+ })
86
+ });
87
+ }
88
+ export default wrapLocale(ExchangePassport);
89
+ const Div = styled.div`
90
+ box-sizing: border-box;
91
+ width: 100%;
92
+ height: 100vh;
93
+ position: relative;
94
+ display: flex;
95
+ flex-direction: column;
96
+ .connect-wrapper {
97
+ flex: 1;
98
+ }
99
+ .connect {
100
+ background: #fafafa;
101
+ }
102
+ `;