@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,184 @@
1
+ import React, { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Box from '@mui/material/Box';
4
+ import CircularProgress from '@mui/material/CircularProgress';
5
+ import CloseIcon from '@mui/icons-material/Close';
6
+ import DoneIcon from '@mui/icons-material/Done';
7
+ import IconButton from '@mui/material/IconButton';
8
+ import MenuItem from '@mui/material/MenuItem';
9
+ import Select from '@mui/material/Select';
10
+ import Chip from '@mui/material/Chip';
11
+ import { useTheme } from '@mui/material/styles';
12
+ import Required from './required';
13
+ import FormWrapper from './form-wrapper';
14
+ import InputTriggers from './input-triggers';
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
+ const ITEM_HEIGHT = 48;
19
+ const ITEM_PADDING_TOP = 8;
20
+ const MenuProps = {
21
+ PaperProps: {
22
+ style: {
23
+ maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,
24
+ width: 250
25
+ }
26
+ }
27
+ };
28
+ const getStyles = (current, selected, theme) => {
29
+ return {
30
+ fontWeight: selected.indexOf(current) === -1 ? theme.typography.fontWeightRegular : theme.typography.fontWeightMedium
31
+ };
32
+ };
33
+ export default function FormSelectInput({
34
+ label,
35
+ disabled,
36
+ required,
37
+ initialValue,
38
+ onChange,
39
+ style,
40
+ onSubmit,
41
+ triggers,
42
+ options,
43
+ formatterBeforeSubmit,
44
+ ...rest
45
+ }) {
46
+ const theme = useTheme();
47
+ const [editing, setEditing] = useState(false);
48
+ const [loading, setLoading] = useState(false);
49
+ const [defaultValue, setDefaultValue] = useState(initialValue);
50
+ const [value, setValue] = useState(defaultValue);
51
+ const handleSubmit = async () => {
52
+ setLoading(true);
53
+ try {
54
+ const shouldUpdate = await onSubmit(typeof formatterBeforeSubmit === 'function' ? formatterBeforeSubmit(value) : value);
55
+ if (shouldUpdate === false) {
56
+ setValue(defaultValue);
57
+ } else {
58
+ setValue(value);
59
+ setDefaultValue(value);
60
+ }
61
+ } catch (err) {
62
+ setValue(defaultValue);
63
+ } finally {
64
+ setLoading(false);
65
+ setEditing(false);
66
+ }
67
+ };
68
+ const onInputChange = e => {
69
+ let {
70
+ value: selected
71
+ } = e.target;
72
+ selected = typeof selected === 'string' ? selected.split(',') : selected;
73
+ setValue(selected);
74
+ onChange(selected);
75
+ };
76
+ const input = editing ? /*#__PURE__*/_jsx(Select, {
77
+ value: value,
78
+ onChange: onInputChange,
79
+ fullWidth: true,
80
+ multiple: true,
81
+ variant: "outlined",
82
+ margin: "dense",
83
+ renderValue: selected => /*#__PURE__*/_jsx(Box, {
84
+ sx: {
85
+ display: 'flex',
86
+ flexWrap: 'wrap'
87
+ },
88
+ children: selected.filter(x => options.some(o => o.code === x)).map(x => /*#__PURE__*/_jsx(Chip, {
89
+ label: options.find(o => o.code === x).name,
90
+ style: {
91
+ marginRight: 8
92
+ },
93
+ size: "small"
94
+ }, x))
95
+ }),
96
+ MenuProps: MenuProps,
97
+ ...rest,
98
+ children: options.map(x => /*#__PURE__*/_jsx(MenuItem, {
99
+ value: x.code,
100
+ style: getStyles(x.code, value, theme),
101
+ children: x.name
102
+ }, x.code))
103
+ }) : /*#__PURE__*/_jsx(Box, {
104
+ px: 1,
105
+ className: "form-item-input slot",
106
+ style: {
107
+ whiteSpace: 'pre-wrap'
108
+ },
109
+ children: value.filter(x => options.some(o => o.code === x)).map(x => /*#__PURE__*/_jsx(Chip, {
110
+ label: options.find(o => o.code === x).name,
111
+ style: {
112
+ marginRight: 8
113
+ },
114
+ size: "small"
115
+ }, x))
116
+ });
117
+ return /*#__PURE__*/_jsx(FormWrapper, {
118
+ className: "form",
119
+ style: style,
120
+ children: /*#__PURE__*/_jsxs(Box, {
121
+ className: "form-item",
122
+ children: [/*#__PURE__*/_jsxs(Box, {
123
+ className: "form-item-label",
124
+ children: [label, required && /*#__PURE__*/_jsx(Required, {})]
125
+ }), /*#__PURE__*/_jsxs(Box, {
126
+ className: "form-item-body",
127
+ children: [/*#__PURE__*/_jsx(Box, {
128
+ className: "form-item-input",
129
+ children: input
130
+ }), /*#__PURE__*/_jsx(Box, {
131
+ className: "form-item-action",
132
+ children: editing ? /*#__PURE__*/_jsxs(_Fragment, {
133
+ children: [/*#__PURE__*/_jsx(IconButton, {
134
+ "data-cy": "schema-form-item-confirm",
135
+ onClick: handleSubmit,
136
+ disabled: disabled || loading,
137
+ size: "large",
138
+ children: loading ? /*#__PURE__*/_jsx(CircularProgress, {
139
+ size: 24
140
+ }) : /*#__PURE__*/_jsx(DoneIcon, {})
141
+ }), /*#__PURE__*/_jsx(IconButton, {
142
+ "data-cy": "schema-form-item-cancel",
143
+ onClick: () => {
144
+ setValue(defaultValue);
145
+ setEditing(false);
146
+ },
147
+ disabled: disabled || loading,
148
+ size: "large",
149
+ children: /*#__PURE__*/_jsx(CloseIcon, {})
150
+ })]
151
+ }) : /*#__PURE__*/_jsx(InputTriggers, {
152
+ triggers: triggers,
153
+ onEnterEdit: () => setEditing(true),
154
+ disabled: disabled
155
+ })
156
+ })]
157
+ })]
158
+ })
159
+ });
160
+ }
161
+ FormSelectInput.propTypes = {
162
+ style: PropTypes.object,
163
+ onSubmit: PropTypes.func,
164
+ onChange: PropTypes.func,
165
+ label: PropTypes.string,
166
+ initialValue: PropTypes.string,
167
+ required: PropTypes.bool,
168
+ disabled: PropTypes.bool,
169
+ triggers: PropTypes.array,
170
+ options: PropTypes.array,
171
+ formatterBeforeSubmit: PropTypes.func
172
+ };
173
+ FormSelectInput.defaultProps = {
174
+ style: {},
175
+ onSubmit: () => {},
176
+ onChange: () => {},
177
+ label: '',
178
+ initialValue: '',
179
+ required: false,
180
+ disabled: false,
181
+ triggers: [],
182
+ options: [],
183
+ formatterBeforeSubmit: x => x.join(',')
184
+ };
@@ -0,0 +1,178 @@
1
+ import React, { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Box from '@mui/material/Box';
4
+ import TextField from '@mui/material/TextField';
5
+ import CircularProgress from '@mui/material/CircularProgress';
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 Required from './required';
10
+ import FormWrapper from './form-wrapper';
11
+ import InputTriggers from './input-triggers';
12
+
13
+ /**
14
+ * @param {*} value value 空时, null 表示未修改, '' 表示已修改
15
+ * @returns
16
+ */
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { jsxs as _jsxs } from "react/jsx-runtime";
19
+ import { Fragment as _Fragment } from "react/jsx-runtime";
20
+ const getDisplayValue = (value, secure, initialValue) => {
21
+ if (value === null && secure && initialValue) {
22
+ return '******';
23
+ }
24
+ if (!value) {
25
+ return '';
26
+ }
27
+ if (secure) {
28
+ return '******';
29
+ }
30
+ return value;
31
+ };
32
+ export default function FormTextInput({
33
+ label,
34
+ disabled,
35
+ required,
36
+ initialValue,
37
+ onChange,
38
+ placeholder,
39
+ style,
40
+ onSubmit,
41
+ secure,
42
+ triggers,
43
+ formatterBeforeSubmit,
44
+ ...rest
45
+ }) {
46
+ const [editing, setEditing] = useState(false);
47
+ const [loading, setLoading] = useState(false);
48
+
49
+ // value 空时, null 表示未修改, '' 表示已修改
50
+ const [defaultValue, setDefaultValue] = useState(secure && initialValue === '__encrypted__' ? null : initialValue);
51
+ const [value, setValue] = useState(defaultValue);
52
+ const handleSubmit = async () => {
53
+ setLoading(true);
54
+ try {
55
+ const shouldUpdate = await onSubmit(value);
56
+ if (shouldUpdate === false) {
57
+ setValue(defaultValue);
58
+ } else {
59
+ let tmpValue = value;
60
+ if (typeof formatterBeforeSubmit === 'function') {
61
+ tmpValue = formatterBeforeSubmit(value);
62
+ }
63
+ setValue(tmpValue);
64
+ setDefaultValue(tmpValue);
65
+ }
66
+ } catch (err) {
67
+ setValue(defaultValue);
68
+ } finally {
69
+ setLoading(false);
70
+ setEditing(false);
71
+ }
72
+ };
73
+ const onInputChange = changeValue => {
74
+ setValue(changeValue);
75
+ onChange(changeValue);
76
+ };
77
+
78
+ // enter keydown
79
+ const handleKeydown = e => {
80
+ if (e.key === 'Enter') {
81
+ handleSubmit();
82
+ }
83
+ };
84
+ const input = editing ? /*#__PURE__*/_jsx(TextField, {
85
+ style: {
86
+ flex: 1
87
+ },
88
+ fullWidth: true,
89
+ value: value,
90
+ onChange: e => {
91
+ onInputChange(e.target.value);
92
+ },
93
+ autoFocus: true,
94
+ size: "small",
95
+ variant: "outlined",
96
+ placeholder: placeholder,
97
+ onKeyDown: handleKeydown,
98
+ disabled: disabled,
99
+ type: secure ? 'password' : 'text',
100
+ ...rest
101
+ }) : /*#__PURE__*/_jsx(Box, {
102
+ px: 1,
103
+ className: "form-item-input slot",
104
+ style: {
105
+ whiteSpace: 'pre-wrap'
106
+ },
107
+ children: getDisplayValue(value, secure, initialValue)
108
+ });
109
+ return /*#__PURE__*/_jsx(FormWrapper, {
110
+ className: "form",
111
+ style: style,
112
+ children: /*#__PURE__*/_jsxs(Box, {
113
+ className: "form-item",
114
+ children: [/*#__PURE__*/_jsxs(Box, {
115
+ className: "form-item-label",
116
+ children: [label, required && /*#__PURE__*/_jsx(Required, {})]
117
+ }), /*#__PURE__*/_jsxs(Box, {
118
+ className: "form-item-body",
119
+ children: [/*#__PURE__*/_jsx(Box, {
120
+ className: "form-item-input",
121
+ children: input
122
+ }), /*#__PURE__*/_jsx(Box, {
123
+ className: "form-item-action",
124
+ children: editing ? /*#__PURE__*/_jsxs(_Fragment, {
125
+ children: [/*#__PURE__*/_jsx(IconButton, {
126
+ "data-cy": "schema-form-item-confirm",
127
+ onClick: handleSubmit,
128
+ disabled: disabled || loading,
129
+ size: "large",
130
+ children: loading ? /*#__PURE__*/_jsx(CircularProgress, {
131
+ size: 24
132
+ }) : /*#__PURE__*/_jsx(DoneIcon, {})
133
+ }), /*#__PURE__*/_jsx(IconButton, {
134
+ "data-cy": "schema-form-item-cancel",
135
+ onClick: () => {
136
+ setValue(defaultValue);
137
+ setEditing(false);
138
+ },
139
+ disabled: disabled || loading,
140
+ size: "large",
141
+ children: /*#__PURE__*/_jsx(CloseIcon, {})
142
+ })]
143
+ }) : /*#__PURE__*/_jsx(InputTriggers, {
144
+ triggers: triggers,
145
+ onEnterEdit: () => setEditing(true),
146
+ disabled: disabled
147
+ })
148
+ })]
149
+ })]
150
+ })
151
+ });
152
+ }
153
+ FormTextInput.propTypes = {
154
+ style: PropTypes.object,
155
+ onSubmit: PropTypes.func,
156
+ onChange: PropTypes.func,
157
+ label: PropTypes.string,
158
+ initialValue: PropTypes.string,
159
+ placeholder: PropTypes.string,
160
+ required: PropTypes.bool,
161
+ disabled: PropTypes.bool,
162
+ secure: PropTypes.bool,
163
+ triggers: PropTypes.array,
164
+ formatterBeforeSubmit: PropTypes.func
165
+ };
166
+ FormTextInput.defaultProps = {
167
+ style: {},
168
+ onSubmit: () => {},
169
+ onChange: () => {},
170
+ label: '',
171
+ initialValue: '',
172
+ placeholder: '',
173
+ required: false,
174
+ disabled: false,
175
+ secure: false,
176
+ triggers: [],
177
+ formatterBeforeSubmit: null
178
+ };
@@ -0,0 +1,88 @@
1
+ import styled from '@emotion/styled';
2
+ import Box from '@mui/material/Box';
3
+ export default styled(Box)`
4
+ width: 100%;
5
+ flex-grow: 1;
6
+ overflow-y: auto;
7
+ ${props => props.theme.breakpoints.down('md')} {
8
+ width: 100%;
9
+ flex-shrink: 0;
10
+ padding: 0 24px;
11
+ transform: translate(0, 0);
12
+ /* max-height: 60vh; */
13
+ }
14
+
15
+ .form-item {
16
+ width: 100%;
17
+ margin-bottom: 24px;
18
+ position: relative;
19
+ ${props => props.theme.breakpoints.down('md')} {
20
+ flex-wrap: wrap;
21
+ justify-content: space-between;
22
+ width: 100%;
23
+ flex-shrink: 0;
24
+ }
25
+ }
26
+
27
+ .form-item-body {
28
+ display: flex;
29
+ align-items: center;
30
+ width: 100%;
31
+ margin-top: 4px;
32
+ }
33
+
34
+ .form-item-label {
35
+ line-height: 1.2;
36
+ font-size: 14px;
37
+ color: #888;
38
+ font-weight: bold;
39
+
40
+ ${props => props.theme.breakpoints.down('md')} {
41
+ text-align: left;
42
+ width: auto;
43
+ flex-grow: 1;
44
+ }
45
+ }
46
+
47
+ .form-item-input {
48
+ flex-grow: 1;
49
+ overflow: hidden;
50
+ white-space: nowrap;
51
+ text-overflow: ellipsis;
52
+
53
+ &.slot {
54
+ height: 40px;
55
+ line-height: 40px;
56
+ background: #f8f8f8;
57
+ font-size: 16px;
58
+
59
+ .MuiChip-root {
60
+ margin-top: -4px;
61
+ }
62
+ }
63
+
64
+ .MuiSelect-select {
65
+ padding: 8px;
66
+ }
67
+ }
68
+
69
+ .form-item-action {
70
+ // width: 100px;
71
+ text-align: left;
72
+ margin-left: 12px;
73
+ flex-shrink: 0;
74
+ ${props => props.theme.breakpoints.down('md')} {
75
+ width: auto;
76
+ margin-left: 0px;
77
+ }
78
+ .MuiIconButton-root {
79
+ padding: 8px;
80
+ svg {
81
+ fill: #888;
82
+ }
83
+ &.Mui-disabled {
84
+ opacity: 0.4;
85
+ }
86
+ }
87
+ }
88
+ `;
@@ -0,0 +1,98 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import EditIcon from '@arcblock/icons/lib/EditIcon';
4
+ import IconButton from '@mui/material/IconButton';
5
+ import Button from '@mui/material/Button';
6
+ import ButtonGroup from '@mui/material/ButtonGroup';
7
+ import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
8
+ import ClickAwayListener from '@mui/material/ClickAwayListener';
9
+ import Paper from '@mui/material/Paper';
10
+ import Popper from '@mui/material/Popper';
11
+ import MenuItem from '@mui/material/MenuItem';
12
+ import MenuList from '@mui/material/MenuList';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { jsxs as _jsxs } from "react/jsx-runtime";
15
+ import { Fragment as _Fragment } from "react/jsx-runtime";
16
+ export default function InputTriggers({
17
+ triggers,
18
+ onEnterEdit,
19
+ disabled
20
+ }) {
21
+ const anchorRef = React.useRef(null);
22
+ const [open, setOpen] = React.useState(false);
23
+ const handleTriggerClick = cb => {
24
+ setOpen(false);
25
+ cb();
26
+ };
27
+ const handleToggle = () => {
28
+ setOpen(prevOpen => !prevOpen);
29
+ };
30
+ const handleClose = event => {
31
+ if (anchorRef.current && anchorRef.current.contains(event.target)) {
32
+ return;
33
+ }
34
+ setOpen(false);
35
+ };
36
+ if (triggers.length === 0) {
37
+ return /*#__PURE__*/_jsx(IconButton, {
38
+ "data-cy": "schema-form-item-edit",
39
+ onClick: onEnterEdit,
40
+ disabled: disabled,
41
+ size: "large",
42
+ children: /*#__PURE__*/_jsx(EditIcon, {})
43
+ });
44
+ }
45
+ return /*#__PURE__*/_jsxs(_Fragment, {
46
+ children: [/*#__PURE__*/_jsxs(ButtonGroup, {
47
+ variant: "outlined",
48
+ ref: anchorRef,
49
+ "aria-label": "split button",
50
+ children: [/*#__PURE__*/_jsx(Button, {
51
+ "data-cy": "schema-form-item-edit",
52
+ onClick: onEnterEdit,
53
+ disabled: disabled,
54
+ size: "large",
55
+ children: /*#__PURE__*/_jsx(EditIcon, {})
56
+ }), /*#__PURE__*/_jsx(Button, {
57
+ size: "small",
58
+ "aria-controls": open ? 'split-button-menu' : undefined,
59
+ "aria-expanded": open ? 'true' : undefined,
60
+ onClick: handleToggle,
61
+ children: /*#__PURE__*/_jsx(ArrowDropDownIcon, {})
62
+ })]
63
+ }), /*#__PURE__*/_jsx(Popper, {
64
+ sx: {
65
+ zIndex: 9999
66
+ },
67
+ open: open,
68
+ anchorEl: anchorRef.current,
69
+ role: undefined,
70
+ placement: "bottom-end",
71
+ children: /*#__PURE__*/_jsx(Paper, {
72
+ children: /*#__PURE__*/_jsx(ClickAwayListener, {
73
+ onClickAway: handleClose,
74
+ children: /*#__PURE__*/_jsx(MenuList, {
75
+ id: "split-button-menu",
76
+ autoFocusItem: true,
77
+ children: triggers.map(x => /*#__PURE__*/_jsx(MenuItem, {
78
+ onClick: () => handleTriggerClick(x.handler),
79
+ children: x.title
80
+ }, x.key))
81
+ })
82
+ })
83
+ })
84
+ })]
85
+ });
86
+ }
87
+ InputTriggers.propTypes = {
88
+ triggers: PropTypes.arrayOf(PropTypes.shape({
89
+ key: PropTypes.string.isRequired,
90
+ title: PropTypes.string.isRequired,
91
+ handler: PropTypes.func.isRequired
92
+ })),
93
+ onEnterEdit: PropTypes.func.isRequired,
94
+ disabled: PropTypes.bool.isRequired
95
+ };
96
+ InputTriggers.defaultProps = {
97
+ triggers: []
98
+ };
@@ -0,0 +1,8 @@
1
+ import styled from '@emotion/styled';
2
+ const Required = styled.span`
3
+ color: ${props => props.theme.palette.error.main};
4
+ &::before {
5
+ content: '*';
6
+ }
7
+ `;
8
+ export default Required;