@abtnode/ux 1.16.14-beta-ab7f615e → 1.16.14-beta-cb53c14b

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 (202) 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 +1308 -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/setting.js +109 -0
  32. package/es/blocklet/component/sortable-tree.js +126 -0
  33. package/es/blocklet/component/space-connector.js +199 -0
  34. package/es/blocklet/component/space-selector.js +178 -0
  35. package/es/blocklet/component/start.js +101 -0
  36. package/es/blocklet/component/store-blocklet-list.js +200 -0
  37. package/es/blocklet/component/switch-control.js +57 -0
  38. package/es/blocklet/config-navigation.js +331 -0
  39. package/es/blocklet/configuration.js +603 -0
  40. package/es/blocklet/disk-info.js +75 -0
  41. package/es/blocklet/icons.js +18 -0
  42. package/es/blocklet/install-from-url.js +337 -0
  43. package/es/blocklet/log.js +90 -0
  44. package/es/blocklet/migration.js +149 -0
  45. package/es/blocklet/mode.js +19 -0
  46. package/es/blocklet/notification/email.js +257 -0
  47. package/es/blocklet/notification/index.js +49 -0
  48. package/es/blocklet/oauth/auth0.js +145 -0
  49. package/es/blocklet/oauth/common-settings.js +133 -0
  50. package/es/blocklet/oauth/federated-detail-dialog.js +175 -0
  51. package/es/blocklet/oauth/federated-invite-dialog.js +83 -0
  52. package/es/blocklet/oauth/federated-join-dialog.js +111 -0
  53. package/es/blocklet/oauth/federated-site-list.js +338 -0
  54. package/es/blocklet/oauth/federated.js +81 -0
  55. package/es/blocklet/oauth/index.js +69 -0
  56. package/es/blocklet/overview.js +293 -0
  57. package/es/blocklet/page-group.js +19 -0
  58. package/es/blocklet/preferences/app-sk.js +142 -0
  59. package/es/blocklet/preferences/index.js +305 -0
  60. package/es/blocklet/purchase/common.js +95 -0
  61. package/es/blocklet/purchase/component-purchase.js +237 -0
  62. package/es/blocklet/purchase/index.js +4 -0
  63. package/es/blocklet/router/action/add-domain-alias.js +167 -0
  64. package/es/blocklet/router/action/add-rule.js +211 -0
  65. package/es/blocklet/router/action/config-routing-rule.js +232 -0
  66. package/es/blocklet/router/action/delete-domain-alias.js +99 -0
  67. package/es/blocklet/router/action/delete-rule.js +108 -0
  68. package/es/blocklet/router/action/update-rule.js +209 -0
  69. package/es/blocklet/router/domain-actions.js +64 -0
  70. package/es/blocklet/router/domain-status.js +88 -0
  71. package/es/blocklet/router/rule-actions.js +66 -0
  72. package/es/blocklet/router/rule-list.js +190 -0
  73. package/es/blocklet/router/util.js +131 -0
  74. package/es/blocklet/runtime-info.js +68 -0
  75. package/es/blocklet/status.js +91 -0
  76. package/es/blocklet/storage/action.js +134 -0
  77. package/es/blocklet/storage/backups.js +241 -0
  78. package/es/blocklet/storage/connect-to.js +373 -0
  79. package/es/blocklet/storage/connected.js +198 -0
  80. package/es/blocklet/storage/delete.js +113 -0
  81. package/es/blocklet/storage/disconnect.js +243 -0
  82. package/es/blocklet/storage/index.js +19 -0
  83. package/es/blocklet/storage/item.js +558 -0
  84. package/es/blocklet/storage/preview-nft.js +286 -0
  85. package/es/blocklet/transfer-owner.js +198 -0
  86. package/es/blocklet/types.js +18 -0
  87. package/es/blocklet/util.js +145 -0
  88. package/es/blocklet/version.js +141 -0
  89. package/es/card-selector.js +134 -0
  90. package/es/certificate.js +105 -0
  91. package/es/chain.js +13 -0
  92. package/es/click-to-copy.js +22 -0
  93. package/es/confirm.js +149 -0
  94. package/es/contexts/audit-log.js +152 -0
  95. package/es/contexts/blocklet.js +10 -0
  96. package/es/contexts/deleting-blocklets.js +70 -0
  97. package/es/contexts/node.js +17 -0
  98. package/es/contexts/session.js +8 -0
  99. package/es/contexts/team.js +10 -0
  100. package/es/delete-confirm.js +121 -0
  101. package/es/did-address.js +46 -0
  102. package/es/dot.js +14 -0
  103. package/es/exchange-passport.js +102 -0
  104. package/es/form/form-select-input.js +184 -0
  105. package/es/form/form-text-input.js +178 -0
  106. package/es/form/form-wrapper.js +88 -0
  107. package/es/form/input-triggers.js +98 -0
  108. package/es/form/required.js +8 -0
  109. package/es/hooks/blocklet.js +229 -0
  110. package/es/hooks/confirm.js +90 -0
  111. package/es/hooks/mobile-width.js +11 -0
  112. package/es/hooks/url-evaluation.js +155 -0
  113. package/es/hooks/use-app-logo.js +16 -0
  114. package/es/hooks/use-backup-progress.js +31 -0
  115. package/es/hooks/use-blocklet-info-for-connect-did-spaces.js +50 -0
  116. package/es/hooks/use-bundle-logo.js +27 -0
  117. package/es/hooks/use-navigation.js +347 -0
  118. package/es/hooks/use-passport-id.js +14 -0
  119. package/es/hooks/use-subscription.js +22 -0
  120. package/es/icons/empty-space-nft.svg +59 -0
  121. package/es/icons/empty-spaces-nft.svg +58 -0
  122. package/es/icons/long-arrow.svg +5 -0
  123. package/es/icons/space-connected.svg +3 -0
  124. package/es/icons/space-disconnect.svg +3 -0
  125. package/es/index.js +3 -0
  126. package/es/invitation/invitation-app.js +58 -0
  127. package/es/invitation/invitation-login.js +68 -0
  128. package/es/invitation/invitation-passport.js +144 -0
  129. package/es/invitation/invitation-receive.js +138 -0
  130. package/es/invitation/invitation-success.js +93 -0
  131. package/es/invitation/invitation-user.js +90 -0
  132. package/es/invitation/invitation.js +90 -0
  133. package/es/issue-passport.js +142 -0
  134. package/es/launch-blocklet/content-layout.js +58 -0
  135. package/es/launch-blocklet/page-header.js +43 -0
  136. package/es/layout/addon.js +114 -0
  137. package/es/layout/feedback.js +55 -0
  138. package/es/locales/en.js +1534 -0
  139. package/es/locales/index.js +9 -0
  140. package/es/locales/zh.js +1537 -0
  141. package/es/logs/clock.js +11 -0
  142. package/es/logs/download.js +132 -0
  143. package/es/logs/log-terminal.js +253 -0
  144. package/es/lost-passport.js +452 -0
  145. package/es/nav-logo.js +219 -0
  146. package/es/passport-tag.js +43 -0
  147. package/es/permission.js +57 -0
  148. package/es/relative-time.js +53 -0
  149. package/es/result-message.js +11 -0
  150. package/es/schema-form/color-input.js +98 -0
  151. package/es/schema-form/common-prop-types.js +13 -0
  152. package/es/schema-form/index.js +215 -0
  153. package/es/schema-form/passport-input.js +54 -0
  154. package/es/schema-form/text-input.js +57 -0
  155. package/es/store/add.js +179 -0
  156. package/es/store/delete.js +96 -0
  157. package/es/store/item.js +76 -0
  158. package/es/subscription.js +144 -0
  159. package/es/table-icons.js +34 -0
  160. package/es/table.js +52 -0
  161. package/es/tag.js +21 -0
  162. package/es/team/members/actions.js +89 -0
  163. package/es/team/members/index.js +636 -0
  164. package/es/team/members/invitations.js +188 -0
  165. package/es/team/members/invite-member.js +208 -0
  166. package/es/team/members/issue-passport.js +152 -0
  167. package/es/team/members/member.js +408 -0
  168. package/es/team/members/passport-issuances.js +155 -0
  169. package/es/team/members/passports.js +364 -0
  170. package/es/team/members/toggle-user-approval.js +122 -0
  171. package/es/team/members/transfer-node.js +256 -0
  172. package/es/team/members/util.js +14 -0
  173. package/es/team/passports/color.js +126 -0
  174. package/es/team/passports/detail.js +312 -0
  175. package/es/team/passports/index.js +282 -0
  176. package/es/team/passports/mutate-role.js +198 -0
  177. package/es/team/passports/trusted-factories.js +221 -0
  178. package/es/team/passports/trusted-factory.js +343 -0
  179. package/es/team/passports/trusted-issuer.js +296 -0
  180. package/es/team/passports/trusted-issuers.js +226 -0
  181. package/es/team/search-input.js +46 -0
  182. package/es/team/styles/dialog.js +72 -0
  183. package/es/team/styles/list-header.js +31 -0
  184. package/es/util/api.js +6 -0
  185. package/es/util/constants.js +2 -0
  186. package/es/util/index.js +598 -0
  187. package/es/util/mode.js +4 -0
  188. package/es/util/space-gateway.js +51 -0
  189. package/es/util/spaces.js +151 -0
  190. package/es/who-can-access/config.js +38 -0
  191. package/es/wrap-locale.js +15 -0
  192. package/lib/blocklet/component/space-connector.js +1 -1
  193. package/lib/blocklet/component/space-selector.js +1 -1
  194. package/lib/blocklet/storage/backups.js +1 -1
  195. package/lib/blocklet/storage/connect-to.js +1 -1
  196. package/lib/blocklet/storage/connected.js +1 -1
  197. package/lib/blocklet/storage/disconnect.js +1 -1
  198. package/lib/blocklet/storage/index.js +1 -1
  199. package/lib/blocklet/storage/item.js +1 -1
  200. package/lib/invitation/invitation-receive.js +1 -1
  201. package/lib/team/passports/trusted-factory.js +1 -1
  202. package/package.json +81 -18
@@ -0,0 +1,57 @@
1
+ import PropTypes from 'prop-types';
2
+ import { useSessionContext } from './contexts/session';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ export default function Permission({
5
+ permission,
6
+ role,
7
+ component,
8
+ children
9
+ }) {
10
+ const {
11
+ session
12
+ } = useSessionContext();
13
+ let can = true;
14
+ const permissions = [].concat(permission).filter(Boolean);
15
+ const roles = [].concat(role).filter(Boolean);
16
+ if (permissions.length) {
17
+ const userPermissions = session.user && session.user.permissions || [];
18
+ can = permissions.some(p => userPermissions.includes(p));
19
+ }
20
+ if (can && roles.length) {
21
+ can = roles.includes(session.user.role);
22
+ }
23
+ if (typeof component === 'function') {
24
+ return component(can);
25
+ }
26
+ if (typeof children === 'function') {
27
+ return children(can);
28
+ }
29
+ if (can) {
30
+ return component || children || null;
31
+ }
32
+ return null;
33
+ }
34
+ export function withPermission(Component, permissionName, role) {
35
+ return function WithPermission(props) {
36
+ return /*#__PURE__*/_jsx(Permission, {
37
+ permission: permissionName,
38
+ role: role,
39
+ children: hasPermission => /*#__PURE__*/_jsx(Component, {
40
+ ...props,
41
+ hasPermission: hasPermission
42
+ })
43
+ });
44
+ };
45
+ }
46
+ Permission.propTypes = {
47
+ permission: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
48
+ role: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
49
+ component: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
50
+ children: PropTypes.oneOfType([PropTypes.func, PropTypes.node])
51
+ };
52
+ Permission.defaultProps = {
53
+ permission: '',
54
+ role: '',
55
+ component: null,
56
+ children: null
57
+ };
@@ -0,0 +1,53 @@
1
+ import PropTypes from 'prop-types';
2
+ import prettyMs from 'pretty-ms-i18n';
3
+ import Tooltip from '@mui/material/Tooltip';
4
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
5
+ import { formatPrettyMsLocale, formatToDatetime } from './util';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export default function RelativeTime({
8
+ value
9
+ }) {
10
+ const {
11
+ t,
12
+ locale
13
+ } = useLocaleContext();
14
+ if (!value) {
15
+ return '-';
16
+ }
17
+ const prettyOption = {
18
+ locale: formatPrettyMsLocale(locale),
19
+ compact: true
20
+ };
21
+ const valTime = new Date(value).getTime();
22
+ const now = Date.now();
23
+ if (valTime > now) {
24
+ const time = prettyMs(valTime - now, prettyOption);
25
+ return /*#__PURE__*/_jsx(Tooltip, {
26
+ title: formatToDatetime(value, locale),
27
+ placement: "top-end",
28
+ enterTouchDelay: 0,
29
+ children: /*#__PURE__*/_jsx("span", {
30
+ children: t('common.afterTime', {
31
+ time
32
+ })
33
+ })
34
+ });
35
+ }
36
+ const time = prettyMs(now - valTime, prettyOption);
37
+ return /*#__PURE__*/_jsx(Tooltip, {
38
+ title: formatToDatetime(value, locale),
39
+ placement: "top-end",
40
+ enterTouchDelay: 0,
41
+ children: /*#__PURE__*/_jsx("span", {
42
+ children: t('common.timeAgo', {
43
+ time
44
+ })
45
+ })
46
+ });
47
+ }
48
+ RelativeTime.propTypes = {
49
+ value: PropTypes.any
50
+ };
51
+ RelativeTime.defaultProps = {
52
+ value: ''
53
+ };
@@ -0,0 +1,11 @@
1
+ import styled from '@emotion/styled';
2
+ import ResultMessage from '@blocklet/launcher-layout/lib/launch-result-message';
3
+ const StyledResultMessage = styled(ResultMessage)`
4
+ && .result-footer {
5
+ height: 120px;
6
+ > div {
7
+ flex-wrap: wrap;
8
+ }
9
+ }
10
+ `;
11
+ export default StyledResultMessage;
@@ -0,0 +1,98 @@
1
+ import { useState, useRef, useEffect } from 'react';
2
+ import Box from '@mui/material/Box';
3
+ import Popover from '@mui/material/Popover';
4
+ import { ChromePicker } from 'react-color';
5
+ import commonPropTypes from './common-prop-types';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ export default function ColorInput({
9
+ editing,
10
+ value,
11
+ onChange
12
+ }) {
13
+ const [open, setOpen] = useState(false);
14
+ const colorElm = useRef();
15
+ const colorValue = useRef(value);
16
+
17
+ // auto open color picker when editing, should wait the useRef to be ready
18
+ useEffect(() => {
19
+ let timer = null;
20
+ if (editing) {
21
+ timer = setTimeout(() => {
22
+ setOpen(true);
23
+ }, 50);
24
+ }
25
+ return () => {
26
+ clearTimeout(timer);
27
+ };
28
+ }, [editing]);
29
+ const onColorChange = color => {
30
+ colorValue.current = color;
31
+ onChange(color);
32
+ };
33
+ const handleEnterKeyDown = () => {
34
+ setOpen(false);
35
+ onChange(colorValue.current);
36
+ };
37
+ const ReadView = /*#__PURE__*/_jsx(Box, {
38
+ className: "form-item-input slot",
39
+ px: 1,
40
+ children: /*#__PURE__*/_jsxs(Box, {
41
+ display: "flex",
42
+ alignItems: "center",
43
+ children: [value, value !== 'auto' && /*#__PURE__*/_jsx("div", {
44
+ style: {
45
+ marginLeft: 4,
46
+ backgroundColor: value,
47
+ width: '1em',
48
+ height: '1em',
49
+ borderRadius: '0.2em'
50
+ }
51
+ })]
52
+ })
53
+ });
54
+ const EditView = /*#__PURE__*/_jsxs(Box, {
55
+ display: "flex",
56
+ flexGrow: 1,
57
+ alignItems: "center",
58
+ height: "40px",
59
+ onKeyDown: handleEnterKeyDown,
60
+ children: [/*#__PURE__*/_jsx(Box, {
61
+ display: "flex",
62
+ alignItems: "center",
63
+ onClick: () => setOpen(true),
64
+ children: /*#__PURE__*/_jsx("div", {
65
+ ref: colorElm,
66
+ style: {
67
+ flexShrink: 0,
68
+ marginLeft: '8px',
69
+ backgroundColor: value,
70
+ width: '32px',
71
+ height: '32px',
72
+ boxSizing: 'border-box',
73
+ borderRadius: '8px',
74
+ border: '1px solid #eee',
75
+ cursor: value === 'auto' ? 'default' : 'pointer'
76
+ }
77
+ })
78
+ }), /*#__PURE__*/_jsx(Popover, {
79
+ open: open,
80
+ anchorEl: colorElm.current,
81
+ onClose: () => setOpen(false),
82
+ anchorOrigin: {
83
+ vertical: 'bottom',
84
+ horizontal: 'center'
85
+ },
86
+ transformOrigin: {
87
+ vertical: 'top',
88
+ horizontal: 'center'
89
+ },
90
+ children: /*#__PURE__*/_jsx(ChromePicker, {
91
+ color: value,
92
+ onChange: c => onColorChange(c.hex)
93
+ })
94
+ })]
95
+ });
96
+ return editing ? EditView : ReadView;
97
+ }
98
+ ColorInput.propTypes = commonPropTypes;
@@ -0,0 +1,13 @@
1
+ import PropTypes from 'prop-types';
2
+ export default {
3
+ description: PropTypes.string,
4
+ editing: PropTypes.bool,
5
+ onChange: PropTypes.func,
6
+ required: PropTypes.bool,
7
+ // eslint-disable-next-line react/no-unused-prop-types
8
+ value: PropTypes.any,
9
+ // eslint-disable-next-line react/no-unused-prop-types
10
+ componentProps: PropTypes.object,
11
+ render: PropTypes.func,
12
+ renderFormItem: PropTypes.func
13
+ };
@@ -0,0 +1,215 @@
1
+ import { useState, useRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from '@emotion/styled';
4
+ import Box from '@mui/material/Box';
5
+ import EditIcon from '@arcblock/icons/lib/EditIcon';
6
+ import CloseIcon from '@mui/icons-material/Close';
7
+ import DoneIcon from '@mui/icons-material/Done';
8
+ import IconButton from '@mui/material/IconButton';
9
+ import CircularProgress from '@mui/material/CircularProgress';
10
+ import ColorInput from './color-input';
11
+ import TextInput from './text-input';
12
+ import PassportInput from './passport-input';
13
+ import Required from '../form/required';
14
+ import FormWrapper from '../form/form-wrapper';
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ import { jsxs as _jsxs } from "react/jsx-runtime";
17
+ import { Fragment as _Fragment } from "react/jsx-runtime";
18
+ function getComponent(item, {
19
+ editing = false
20
+ }) {
21
+ const {
22
+ componentType = 'input',
23
+ render,
24
+ renderFormItem
25
+ } = item;
26
+ // if provided renderItem and editing is true, use it
27
+ if (editing && renderFormItem) {
28
+ return renderFormItem;
29
+ }
30
+
31
+ // if provided render and editing is false, use it
32
+ if (!editing && render) {
33
+ return render;
34
+ }
35
+ const componentMap = {
36
+ input: TextInput,
37
+ color: ColorInput,
38
+ passport: PassportInput
39
+ };
40
+ return componentMap[componentType?.toLowerCase()];
41
+ }
42
+ export default function SchemaForm({
43
+ schema,
44
+ loading,
45
+ value,
46
+ defaultValue,
47
+ onChange,
48
+ style,
49
+ disabled
50
+ }) {
51
+ const isControlled = Object.prototype.toString.call(value) === '[object Object]';
52
+ const [editingItem, setEditingItem] = useState(null);
53
+ const [formValues, setFormValues] = useState(isControlled ? value : defaultValue);
54
+ const editingItemInitialValue = useRef();
55
+ function onFormItemChange(item, changeValue, action) {
56
+ const {
57
+ key,
58
+ secure
59
+ } = item;
60
+ const oldValue = formValues[key];
61
+ const isChanged = oldValue !== changeValue;
62
+ const newValues = {
63
+ ...formValues,
64
+ [key]: changeValue
65
+ };
66
+ if (isChanged) {
67
+ setFormValues(newValues);
68
+ }
69
+ onChange({
70
+ [key]: changeValue
71
+ }, {
72
+ allValues: newValues,
73
+ action,
74
+ currentItem: item
75
+ });
76
+
77
+ // hide secure text after confirm
78
+ if (action === 'confirm' && secure) {
79
+ setFormValues({
80
+ ...formValues,
81
+ [key]: '__encrypted__'
82
+ });
83
+ }
84
+ if (['confirm', 'cancel'].includes(action)) {
85
+ onItemEditingStatusChange(null);
86
+ } else {
87
+ onItemEditingStatusChange(item);
88
+ }
89
+ }
90
+ function onItemEditingStatusChange(item) {
91
+ if (item) {
92
+ editingItemInitialValue.current = formValues[item.key];
93
+ setEditingItem(item);
94
+ return;
95
+ }
96
+ editingItemInitialValue.current = null;
97
+ setEditingItem(null);
98
+ }
99
+ function getValue(item, {
100
+ editing = false
101
+ }) {
102
+ const {
103
+ key
104
+ } = item;
105
+ const currentValue = isControlled ? value[key] : formValues[key];
106
+ if (currentValue === '__encrypted__') {
107
+ if (!editing) {
108
+ return '******';
109
+ }
110
+ return '';
111
+ }
112
+ return currentValue;
113
+ }
114
+ return /*#__PURE__*/_jsx(StyledFormWrapper, {
115
+ className: "form",
116
+ style: style,
117
+ children: schema?.map(x => {
118
+ const {
119
+ key,
120
+ description,
121
+ required,
122
+ hidden = false,
123
+ componentProps = {}
124
+ } = x;
125
+ if (hidden) {
126
+ return null;
127
+ }
128
+ const editing = !!(editingItem && key === editingItem.key);
129
+ const currentValue = getValue(x, {
130
+ editing
131
+ });
132
+ // get component by componentType
133
+ const CurrentComponent = getComponent(x, {
134
+ editing
135
+ });
136
+ const renderComponentProps = {
137
+ inputProps: {
138
+ 'data-cy': 'schema-form-item-component'
139
+ },
140
+ key,
141
+ description,
142
+ editing,
143
+ value: currentValue,
144
+ onChange: (changeValue, action = 'change') => onFormItemChange(x, changeValue, action),
145
+ componentProps
146
+ };
147
+ return /*#__PURE__*/_jsxs(Box, {
148
+ className: "form-item",
149
+ children: [/*#__PURE__*/_jsxs(Box, {
150
+ className: "form-item-label",
151
+ style: {
152
+ color: required && !currentValue ? '#ff0000' : '#333'
153
+ },
154
+ children: [description, required && /*#__PURE__*/_jsx(Required, {})]
155
+ }), /*#__PURE__*/_jsxs(Box, {
156
+ className: "form-item-body",
157
+ children: [/*#__PURE__*/_jsx(Box, {
158
+ className: "form-item-input",
159
+ children: /*#__PURE__*/_jsx(CurrentComponent, {
160
+ ...renderComponentProps
161
+ })
162
+ }), /*#__PURE__*/_jsx(Box, {
163
+ className: "form-item-action",
164
+ children: editing ? /*#__PURE__*/_jsxs(_Fragment, {
165
+ children: [/*#__PURE__*/_jsx(IconButton, {
166
+ "data-cy": "schema-form-item-confirm",
167
+ onClick: () => {
168
+ onFormItemChange(x, currentValue, 'confirm');
169
+ },
170
+ disabled: disabled || loading,
171
+ size: "large",
172
+ children: loading ? /*#__PURE__*/_jsx(CircularProgress, {
173
+ size: 24
174
+ }) : /*#__PURE__*/_jsx(DoneIcon, {})
175
+ }), /*#__PURE__*/_jsx(IconButton, {
176
+ "data-cy": "schema-form-item-cancel",
177
+ onClick: () => {
178
+ onFormItemChange(x, editingItemInitialValue.current, 'cancel');
179
+ },
180
+ disabled: disabled || loading,
181
+ size: "large",
182
+ children: /*#__PURE__*/_jsx(CloseIcon, {})
183
+ })]
184
+ }) : /*#__PURE__*/_jsx(IconButton, {
185
+ "data-cy": "schema-form-item-edit",
186
+ onClick: () => {
187
+ onFormItemChange(x, formValues[key], 'edit');
188
+ },
189
+ disabled: disabled || editingItem,
190
+ size: "large",
191
+ children: /*#__PURE__*/_jsx(EditIcon, {})
192
+ })
193
+ })]
194
+ })]
195
+ }, key);
196
+ })
197
+ });
198
+ }
199
+ SchemaForm.propTypes = {
200
+ schema: PropTypes.array.isRequired,
201
+ loading: PropTypes.bool,
202
+ onChange: PropTypes.func.isRequired,
203
+ value: PropTypes.object,
204
+ defaultValue: PropTypes.object,
205
+ style: PropTypes.object,
206
+ disabled: PropTypes.bool
207
+ };
208
+ SchemaForm.defaultProps = {
209
+ loading: false,
210
+ value: undefined,
211
+ defaultValue: {},
212
+ style: {},
213
+ disabled: false
214
+ };
215
+ const StyledFormWrapper = styled(FormWrapper)``;
@@ -0,0 +1,54 @@
1
+ import PropTypes from 'prop-types';
2
+ import Box from '@mui/material/Box';
3
+ import createPassportSvg from '@abtnode/auth/lib/util/create-passport-svg';
4
+ import { getPassportColorFromDid } from '@arcblock/nft-display';
5
+ import { getDisplayName } from '@blocklet/meta/lib/util';
6
+ import ColorInput from './color-input';
7
+ import commonPropTypes from './common-prop-types';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ export default function PassportInput({
11
+ editing,
12
+ value,
13
+ onChange,
14
+ componentProps,
15
+ ...rest
16
+ }) {
17
+ const {
18
+ blocklet
19
+ } = componentProps;
20
+ const color = value === 'auto' ? getPassportColorFromDid(blocklet.appDid) : value;
21
+ return /*#__PURE__*/_jsxs(Box, {
22
+ display: "flex",
23
+ alignItems: "center",
24
+ children: [/*#__PURE__*/_jsx("img", {
25
+ style: {
26
+ width: 96,
27
+ marginRight: 12
28
+ },
29
+ alt: "",
30
+ src: createPassportSvg({
31
+ title: 'Owner',
32
+ issuer: getDisplayName(blocklet),
33
+ issuerDid: blocklet.appDid,
34
+ ownerName: 'Your Name',
35
+ ownerDid: blocklet.appDid,
36
+ isDataUrl: true,
37
+ preferredColor: value || 'auto'
38
+ })
39
+ }), /*#__PURE__*/_jsx(ColorInput, {
40
+ ...rest,
41
+ editing: editing,
42
+ value: editing ? color : value,
43
+ onChange: onChange,
44
+ componentProps: componentProps
45
+ })]
46
+ });
47
+ }
48
+ PassportInput.propTypes = {
49
+ ...commonPropTypes,
50
+ componentProps: PropTypes.shape({
51
+ blocklet: PropTypes.object.isRequired
52
+ }).isRequired
53
+ };
54
+ PassportInput.defaultProps = {};
@@ -0,0 +1,57 @@
1
+ import { useRef } from 'react';
2
+ import Box from '@mui/material/Box';
3
+ import TextField from '@mui/material/TextField';
4
+ import commonPropTypes from './common-prop-types';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ export default function TextInput({
7
+ editing,
8
+ description,
9
+ value,
10
+ onChange,
11
+ componentProps,
12
+ ...rest
13
+ }) {
14
+ const {
15
+ placeholder
16
+ } = componentProps;
17
+ const inputValue = useRef(value);
18
+
19
+ // enter keydown
20
+ const handleKeydown = e => {
21
+ if (e.key === 'Enter') {
22
+ onChange(inputValue.current, 'confirm');
23
+ }
24
+ };
25
+ const onInputChange = changeValue => {
26
+ inputValue.current = changeValue;
27
+ onChange(changeValue);
28
+ };
29
+ if (editing) {
30
+ return /*#__PURE__*/_jsx(TextField, {
31
+ style: {
32
+ flex: 1
33
+ },
34
+ fullWidth: true,
35
+ value: value,
36
+ onChange: e => {
37
+ e.persist();
38
+ onInputChange(e.target.value);
39
+ },
40
+ autoFocus: true,
41
+ size: "small",
42
+ variant: "outlined",
43
+ placeholder: description || placeholder,
44
+ onKeyDown: handleKeydown,
45
+ ...rest
46
+ });
47
+ }
48
+ return /*#__PURE__*/_jsx(Box, {
49
+ px: 1,
50
+ className: "form-item-input slot",
51
+ children: value
52
+ });
53
+ }
54
+ TextInput.propTypes = commonPropTypes;
55
+ TextInput.defaultProps = {
56
+ componentProps: {}
57
+ };