@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,141 @@
1
+ import { useContext, useEffect, useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Spinner from '@mui/material/CircularProgress';
4
+ import Button from '@mui/material/IconButton';
5
+ import UpgradeIcon from '@mui/icons-material/ArrowUpward';
6
+ import Tooltip from '@mui/material/Tooltip';
7
+ import Toast from '@arcblock/ux/lib/Toast';
8
+ import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
9
+ import { BLOCKLET_MODES } from '@blocklet/constant';
10
+ import { getDisplayName, isInProgress } from '@blocklet/meta/lib/util';
11
+ import Tag from '../tag';
12
+ import Confirm from '../confirm';
13
+ import { useNodeContext } from '../contexts/node';
14
+ import { sleep, formatError, BlockletAdminRoles } from '../util';
15
+ import { withPermission } from '../permission';
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ import { Fragment as _Fragment } from "react/jsx-runtime";
18
+ import { jsxs as _jsxs } from "react/jsx-runtime";
19
+ function Version({
20
+ blocklet,
21
+ checkUpgrade,
22
+ hasPermission,
23
+ ...rest
24
+ }) {
25
+ const {
26
+ api
27
+ } = useNodeContext();
28
+ const {
29
+ t
30
+ } = useContext(LocaleContext);
31
+ const [loading, setLoading] = useState(false);
32
+ const [error, setError] = useState('');
33
+ const [newVersionBlocklet, setNewVersionBlocklet] = useState(null);
34
+ const [confirmSetting, setConfirmSetting] = useState(null);
35
+ useEffect(() => {
36
+ setNewVersionBlocklet(null);
37
+ if (checkUpgrade && blocklet.mode !== BLOCKLET_MODES.DEVELOPMENT) {
38
+ // The implementation was removed and will be restore in the further
39
+ }
40
+ }, [blocklet, checkUpgrade]); // eslint-disable-line
41
+
42
+ const onCancel = () => {
43
+ setLoading(false);
44
+ setConfirmSetting(null);
45
+ };
46
+ const onConfirm = async () => {
47
+ setLoading(true);
48
+ try {
49
+ const input = {
50
+ did: blocklet.meta.did,
51
+ version: newVersionBlocklet.version,
52
+ storeUrl: newVersionBlocklet.registryUrl || ''
53
+ };
54
+ await sleep(2000);
55
+ await api.upgradeBlocklet({
56
+ input
57
+ });
58
+ } catch (err) {
59
+ Toast.error(`Blocklet upgrade failed: ${formatError(err)}`);
60
+ } finally {
61
+ setLoading(false);
62
+ setConfirmSetting(null);
63
+ }
64
+ };
65
+ const setting = {
66
+ title: `${t('common.upgrade')} ${t('common.blocklet')} ${getDisplayName(blocklet)}`,
67
+ description: t('blocklet.action.upgradeDescription'),
68
+ confirm: t('blocklet.action.confirmUpgrade'),
69
+ cancel: t('common.cancel'),
70
+ onConfirm,
71
+ onCancel
72
+ };
73
+ if (hasPermission && newVersionBlocklet && !isInProgress(blocklet.status)) {
74
+ return /*#__PURE__*/_jsxs(_Fragment, {
75
+ children: [/*#__PURE__*/_jsx(Tag, {
76
+ ...rest,
77
+ children: blocklet.meta.version
78
+ }), /*#__PURE__*/_jsx(Tooltip, {
79
+ title: t('common.updateAvailable', {
80
+ version: newVersionBlocklet.version
81
+ }),
82
+ children: /*#__PURE__*/_jsx(Button, {
83
+ size: "small",
84
+ style: {
85
+ marginLeft: 8
86
+ },
87
+ disabled: loading,
88
+ onClick: () => setConfirmSetting(setting),
89
+ children: loading ? /*#__PURE__*/_jsx(Spinner, {
90
+ size: 16
91
+ }) : /*#__PURE__*/_jsx(UpgradeIcon, {
92
+ style: {
93
+ fontSize: 16,
94
+ color: 'red'
95
+ }
96
+ })
97
+ })
98
+ }), !!error && /*#__PURE__*/_jsx(Toast, {
99
+ variant: "error",
100
+ message: error,
101
+ onClose: () => setError('')
102
+ }), confirmSetting && /*#__PURE__*/_jsx(Confirm, {
103
+ title: confirmSetting.title,
104
+ description: confirmSetting.description,
105
+ confirm: confirmSetting.confirm,
106
+ cancel: confirmSetting.cancel,
107
+ params: confirmSetting.params,
108
+ onConfirm: confirmSetting.onConfirm,
109
+ onCancel: confirmSetting.onCancel
110
+ })]
111
+ });
112
+ }
113
+ return /*#__PURE__*/_jsx(Tag, {
114
+ ...rest,
115
+ children: blocklet.meta.version
116
+ });
117
+ }
118
+ Version.propTypes = {
119
+ blocklet: PropTypes.object.isRequired,
120
+ checkUpgrade: PropTypes.bool,
121
+ hasPermission: PropTypes.bool
122
+ };
123
+ Version.defaultProps = {
124
+ checkUpgrade: false,
125
+ hasPermission: false
126
+ };
127
+ const BlockletVersionInDaemon = withPermission(Version, 'mutate_blocklets');
128
+ const BlockletVersionInService = withPermission(Version, '', BlockletAdminRoles);
129
+ export default function BlockletVersion(props) {
130
+ const {
131
+ inService
132
+ } = useNodeContext();
133
+ if (inService) {
134
+ return /*#__PURE__*/_jsx(BlockletVersionInService, {
135
+ ...props
136
+ });
137
+ }
138
+ return /*#__PURE__*/_jsx(BlockletVersionInDaemon, {
139
+ ...props
140
+ });
141
+ }
@@ -0,0 +1,134 @@
1
+ /* eslint-disable react/no-danger */
2
+ /* eslint-disable jsx-a11y/alt-text */
3
+ import { useState, useEffect, useRef } from 'react';
4
+ import styled from '@emotion/styled';
5
+ import PropTypes from 'prop-types';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export default function CardSelector({
8
+ list,
9
+ width,
10
+ height,
11
+ cardSpace,
12
+ onSelect,
13
+ defaultIndex
14
+ }) {
15
+ const [selectedId, setSelectedId] = useState(0);
16
+ const [translateX, setTranslateX] = useState(0);
17
+ const outerCon = useRef(null);
18
+
19
+ // 选择卡片
20
+ const selectedItem = i => {
21
+ if (i < 0 || i > list.length - 1) {
22
+ return;
23
+ }
24
+ setSelectedId(i);
25
+
26
+ // 外部容器大小
27
+ const outerWidth = outerCon.current.clientWidth;
28
+ setTranslateX(i * (width + cardSpace) - (outerWidth - width) / 2 + cardSpace * 0.5);
29
+ onSelect(i);
30
+ };
31
+ useEffect(() => {
32
+ selectedItem(defaultIndex);
33
+ const func = e => e.preventDefault();
34
+ outerCon.current.addEventListener('touchmove', func, {
35
+ passive: false
36
+ });
37
+ // eslint-disable-next-line react-hooks/exhaustive-deps
38
+ }, []);
39
+ let startX;
40
+ const touchstart = e => {
41
+ const point = e.touches[0];
42
+ startX = point.clientX;
43
+ };
44
+ const touchend = e => {
45
+ const point = e.changedTouches[0];
46
+ const diffX = startX - point.clientX;
47
+ if (Math.abs(diffX) > 60) {
48
+ if (diffX > 0) {
49
+ selectedItem(selectedId + 1);
50
+ } else {
51
+ selectedItem(selectedId - 1);
52
+ }
53
+ }
54
+ };
55
+ return /*#__PURE__*/_jsx(Container, {
56
+ ref: outerCon,
57
+ onTouchStart: touchstart,
58
+ onTouchEnd: touchend,
59
+ children: /*#__PURE__*/_jsx("div", {
60
+ className: "card-container",
61
+ style: {
62
+ transform: `translate(${-translateX}px, 0)`
63
+ },
64
+ children: list.map((x, i) => {
65
+ return /*#__PURE__*/_jsx("div", {
66
+ className: `card-item ${i === selectedId ? 'selected' : ''}`,
67
+ style: {
68
+ width,
69
+ height,
70
+ margin: cardSpace / 2
71
+ },
72
+ onClick: () => selectedItem(i),
73
+ children: /*#__PURE__*/_jsx("div", {
74
+ className: "card-content",
75
+ dangerouslySetInnerHTML: {
76
+ __html: x.src
77
+ }
78
+ })
79
+ }, x.id);
80
+ })
81
+ })
82
+ });
83
+ }
84
+ const Container = styled.div`
85
+ overflow: hidden;
86
+ mask-image: linear-gradient(to left, transparent, black 3%, black 97%, transparent);
87
+ overflow: hidden;
88
+ .card-container {
89
+ display: flex;
90
+ white-space: nowrap;
91
+ width: max-content;
92
+ transition: all ease 0.3s;
93
+ }
94
+ .card-item {
95
+ display: inline-flex;
96
+ justify-content: center;
97
+ align-items: center;
98
+ flex-shrink: 0;
99
+ cursor: pointer;
100
+
101
+ .card-content {
102
+ pointer-events: none;
103
+ max-width: 100%;
104
+ max-height: 100%;
105
+ width: auto;
106
+ height: auto;
107
+ outline: #526ded solid 0;
108
+ transition: all ease 0.2s;
109
+ box-shadow: rgba(0, 0, 0, 0.2) 0 0 10px;
110
+ }
111
+ &.selected {
112
+ cursor: default;
113
+ .card-content {
114
+ outline: #526ded solid 5px;
115
+ }
116
+ }
117
+ }
118
+ `;
119
+ CardSelector.propTypes = {
120
+ list: PropTypes.array,
121
+ width: PropTypes.number,
122
+ height: PropTypes.number,
123
+ cardSpace: PropTypes.number,
124
+ onSelect: PropTypes.func,
125
+ defaultIndex: PropTypes.number
126
+ };
127
+ CardSelector.defaultProps = {
128
+ list: '',
129
+ width: 300,
130
+ height: 400,
131
+ cardSpace: 40,
132
+ onSelect: () => {},
133
+ defaultIndex: 0
134
+ };
@@ -0,0 +1,105 @@
1
+ import { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import get from 'lodash/get';
4
+ import HttpsIcon from '@mui/icons-material/Https';
5
+ import Popover from '@mui/material/Popover';
6
+ import Card from '@mui/material/Card';
7
+ import CardContent from '@mui/material/CardContent';
8
+ import Typography from '@mui/material/Typography';
9
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
10
+ import { formatToDate } from './util';
11
+ import { useNodeContext } from './contexts/node';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { Fragment as _Fragment } from "react/jsx-runtime";
15
+ export default function Certificate({
16
+ certificate
17
+ }) {
18
+ const [anchorEl, setAnchorEl] = useState(null);
19
+ const node = useNodeContext();
20
+ const {
21
+ t,
22
+ locale
23
+ } = useLocaleContext();
24
+ const handlePopoverOpen = event => {
25
+ setAnchorEl(event.currentTarget);
26
+ };
27
+ const handlePopoverClose = () => {
28
+ setAnchorEl(null);
29
+ };
30
+ const open = Boolean(anchorEl);
31
+ return /*#__PURE__*/_jsxs(_Fragment, {
32
+ children: [/*#__PURE__*/_jsx(HttpsIcon, {
33
+ "aria-owns": open ? 'mouse-over-popover' : undefined,
34
+ onMouseEnter: handlePopoverOpen,
35
+ onMouseLeave: handlePopoverClose,
36
+ style: {
37
+ color: '#44cdc6',
38
+ fontSize: 20,
39
+ marginLeft: 8,
40
+ cursor: 'pointer'
41
+ }
42
+ }), /*#__PURE__*/_jsx(Popover, {
43
+ id: "mouse-over-popover",
44
+ style: {
45
+ pointerEvents: 'none'
46
+ },
47
+ open: open,
48
+ anchorEl: anchorEl,
49
+ anchorOrigin: {
50
+ vertical: 'bottom',
51
+ horizontal: 'left'
52
+ },
53
+ transformOrigin: {
54
+ vertical: 'top',
55
+ horizontal: 'left'
56
+ },
57
+ onClose: handlePopoverClose,
58
+ disableRestoreFocus: true,
59
+ children: /*#__PURE__*/_jsx(Card, {
60
+ children: /*#__PURE__*/_jsxs(CardContent, {
61
+ style: {
62
+ display: 'flex'
63
+ },
64
+ children: [/*#__PURE__*/_jsx("div", {
65
+ children: /*#__PURE__*/_jsx("img", {
66
+ src: `${node.imgPrefix}/https-certificate-icon.png`,
67
+ alt: "certificate icon",
68
+ style: {
69
+ maxHeight: '100%',
70
+ maxWidth: '100%'
71
+ }
72
+ })
73
+ }), /*#__PURE__*/_jsxs(Typography, {
74
+ component: "div",
75
+ style: {
76
+ marginLeft: '16px'
77
+ },
78
+ children: [/*#__PURE__*/_jsx(Typography, {
79
+ component: "div",
80
+ style: {
81
+ fontWeight: 'bold'
82
+ },
83
+ children: certificate.domain
84
+ }), /*#__PURE__*/_jsx(Typography, {
85
+ component: "div",
86
+ children: `${t('common.issuer')}: ${get(certificate, 'issuer.commonName', '')}`
87
+ }), /*#__PURE__*/_jsx(Typography, {
88
+ component: "div",
89
+ children: `${t('router.cert.issuedOn')}: ${formatToDate(certificate.validFrom, locale)}`
90
+ }), /*#__PURE__*/_jsx(Typography, {
91
+ component: "div",
92
+ children: `${t('router.cert.expiryOn')}: ${formatToDate(certificate.validTo, locale)}`
93
+ })]
94
+ })]
95
+ })
96
+ })
97
+ })]
98
+ });
99
+ }
100
+ Certificate.propTypes = {
101
+ certificate: PropTypes.object
102
+ };
103
+ Certificate.defaultProps = {
104
+ certificate: {}
105
+ };
package/es/chain.js ADDED
@@ -0,0 +1,13 @@
1
+ import OcapClient from '@ocap/client/dist/lite';
2
+ const clients = {};
3
+ export default function getChainClient(endpoint) {
4
+ if (!endpoint) {
5
+ return null;
6
+ }
7
+ if (clients[endpoint]) {
8
+ return clients[endpoint];
9
+ }
10
+ const client = new OcapClient(endpoint);
11
+ clients[endpoint] = client;
12
+ return client;
13
+ }
@@ -0,0 +1,22 @@
1
+ import { useContext } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Copy from '@arcblock/ux/lib/ClickToCopy';
4
+ import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ export default function ClickToCopy({
7
+ children,
8
+ ...rest
9
+ }) {
10
+ const {
11
+ t
12
+ } = useContext(LocaleContext);
13
+ return /*#__PURE__*/_jsx(Copy, {
14
+ tip: t('common.copyTip'),
15
+ copiedTip: t('common.copiedTip'),
16
+ ...rest,
17
+ children: children
18
+ });
19
+ }
20
+ ClickToCopy.propTypes = {
21
+ children: PropTypes.any.isRequired
22
+ };
package/es/confirm.js ADDED
@@ -0,0 +1,149 @@
1
+ import { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from '@emotion/styled';
4
+ import Dialog from '@mui/material/Dialog';
5
+ import Spinner from '@mui/material/CircularProgress';
6
+ import DialogActions from '@mui/material/DialogActions';
7
+ import DialogContent from '@mui/material/DialogContent';
8
+ import DialogContentText from '@mui/material/DialogContentText';
9
+ import DialogTitle from '@mui/material/DialogTitle';
10
+ import Alert from '@mui/material/Alert';
11
+ import useTheme from '@mui/material/styles/useTheme';
12
+ import useMediaQuery from '@mui/material/useMediaQuery';
13
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
14
+ import Button from '@arcblock/ux/lib/Button';
15
+ import { formatError } from './util';
16
+ import useMobileWidth from './hooks/mobile-width';
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { jsxs as _jsxs } from "react/jsx-runtime";
19
+ export default function ConfirmDialog({
20
+ title,
21
+ description,
22
+ showCancel,
23
+ cancel,
24
+ confirm,
25
+ color,
26
+ params: initialParams,
27
+ onCancel,
28
+ onConfirm,
29
+ loading: inputLoading
30
+ }) {
31
+ const [params, setParams] = useState(initialParams);
32
+ const [open, setOpen] = useState(true);
33
+ const [loading, setLoading] = useState(false);
34
+ const [error, setError] = useState('');
35
+ const {
36
+ t: changeLocale
37
+ } = useLocaleContext();
38
+ const theme = useTheme();
39
+ const onCallback = async cb => {
40
+ if (typeof cb === 'function') {
41
+ setLoading(true);
42
+ try {
43
+ await cb(params);
44
+ setOpen(false);
45
+ } catch (err) {
46
+ setError(formatError(err));
47
+ console.error(err);
48
+ } finally {
49
+ setLoading(false);
50
+ }
51
+ } else {
52
+ setOpen(false);
53
+ }
54
+ };
55
+ const t = typeof title === 'function' ? title() : title;
56
+ const d = typeof description === 'function' ? description(params, setParams, setError) : description;
57
+ const isBreakpointsDownSm = useMediaQuery(theme.breakpoints.down('md'));
58
+ const handleClick = e => {
59
+ e.stopPropagation();
60
+ };
61
+ const {
62
+ minWidth
63
+ } = useMobileWidth();
64
+ return /*#__PURE__*/_jsxs(StyledDialog, {
65
+ onClick: handleClick,
66
+ fullScreen: isBreakpointsDownSm,
67
+ open: open,
68
+ style: {
69
+ minWidth
70
+ },
71
+ children: [/*#__PURE__*/_jsx(DialogTitle, {
72
+ children: t
73
+ }), /*#__PURE__*/_jsxs(DialogContent, {
74
+ style: {
75
+ minWidth
76
+ },
77
+ children: [/*#__PURE__*/_jsx(DialogContentText, {
78
+ component: "div",
79
+ children: d
80
+ }), !!error && /*#__PURE__*/_jsx(Alert, {
81
+ severity: "error",
82
+ style: {
83
+ width: '100%',
84
+ marginTop: 8
85
+ },
86
+ children: error
87
+ })]
88
+ }), /*#__PURE__*/_jsxs(DialogActions, {
89
+ className: "delete-actions",
90
+ style: {
91
+ padding: '8px 24px 24px'
92
+ },
93
+ children: [showCancel && /*#__PURE__*/_jsx(Button, {
94
+ onClick: e => {
95
+ e.stopPropagation();
96
+ onCallback(onCancel);
97
+ },
98
+ color: "inherit",
99
+ "data-cy": "cancel-confirm-dialog",
100
+ children: cancel || changeLocale('common.cancel')
101
+ }), /*#__PURE__*/_jsxs(Button, {
102
+ onClick: e => {
103
+ e.stopPropagation();
104
+ onCallback(onConfirm);
105
+ },
106
+ color: color
107
+ // eslint-disable-next-line no-underscore-dangle
108
+ ,
109
+ disabled: params.__disableConfirm || loading || inputLoading,
110
+ variant: "contained",
111
+ "data-cy": "submit-confirm-dialog",
112
+ autoFocus: true,
113
+ children: [(loading || inputLoading) && /*#__PURE__*/_jsx(Spinner, {
114
+ size: 16
115
+ }), confirm]
116
+ })]
117
+ })]
118
+ });
119
+ }
120
+ ConfirmDialog.propTypes = {
121
+ title: PropTypes.any.isRequired,
122
+ description: PropTypes.any.isRequired,
123
+ // can be a function that renders different content based on params
124
+ showCancel: PropTypes.bool,
125
+ cancel: PropTypes.string,
126
+ color: PropTypes.string,
127
+ confirm: PropTypes.string,
128
+ params: PropTypes.object,
129
+ // This object holds states managed in the dialog
130
+ onCancel: PropTypes.func,
131
+ onConfirm: PropTypes.func.isRequired,
132
+ loading: PropTypes.bool
133
+ };
134
+ ConfirmDialog.defaultProps = {
135
+ onCancel: () => {},
136
+ showCancel: true,
137
+ cancel: '',
138
+ confirm: 'Confirm',
139
+ color: 'error',
140
+ params: {},
141
+ loading: false
142
+ };
143
+ const StyledDialog = styled(Dialog)`
144
+ .delete-actions .Mui-disabled {
145
+ color: rgba(0, 0, 0, 0.26) !important;
146
+ box-shadow: none;
147
+ background-color: rgba(0, 0, 0, 0.12) !important;
148
+ }
149
+ `;