@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,1313 @@
1
+ /* eslint-disable react/no-unstable-nested-components */
2
+ import { useState, useRef, useImperativeHandle, forwardRef, useEffect } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import uniqBy from 'lodash/uniqBy';
5
+ import flatten from 'lodash/flatten';
6
+ import isEmpty from 'lodash/isEmpty';
7
+ import isNil from 'lodash/isNil';
8
+ import PageHeader from '@blocklet/launcher-layout/lib/page-header';
9
+ import Dialog from '@arcblock/ux/lib/Dialog';
10
+ import Spinner from '@mui/material/CircularProgress';
11
+ import DialogContentText from '@mui/material/DialogContentText';
12
+ import Typography from '@mui/material/Typography';
13
+ import TextField from '@mui/material/TextField';
14
+ import MenuItem from '@mui/material/MenuItem';
15
+ import AddIcon from '@mui/icons-material/Link';
16
+ import CheckIcon from '@mui/icons-material/Check';
17
+ import useMediaQuery from '@mui/material/useMediaQuery';
18
+ import styled from '@emotion/styled';
19
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
20
+ import { BLOCKLET_CONFIGURABLE_KEY, BlockletStatus, BlockletEvents } from '@blocklet/constant';
21
+ import Layout from '@blocklet/launcher-layout';
22
+ import { StepProvider, useStepContext } from '@blocklet/launcher-layout/lib/context/step';
23
+ import Box from '@mui/material/Box';
24
+ import { NODE_MODES } from '@abtnode/constant';
25
+ import Button from '@arcblock/ux/lib/Button';
26
+ import Alert from '@arcblock/ux/lib/Alert';
27
+ import AnimationWaiter from '@arcblock/ux/lib/AnimationWaiter';
28
+ import ResultMessage from '@blocklet/launcher-layout/lib/launch-result-message';
29
+ import { getDisplayName, isComponentBlocklet, isFreeBlocklet, getSharedConfigObj } from '@blocklet/meta/lib/util';
30
+ import urlPathFriendly from '@blocklet/meta/lib/url-path-friendly';
31
+ import Toast from '@arcblock/ux/lib/Toast';
32
+ import { useNodeContext } from '../../contexts/node';
33
+ import { useBlockletContext } from '../../contexts/blocklet';
34
+ import { getBlockletLogoUrl, getBlockletMetaUrl, isNewStoreUrl, getStoreList, formatError, formatMountPoint } from '../../util';
35
+ import SchemaForm from '../../schema-form';
36
+ import Required from '../../form/required';
37
+ import { ComponentPurchaseSelect } from '../purchase';
38
+ import { validatePathPrefix } from '../router/util';
39
+ import Agreement from '../agreement';
40
+ import InstallFromUrl from '../install-from-url';
41
+ import SelectStore from './select-store';
42
+ import BlockletList from './store-blocklet-list';
43
+ import SpaceConnector from './space-connector';
44
+ import { jsx as _jsx } from "react/jsx-runtime";
45
+ import { jsxs as _jsxs } from "react/jsx-runtime";
46
+ import { Fragment as _Fragment } from "react/jsx-runtime";
47
+ const requirePurchase = meta => meta.inStore && isFreeBlocklet(meta) === false;
48
+ const getDIDSpaceCapability = meta => {
49
+ return meta?.capabilities?.didSpace;
50
+ };
51
+ /**
52
+ * @description
53
+ * @param {import('@abtnode/client').BlockletState} blocklet
54
+ * @return {string}
55
+ */
56
+ const getDIDSpaceEndpoint = blocklet => {
57
+ return blocklet?.configs?.find(item => item.key === BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SPACE_ENDPOINT)?.value || null;
58
+ };
59
+ const hasRequiredEnvironments = meta => (meta.environments || []).some(x => x.required);
60
+ const hasMissRequiredConfigs = (configsList, sharedValueMap) => {
61
+ return configsList?.some(item => {
62
+ return item.required && !sharedValueMap[item.key];
63
+ });
64
+ };
65
+ const getParamsName = (params = {}) => {
66
+ return params.title || params.name;
67
+ };
68
+ const StepContent = /*#__PURE__*/forwardRef(({
69
+ meta,
70
+ isMobile,
71
+ onStepChange
72
+ }, ref) => {
73
+ const {
74
+ steps,
75
+ activeStep,
76
+ setActiveStepByKey,
77
+ setActiveStepByIndex
78
+ } = useStepContext();
79
+ const {
80
+ t,
81
+ locale
82
+ } = useLocaleContext();
83
+ const step = steps[activeStep];
84
+ useEffect(() => {
85
+ onStepChange(activeStep);
86
+ }, [onStepChange, activeStep]);
87
+
88
+ // expose the func and activeStep
89
+ useImperativeHandle(ref, () => ({
90
+ setActiveStepByKey,
91
+ setActiveStepByIndex
92
+ }));
93
+ return /*#__PURE__*/_jsx(DialogContentWrapper, {
94
+ component: "div",
95
+ className: isMobile ? 'mobileStyle' : '',
96
+ children: /*#__PURE__*/_jsx(Layout, {
97
+ locale: locale,
98
+ blockletMeta: {
99
+ title: ' ',
100
+ ...meta
101
+ },
102
+ pcWidth: "100%",
103
+ pcHeight: "100%",
104
+ logoUrl: meta && meta.logo && meta.registryUrl ? getBlockletLogoUrl({
105
+ did: meta.did,
106
+ baseUrl: meta.registryUrl,
107
+ logoPath: meta.logo
108
+ }) : null,
109
+ stepTip: t('blocklet.component.add'),
110
+ children: /*#__PURE__*/_jsx(RightContent, {
111
+ children: step?.body && typeof step.body === 'function' ? step.body() : step.body
112
+ })
113
+ })
114
+ });
115
+ });
116
+ StepContent.propTypes = {
117
+ meta: PropTypes.any,
118
+ onStepChange: PropTypes.func.isRequired,
119
+ isMobile: PropTypes.bool.isRequired
120
+ };
121
+ StepContent.defaultProps = {
122
+ meta: null
123
+ };
124
+ export default function AddComponent({
125
+ blocklet,
126
+ children
127
+ }) {
128
+ const {
129
+ t,
130
+ locale
131
+ } = useLocaleContext();
132
+ const [loading, setLoading] = useState(false);
133
+ const [editingItem, setEditingItem] = useState(null);
134
+ const [error, setError] = useState('');
135
+ const [showDialog, setShowDialog] = useState('');
136
+ const [mountPointHelperText, setMountPointHelperText] = useState('');
137
+ const {
138
+ api,
139
+ ws: {
140
+ useSubscription
141
+ },
142
+ inService,
143
+ info: nodeInfo
144
+ } = useNodeContext();
145
+ const {
146
+ actions: {
147
+ refreshBlocklet: refreshApp
148
+ }
149
+ } = useBlockletContext();
150
+ const [purchaseData, setPurchaseData] = useState(null);
151
+ const [isWaitingPurchase, setIsWaitingPurchase] = useState(false);
152
+ const initParams = {
153
+ bundleDid: '',
154
+ componentDid: '',
155
+ componentName: '',
156
+ pathPrefix: '',
157
+ name: '',
158
+ title: '',
159
+ configsList: [],
160
+ configsValue: {},
161
+ hasMissRequiredConfigs: false,
162
+ hasEnvironmentsStep: false,
163
+ hasRequiredEnvironments: false,
164
+ requirePurchase: false,
165
+ didSpaceCapability: null,
166
+ installResultProps: {},
167
+ purchaseResultProps: {},
168
+ showFromUrlDialog: false
169
+ };
170
+ const [params, setParams] = useState(initParams);
171
+ const [activeStep, setActiveStep] = useState(0);
172
+ const component = useRef({});
173
+ const stepRef = useRef({});
174
+ const purchaseRef = useRef({});
175
+ const isMobile = useMediaQuery(theme => theme.breakpoints.down('md'));
176
+ const {
177
+ meta
178
+ } = component.current;
179
+ // eslint-disable-next-line no-unused-vars
180
+ const {
181
+ setActiveStepByIndex
182
+ } = stepRef.current || {};
183
+ const isServerlessMode = nodeInfo.mode === NODE_MODES.SERVERLESS;
184
+ const updateParams = obj => setParams(x => ({
185
+ ...x,
186
+ ...obj
187
+ }));
188
+ useEffect(() => {
189
+ if (params.pathPrefix) {
190
+ const {
191
+ errMsg
192
+ } = validateInput({
193
+ ...params,
194
+ pathPrefix: params.pathPrefix,
195
+ locale
196
+ });
197
+ setError(errMsg);
198
+ }
199
+ }, [params.pathPrefix]); // eslint-disable-line
200
+
201
+ useEffect(() => {
202
+ if (activeStep === 0) {
203
+ // reset params, when step change to select component
204
+ setParams(initParams);
205
+ }
206
+ }, [activeStep]); // eslint-disable-line
207
+
208
+ const getComponentName = () => {
209
+ if (component?.current?.meta) {
210
+ return getDisplayName(component.current);
211
+ }
212
+ return '';
213
+ };
214
+ const setInstallErrorResult = errorMessage => {
215
+ const update = _loading => {
216
+ updateParams({
217
+ installResultProps: {
218
+ variant: 'error',
219
+ title: getComponentName(),
220
+ subTitle: errorMessage,
221
+ footer: /*#__PURE__*/_jsx(Button, {
222
+ className: "bottom-button",
223
+ disabled: _loading,
224
+ "data-cy": "retry-install-component",
225
+ onClick: async () => {
226
+ // set button disabled and show spinner
227
+ update(true);
228
+ await onInstall(component.current.installInput);
229
+ },
230
+ children: /*#__PURE__*/_jsxs(Box, {
231
+ display: "flex",
232
+ alignItems: "center",
233
+ children: [_loading && /*#__PURE__*/_jsx(Spinner, {
234
+ size: 16,
235
+ style: {
236
+ marginRight: 8
237
+ }
238
+ }), t('common.retry')]
239
+ })
240
+ })
241
+ }
242
+ });
243
+ };
244
+ update();
245
+ };
246
+ const createBlockletEventHandler = handler => {
247
+ return b => {
248
+ if ((b?.meta?.did || b?.meta) === blocklet?.meta?.did) {
249
+ handler(b);
250
+ }
251
+ };
252
+ };
253
+ useSubscription(BlockletEvents.statusChange, createBlockletEventHandler(e => {
254
+ switch (e.status) {
255
+ case BlockletStatus.upgrading:
256
+ updateParams({
257
+ installResultProps: {
258
+ variant: 'success',
259
+ title: getComponentName(),
260
+ subTitle: t('blocklet.component.installSuccessTip')
261
+ }
262
+ });
263
+ break;
264
+ default:
265
+ }
266
+ }), [blocklet?.meta?.did]);
267
+ useSubscription(BlockletEvents.downloadFailed, createBlockletEventHandler(() => {
268
+ setInstallErrorResult(t('blocklet.component.installComponentError'));
269
+ }), [blocklet?.meta?.did]);
270
+ useSubscription(BlockletEvents.installFailed, createBlockletEventHandler(() => {
271
+ setInstallErrorResult(t('blocklet.component.installComponentError'));
272
+ }), [blocklet?.meta?.did]);
273
+ const onClose = () => {
274
+ setLoading(false);
275
+ setShowDialog(false);
276
+ setParams({});
277
+ component.current = {};
278
+ };
279
+ const onInstall = async payload => {
280
+ const {
281
+ pathPrefix: mountPoint,
282
+ bundleDid,
283
+ title,
284
+ componentName = '',
285
+ componentDid = ''
286
+ } = params;
287
+ // eslint-disable-next-line no-shadow
288
+ const {
289
+ configs = [],
290
+ registryUrl,
291
+ inStore,
292
+ inputUrl
293
+ } = component.current?.meta || {};
294
+ const downloadTokenList = component.current?.downloadTokenList;
295
+ const url = inStore ? getBlockletMetaUrl(registryUrl, bundleDid) : inputUrl;
296
+ setLoading(true);
297
+ const installInput = {
298
+ rootDid: blocklet.meta.did,
299
+ url,
300
+ mountPoint: urlPathFriendly(mountPoint),
301
+ title,
302
+ name: componentName,
303
+ did: componentDid,
304
+ // if blocklet has config, provide the configs
305
+ ...(params.hasEnvironmentsStep && configs.length > 0 ? {
306
+ configs: configs.map(item => {
307
+ return {
308
+ ...item,
309
+ value: params.configsValue[item.key] || ''
310
+ };
311
+ })
312
+ } : {}),
313
+ ...(downloadTokenList ? {
314
+ downloadTokenList
315
+ } : {}),
316
+ ...payload
317
+ };
318
+ try {
319
+ await api.installComponent({
320
+ input: installInput
321
+ });
322
+ if (registryUrl) {
323
+ const {
324
+ teamDid,
325
+ storeList
326
+ } = getStoreList({
327
+ fromBlocklet: inService,
328
+ nodeInfo,
329
+ blocklet
330
+ });
331
+ const {
332
+ isNew,
333
+ decoded
334
+ } = isNewStoreUrl(registryUrl, storeList);
335
+ if (isNew) {
336
+ await api.addBlockletStore({
337
+ input: {
338
+ teamDid,
339
+ url: decoded
340
+ }
341
+ });
342
+ }
343
+ }
344
+ updateParams({
345
+ installResultProps: {}
346
+ });
347
+
348
+ // let app state refresh fast before receive subscribe event
349
+ refreshApp({
350
+ showError: false,
351
+ attachRuntimeInfo: false
352
+ });
353
+ } catch (err) {
354
+ const errMsg = formatError(err);
355
+ Toast.error(errMsg);
356
+ console.error('installComponent error: ', err);
357
+ setInstallErrorResult(errMsg);
358
+ } finally {
359
+ setLoading(false);
360
+ component.current.installInput = installInput;
361
+ }
362
+ };
363
+ const validateInput = input => {
364
+ // FIXME: validatePathPrefix should be updated
365
+ const errMsg = validatePathPrefix({
366
+ params: {
367
+ ...input,
368
+ did: input.bundleDid
369
+ },
370
+ blocklets: [blocklet],
371
+ // blocklets: component.current?.blocklets?.map(x => ({ meta: x })) || [],
372
+ blocklet,
373
+ locale
374
+ });
375
+ return {
376
+ errMsg
377
+ };
378
+ };
379
+ const onNext = async payload => {
380
+ const {
381
+ errMsg
382
+ } = validateInput({
383
+ ...params,
384
+ locale
385
+ });
386
+ setError(errMsg);
387
+
388
+ // the step can complete, install component
389
+ if (activeStep === steps.length - 2) {
390
+ await onInstall(payload);
391
+ }
392
+ setActiveStepByIndex(x => x + 1);
393
+ };
394
+ const onCancel = () => {
395
+ setActiveStepByIndex(x => x - 1);
396
+ };
397
+ const onGeneratePurchaseData = () => {
398
+ const {
399
+ pathPrefix: mountPoint,
400
+ bundleDid,
401
+ title,
402
+ componentName = '',
403
+ componentDid = ''
404
+ } = params;
405
+
406
+ // eslint-disable-next-line no-shadow
407
+ const {
408
+ meta = {}
409
+ } = component.current || {};
410
+ const {
411
+ registryUrl,
412
+ inStore,
413
+ inputUrl
414
+ } = meta;
415
+ const url = inStore ? getBlockletMetaUrl(registryUrl, bundleDid) : inputUrl;
416
+ setPurchaseData({
417
+ meta,
418
+ installOpts: {
419
+ type: 'component',
420
+ rootDid: blocklet.meta.did,
421
+ mountPoint,
422
+ url,
423
+ title,
424
+ name: componentName,
425
+ did: componentDid
426
+ }
427
+ });
428
+ };
429
+ const onCancelPurchase = errorMessage => {
430
+ setIsWaitingPurchase(false);
431
+ updateParams({
432
+ purchaseResultProps: {
433
+ variant: 'error',
434
+ title: getComponentName(),
435
+ subTitle: errorMessage,
436
+ style: {
437
+ paddingTop: 120
438
+ },
439
+ footer: /*#__PURE__*/_jsx(Button, {
440
+ className: "bottom-button",
441
+ "data-cy": "retry-purchase-component",
442
+ onClick: () => {
443
+ updateParams({
444
+ purchaseResultProps: {}
445
+ });
446
+ },
447
+ children: t('common.retry')
448
+ })
449
+ }
450
+ });
451
+ };
452
+ const onSuccessPurchase = ({
453
+ downloadTokenList
454
+ }) => {
455
+ component.current.downloadTokenList = downloadTokenList;
456
+ setIsWaitingPurchase(false);
457
+ onNext();
458
+ };
459
+ const setConfigValue = ({
460
+ chooseParams = component.current,
461
+ componentDid: componentDidValue,
462
+ isInit = false
463
+ }) => {
464
+ // eslint-disable-next-line no-shadow
465
+ const {
466
+ meta,
467
+ registryUrl,
468
+ inStore,
469
+ inputUrl
470
+ } = chooseParams;
471
+ const {
472
+ did: bundleDid,
473
+ title,
474
+ name
475
+ } = meta;
476
+
477
+ // deleted history list
478
+ const list = (blocklet.settings?.children || []).filter(x => x.status === 'deleted' && x.meta.bundleDid === bundleDid);
479
+ const componentDid = componentDidValue || '';
480
+ const newConfigs = meta.environments?.map(item => {
481
+ const {
482
+ name: key,
483
+ validation,
484
+ ...rest
485
+ } = item;
486
+ const formatItem = {
487
+ // if the blocklet has validation, provide the validation (fix not inStore)
488
+ validation: isNil(validation) ? '' : validation
489
+ };
490
+ return {
491
+ ...rest,
492
+ key,
493
+ ...formatItem
494
+ };
495
+ });
496
+ component.current = {
497
+ ...chooseParams,
498
+ meta: {
499
+ ...meta,
500
+ // init configs from environments
501
+ configs: newConfigs,
502
+ registryUrl,
503
+ inStore,
504
+ inputUrl
505
+ }
506
+ };
507
+ let doc = {};
508
+
509
+ // if is init, should update configs
510
+ if (isInit) {
511
+ const ancestors = [blocklet];
512
+
513
+ // component config
514
+ const componentSelfConfigs = newConfigs || [];
515
+
516
+ // TODO: meta not include children environments/configs before install, waiting for next sprint to design
517
+ const componentChildrenConfigs = [];
518
+
519
+ // eslint-disable-next-line
520
+ // chooseBlocklet?.children?.map(childBlocklet => {
521
+ // // eslint-disable-next-line no-shadow
522
+ // forEachChildSync(childBlocklet, (b, { ancestors }) => {
523
+ // const ancestorDids = ancestors.slice(1).map(x => x.meta.did);
524
+
525
+ // componentChildrenConfigs.push(
526
+ // (b.configs || []).map(x => ({ ...x, childDid: ancestorDids.concat(b.meta.did) }))
527
+ // );
528
+ // });
529
+
530
+ // return false;
531
+ // });
532
+
533
+ const componentAllConfigs = uniqBy(flatten([...componentSelfConfigs, ...componentChildrenConfigs]), 'key').filter(x => !!x.key).sort((a, b) => {
534
+ if (a.required && !b.required) {
535
+ return -1;
536
+ }
537
+ if (b.required && !a.required) {
538
+ return 1;
539
+ }
540
+ return 0;
541
+ });
542
+ const sharedConfigObj = getSharedConfigObj({
543
+ configs: componentAllConfigs
544
+ }, ancestors);
545
+ const configsValue = {};
546
+ const configsList = componentAllConfigs.map(item => {
547
+ const {
548
+ default: defaultValue,
549
+ key,
550
+ ...rest
551
+ } = item;
552
+ configsValue[key] = sharedConfigObj[key] || defaultValue;
553
+ return {
554
+ ...rest,
555
+ key,
556
+ hidden: !!BLOCKLET_CONFIGURABLE_KEY[key]
557
+ };
558
+ });
559
+ doc = {
560
+ ...doc,
561
+ configsList,
562
+ configsValue,
563
+ hasMissRequiredConfigs: hasMissRequiredConfigs(configsList, configsValue)
564
+ };
565
+ }
566
+ const hasRootPath = blocklet.children.some(x => x.mountPoint === '/');
567
+
568
+ // use deleted history
569
+ const config = list.find(x => x.meta.bundleDid === bundleDid);
570
+ if (config) {
571
+ doc = {
572
+ ...doc,
573
+ pathPrefix: config.mountPoint,
574
+ title: title || '',
575
+ componentName: config.meta.name,
576
+ // use history's environments
577
+ hasEnvironmentsStep: false
578
+ };
579
+ } else {
580
+ doc = {
581
+ ...doc,
582
+ pathPrefix: hasRootPath ? `/${urlPathFriendly(name)}` : '/',
583
+ title: title || '',
584
+ componentName: '',
585
+ hasEnvironmentsStep: component.current.meta?.environments?.length > 0
586
+ };
587
+ }
588
+
589
+ // eslint-disable-next-line no-shadow
590
+ const componentRequirePurchase = requirePurchase(component.current.meta);
591
+ const componentDIDSpaceCapability = getDIDSpaceCapability(component.current.meta);
592
+ const didSpaceEndpoint = getDIDSpaceEndpoint(blocklet);
593
+ updateParams({
594
+ bundleDid,
595
+ componentDid,
596
+ ...doc,
597
+ hasRequiredEnvironments: hasRequiredEnvironments(component.current.meta),
598
+ requirePurchase: componentRequirePurchase,
599
+ didSpaceCapability: componentDIDSpaceCapability,
600
+ didSpaceEndpoint
601
+ });
602
+ if (isInit && componentRequirePurchase) {
603
+ onGeneratePurchaseData();
604
+ }
605
+ };
606
+ const steps = [{
607
+ key: 'selectComponent',
608
+ name: t('blocklet.component.selectComponent'),
609
+ body: /*#__PURE__*/_jsxs(TypographyWrapper, {
610
+ component: "div",
611
+ children: [params.showFromUrlDialog && /*#__PURE__*/_jsx(InstallFromUrl
612
+ // if not set defaultUrl, the dialog will always show step 1 when the dialog is opened
613
+ // defaultUrl={meta?.inputUrl}
614
+ , {
615
+ mode: "component",
616
+ onCancel: () => {
617
+ updateParams({
618
+ showFromUrlDialog: false
619
+ });
620
+ }
621
+ // eslint-disable-next-line no-shadow
622
+ ,
623
+ onSuccess: ({
624
+ meta,
625
+ inputUrl,
626
+ inStore,
627
+ registryUrl
628
+ }) => {
629
+ setConfigValue({
630
+ chooseParams: {
631
+ meta,
632
+ inputUrl,
633
+ inStore,
634
+ registryUrl
635
+ },
636
+ isInit: true
637
+ });
638
+ updateParams({
639
+ showFromUrlDialog: false
640
+ });
641
+ onNext();
642
+ },
643
+ handleText: {
644
+ title: t('blocklet.component.addComponentTip.fromUrl'),
645
+ confirm: t('blocklet.component.choose')
646
+ }
647
+ }), /*#__PURE__*/_jsx(SelectStore, {
648
+ extra: !isServerlessMode ? /*#__PURE__*/_jsxs(Button, {
649
+ variant: "text",
650
+ color: "primary",
651
+ "data-cy": "add-component-from-url",
652
+ onClick: () => {
653
+ updateParams({
654
+ showFromUrlDialog: true
655
+ });
656
+ },
657
+ style: {
658
+ padding: '0 2px'
659
+ },
660
+ children: [/*#__PURE__*/_jsx(AddIcon, {
661
+ style: {
662
+ fontSize: 20,
663
+ marginRight: 4
664
+ }
665
+ }), " ", t('blocklet.component.addComponentTip.fromUrl'), ' ']
666
+ }) : null,
667
+ loading: loading,
668
+ onChange: () => {
669
+ setParams({});
670
+ component.current = {};
671
+ },
672
+ children: ({
673
+ currentRegistry
674
+ }) => {
675
+ return /*#__PURE__*/_jsx(BlockletList, {
676
+ serverVersion: nodeInfo?.version,
677
+ style: isMobile ? {
678
+ // should remove other dom height/margin
679
+ height: 'calc(100vh - 56px - 80px - 32px - 40px )'
680
+ } : {
681
+ height: 'calc(100% - 40px)'
682
+ },
683
+ storeUrl: currentRegistry.url,
684
+ handleButtonClick: chooseParams => {
685
+ setConfigValue({
686
+ chooseParams: {
687
+ ...chooseParams,
688
+ inStore: true // choose from store, must be inStore
689
+ },
690
+
691
+ isInit: true
692
+ });
693
+ },
694
+ handleBlockletRender: ({
695
+ blocklet: blockletItem,
696
+ defaultRender
697
+ }) => {
698
+ const isChosen = params?.bundleDid && params?.bundleDid === blockletItem?.did;
699
+ return /*#__PURE__*/_jsxs(StoreBlockletItemWrapper, {
700
+ children: [isChosen && /*#__PURE__*/_jsx("div", {
701
+ className: "check-container",
702
+ children: /*#__PURE__*/_jsx(CheckIcon, {
703
+ className: "check-icon"
704
+ })
705
+ }), /*#__PURE__*/_jsx("div", {
706
+ className: isChosen ? 'choose-blocklet' : '',
707
+ style: {
708
+ marginLeft: 16
709
+ },
710
+ children: defaultRender
711
+ })]
712
+ });
713
+ },
714
+ extraFilter: allBlocklets => {
715
+ // only use blocklets that are component
716
+ return allBlocklets?.filter(x => {
717
+ if (!isComponentBlocklet(x)) {
718
+ return false;
719
+ }
720
+ if ((blocklet.children || []).some(y => y.meta.did === x.did)) {
721
+ return false;
722
+ }
723
+ return true;
724
+ });
725
+ }
726
+ });
727
+ }
728
+ })]
729
+ }),
730
+ cancel: t('common.cancel'),
731
+ confirm: getParamsName(params) ? t('blocklet.component.addNext', {
732
+ name: getParamsName(params)
733
+ }) : t('common.next'),
734
+ onCancel: onClose,
735
+ onConfirm: () => {
736
+ onNext();
737
+ }
738
+ }, {
739
+ key: 'agreement',
740
+ name: t('launchBlocklet.introduction'),
741
+ body: /*#__PURE__*/_jsxs(TypographyWrapper, {
742
+ component: "div",
743
+ className: "agreement-wrapper",
744
+ children: [/*#__PURE__*/_jsx(PageHeader, {
745
+ title: t('launchBlocklet.introduction'),
746
+ subTitle: t('blocklet.component.addComponentTip.introduction')
747
+ }), /*#__PURE__*/_jsx(Agreement, {
748
+ meta: meta,
749
+ onClickNext: onNext,
750
+ handleDescEle: /*#__PURE__*/_jsxs(_Fragment, {
751
+ children: [/*#__PURE__*/_jsx("p", {
752
+ children: /*#__PURE__*/_jsx("div", {
753
+ // eslint-disable-next-line
754
+ dangerouslySetInnerHTML: {
755
+ __html: t(`blocklet.component.addComponentTip.${params.requirePurchase ? 'isPurchase' : 'isFree'}`, {
756
+ name: getComponentName()
757
+ })
758
+ }
759
+ })
760
+ }), /*#__PURE__*/_jsx("p", {
761
+ children: t('blocklet.component.addComponentTip.belowInformation')
762
+ })]
763
+ })
764
+ })]
765
+ }),
766
+ cancel: t('common.pre'),
767
+ confirm: t('launchBlocklet.next'),
768
+ onCancel,
769
+ onConfirm: () => {
770
+ setIsWaitingPurchase(false);
771
+ onNext();
772
+ }
773
+ }, meta && params.requirePurchase && {
774
+ key: 'purchase',
775
+ name: /*#__PURE__*/_jsxs(_Fragment, {
776
+ children: [t('common.verifyNFT'), /*#__PURE__*/_jsx(Required, {})]
777
+ }),
778
+ body: /*#__PURE__*/_jsxs(TypographyWrapper, {
779
+ component: "div",
780
+ className: "flex-align-center",
781
+ style: {
782
+ flexDirection: 'column'
783
+ },
784
+ children: [!(purchaseRef.current?.getCurrentStep?.() === 2 || isWaitingPurchase) && /*#__PURE__*/_jsx(PageHeaderWrapper, {
785
+ title: t('common.verifyNFT'),
786
+ subTitle: t('blocklet.component.addComponentTip.verifyNFT')
787
+ }), !isEmpty(params.purchaseResultProps) ? /*#__PURE__*/_jsx("div", {
788
+ className: "flex-align-center flex-justify-center",
789
+ children: /*#__PURE__*/_jsx(ResultMessage, {
790
+ ...params.purchaseResultProps
791
+ })
792
+ }) : purchaseData && /*#__PURE__*/_jsx(ComponentPurchaseSelect, {
793
+ ref: purchaseRef,
794
+ meta: purchaseData.meta
795
+ // if select deleted history, use verify mode
796
+ ,
797
+ mode: params.componentDid ? 'verify' : 'both',
798
+ onCancel: onCancelPurchase,
799
+ installOpts: purchaseData.installOpts,
800
+ handlePaySuccess: onSuccessPurchase
801
+ })]
802
+ }),
803
+ disabled: purchaseRef.current?.getCurrentStep?.() === 2 || isWaitingPurchase,
804
+ cancel: t('common.pre'),
805
+ confirm: t('common.next'),
806
+ onConfirm: () => {
807
+ if (typeof purchaseRef.current.onNext === 'function') {
808
+ purchaseRef.current.onNext();
809
+ setIsWaitingPurchase(true);
810
+ }
811
+ },
812
+ onCancel: () => {
813
+ onCancel();
814
+ }
815
+ }, {
816
+ key: 'config',
817
+ name: t('common.config'),
818
+ error,
819
+ body: /*#__PURE__*/_jsxs(TypographyWrapper, {
820
+ component: "div",
821
+ children: [/*#__PURE__*/_jsx(PageHeaderWrapper, {
822
+ title: t('common.config'),
823
+ subTitle: t('blocklet.component.addComponentTip.config')
824
+ }), /*#__PURE__*/_jsx(TextField, {
825
+ label: t('blocklet.component.mountPoint'),
826
+ autoComplete: "off",
827
+ variant: "outlined",
828
+ name: "pathPrefix",
829
+ inputProps: {
830
+ 'data-cy': 'mount-point-input'
831
+ },
832
+ fullWidth: true,
833
+ helperText: mountPointHelperText || t('blocklet.component.mountPointTip'),
834
+ style: {
835
+ marginBottom: 32
836
+ },
837
+ margin: "normal",
838
+ value: params.pathPrefix,
839
+ onChange: e => {
840
+ const pathPrefix = e.target.value;
841
+ updateParams({
842
+ pathPrefix
843
+ });
844
+ setMountPointHelperText(t('common.slugifyHint', {
845
+ value: formatMountPoint(pathPrefix)
846
+ }));
847
+ }
848
+ }), !!error && /*#__PURE__*/_jsx(Alert, {
849
+ type: "error",
850
+ style: {
851
+ width: '100%',
852
+ marginTop: 8
853
+ },
854
+ children: error
855
+ })]
856
+ }),
857
+ cancel: t('common.pre'),
858
+ confirm: t('common.next'),
859
+ onCancel,
860
+ onConfirm: () => {
861
+ onNext();
862
+ }
863
+ }, meta && params?.hasEnvironmentsStep && {
864
+ key: 'environment',
865
+ name: /*#__PURE__*/_jsxs(_Fragment, {
866
+ children: [t('common.environment'), " ", params.hasRequiredEnvironments && /*#__PURE__*/_jsx(Required, {})]
867
+ }),
868
+ disabled: !!editingItem || params?.hasMissRequiredConfigs,
869
+ body: () => {
870
+ return /*#__PURE__*/_jsxs(TypographyWrapper, {
871
+ component: "div",
872
+ children: [/*#__PURE__*/_jsx(PageHeaderWrapper, {
873
+ title: t('common.environment'),
874
+ subTitle: t('blocklet.component.addComponentTip.environment')
875
+ }), /*#__PURE__*/_jsx(SchemaForm, {
876
+ style: {
877
+ marginTop: -12,
878
+ width: '100%'
879
+ },
880
+ schema: params.configsList,
881
+ defaultValue: params.configsValue
882
+ // eslint-disable-next-line
883
+ ,
884
+ onChange: (changeValue, {
885
+ action,
886
+ currentItem,
887
+ allValues
888
+ }) => {
889
+ if (action === 'confirm') {
890
+ updateParams({
891
+ hasMissRequiredConfigs: hasMissRequiredConfigs(params.configsList, allValues),
892
+ configsValue: allValues
893
+ });
894
+ }
895
+ if (action === 'edit') {
896
+ setEditingItem(currentItem);
897
+ } else if (['cancel', 'confirm'].includes(action)) {
898
+ setEditingItem(null);
899
+ }
900
+ }
901
+ })]
902
+ });
903
+ },
904
+ cancel: t('common.pre'),
905
+ confirm: t('common.next'),
906
+ onCancel,
907
+ onConfirm: onNext
908
+ }, meta && params?.didSpaceCapability && {
909
+ key: 'didSpace',
910
+ name: /*#__PURE__*/_jsxs(_Fragment, {
911
+ children: [t('blocklet.component.didSpaceConfig'), " ", params.didSpaceCapability === 'required' && /*#__PURE__*/_jsx(Required, {})]
912
+ }),
913
+ disabled: params.didSpaceCapability === 'required' && !params.didSpaceEndpoint,
914
+ body: () => {
915
+ return /*#__PURE__*/_jsxs(TypographyWrapper, {
916
+ component: "div",
917
+ children: [/*#__PURE__*/_jsx(PageHeaderWrapper, {
918
+ title: t('blocklet.component.didSpaceConfig'),
919
+ subTitle: t('blocklet.component.didSpaceConfigTip')
920
+ }), /*#__PURE__*/_jsx(Box, {
921
+ sx: {
922
+ mt: '36px',
923
+ '& > div': {
924
+ maxWidth: 'unset !important',
925
+ '& .MuiAutocomplete-root': {
926
+ maxWidth: 'unset !important'
927
+ }
928
+ }
929
+ },
930
+ children: /*#__PURE__*/_jsx(SpaceConnector, {
931
+ sx: {
932
+ '& .MuiFormHelperText-root': {
933
+ wordBreak: 'break-all'
934
+ }
935
+ },
936
+ helperText: params.didSpaceEndpoint && t('blocklet.component.didSpaceConnected', {
937
+ endpoint: params.didSpaceEndpoint
938
+ }),
939
+ onConnect: () => {
940
+ onNext();
941
+ }
942
+ })
943
+ })]
944
+ });
945
+ },
946
+ cancel: t('common.pre'),
947
+ confirm: t('common.next'),
948
+ onCancel,
949
+ onConfirm: onNext
950
+ }, {
951
+ key: 'install',
952
+ name: t('common.install'),
953
+ disabled: false,
954
+ loading: false,
955
+ body: /*#__PURE__*/_jsx(TypographyWrapper, {
956
+ component: "div",
957
+ className: "flex-justify-center flex-align-center",
958
+ style: {
959
+ flexDirection: 'column'
960
+ },
961
+ children: isEmpty(params.installResultProps) ? /*#__PURE__*/_jsx(AnimationWaiter, {
962
+ message: /*#__PURE__*/_jsx(MessageDiv, {
963
+ children: t('blocklet.component.installingCanCloseWindowTip')
964
+ }),
965
+ increaseSpeed: 0.3,
966
+ messageLoop: false
967
+ }) : /*#__PURE__*/_jsx("div", {
968
+ style: {
969
+ marginTop: 120
970
+ },
971
+ children: /*#__PURE__*/_jsx(ResultMessage, {
972
+ ...params.installResultProps
973
+ })
974
+ })
975
+ }),
976
+ confirm: t('common.complete'),
977
+ // onCancel: onClose,
978
+ onConfirm: () => {
979
+ onClose();
980
+ // scroll to bottom
981
+ setTimeout(() => {
982
+ const scrollDom = document.getElementsByClassName('dashboard-main')[0];
983
+ if (scrollDom) {
984
+ scrollDom.scrollTop = scrollDom.scrollHeight;
985
+ }
986
+ }, 200);
987
+ }
988
+ }].filter(item => item);
989
+ const step = steps[activeStep] || {};
990
+ const onMenuItemClick = e => {
991
+ e.stopPropagation();
992
+ // eslint-disable-next-line no-unused-expressions
993
+ setShowDialog(true);
994
+ };
995
+ const isDisabled = () => {
996
+ if (loading || step.error || !params.bundleDid) {
997
+ return true;
998
+ }
999
+ if (activeStep > 0) {
1000
+ return !params.pathPrefix;
1001
+ }
1002
+ return false;
1003
+ };
1004
+
1005
+ // show close button when step is not the last one
1006
+ const showCloseButton = activeStep < steps.length - 1;
1007
+ return /*#__PURE__*/_jsxs(_Fragment, {
1008
+ children: [typeof children === 'function' ? children({
1009
+ loading,
1010
+ open: onMenuItemClick
1011
+ }) : /*#__PURE__*/_jsxs(MenuItem, {
1012
+ onClick: onMenuItemClick,
1013
+ className: "component-action",
1014
+ "data-cy": "action-add-component",
1015
+ children: [loading ? /*#__PURE__*/_jsx(Spinner, {
1016
+ size: 16
1017
+ }) : /*#__PURE__*/_jsx(AddIcon, {
1018
+ style: {
1019
+ fontSize: 18,
1020
+ marginRight: 5
1021
+ }
1022
+ }), t('blocklet.component.add')]
1023
+ }), showDialog && /*#__PURE__*/_jsx(DialogWrapper, {
1024
+ title: t('blocklet.component.addWithName', {
1025
+ name: getDisplayName(blocklet)
1026
+ }),
1027
+ maxWidth: false,
1028
+ fullWidth: false,
1029
+ PaperProps: {
1030
+ style: isMobile ? {
1031
+ width: '100%',
1032
+ height: window.innerHeight
1033
+ } : {
1034
+ maxWidth: 1350,
1035
+ minWidth: 930,
1036
+ width: '80%'
1037
+ }
1038
+ }
1039
+ // eslint-disable-next-line no-unused-vars
1040
+ ,
1041
+ onClose: (event, reason) => {
1042
+ // disable backdropClick
1043
+ if (reason === 'backdropClick') {
1044
+ return;
1045
+ }
1046
+ steps[0]?.onCancel?.();
1047
+ },
1048
+ showCloseButton: showCloseButton,
1049
+ disableEscapeKeyDown: true,
1050
+ open: true,
1051
+ actions: /*#__PURE__*/_jsxs(_Fragment, {
1052
+ children: [step.cancel && /*#__PURE__*/_jsx(Button, {
1053
+ onClick: e => {
1054
+ e.stopPropagation();
1055
+ step.onCancel();
1056
+ },
1057
+ disabled: activeStep === steps.length - 2 && loading,
1058
+ color: "inherit",
1059
+ children: step.cancel || t('common.cancel')
1060
+ }), step.confirm && /*#__PURE__*/_jsx(Button, {
1061
+ onClick: e => {
1062
+ e.stopPropagation();
1063
+ step.onConfirm();
1064
+ },
1065
+ color: "primary",
1066
+ "data-cy": "submit-confirm-next",
1067
+ disabled: loading || (typeof step.disabled === 'boolean' ? step.disabled : isDisabled()),
1068
+ variant: "contained",
1069
+ autoFocus: true,
1070
+ title: step.confirm,
1071
+ style: {
1072
+ marginLeft: 8,
1073
+ overflow: 'hidden',
1074
+ textOverflow: 'ellipsis',
1075
+ whiteSpace: 'nowrap',
1076
+ maxWidth: '280px',
1077
+ display: 'inline-block'
1078
+ },
1079
+ children: /*#__PURE__*/_jsxs(Box, {
1080
+ display: "flex",
1081
+ alignItems: "center",
1082
+ children: [(typeof step.loading === 'boolean' ? step.loading : loading) && /*#__PURE__*/_jsx(Spinner, {
1083
+ size: 16
1084
+ }), step.confirm]
1085
+ })
1086
+ })]
1087
+ }),
1088
+ children: /*#__PURE__*/_jsx(StepProvider, {
1089
+ steps: steps,
1090
+ mode: "memory",
1091
+ children: /*#__PURE__*/_jsx(StepContent, {
1092
+ ref: stepRef,
1093
+ meta: meta,
1094
+ isMobile: isMobile,
1095
+ onStepChange: newStep => {
1096
+ setActiveStep(newStep);
1097
+ }
1098
+ })
1099
+ })
1100
+ })]
1101
+ });
1102
+ }
1103
+ AddComponent.propTypes = {
1104
+ children: PropTypes.any,
1105
+ blocklet: PropTypes.object.isRequired
1106
+ };
1107
+ AddComponent.defaultProps = {
1108
+ children: null
1109
+ };
1110
+
1111
+ // FIXME: @zhanghan 下面代码中的 header:empty 用于修复 e2e-test 中的问题 core/webapp/cypress/e2e/3-blocklet-lifecycle.cy.js L70
1112
+ const DialogWrapper = styled(Dialog)`
1113
+ .MuiDialogContent-root {
1114
+ padding-left: 0;
1115
+ padding-right: 0;
1116
+ padding-bottom: 0;
1117
+ }
1118
+ .MuiDialogActions-root {
1119
+ padding: 16px 24px;
1120
+ }
1121
+ header:empty {
1122
+ display: none;
1123
+ }
1124
+ `;
1125
+ const TypographyWrapper = styled(Typography)`
1126
+ width: 100%;
1127
+ height: 100%;
1128
+ `;
1129
+ const RightContent = styled.div`
1130
+ padding: 34px 24px 24px;
1131
+ width: 100%;
1132
+ display: flex;
1133
+ flex-direction: column;
1134
+ justify-content: flex-start;
1135
+ align-items: flex-start;
1136
+
1137
+ .bottom-button {
1138
+ min-width: 200px;
1139
+ }
1140
+
1141
+ // blocklet-select-side
1142
+ aside {
1143
+ width: 140px;
1144
+ }
1145
+ `;
1146
+ const isMobileDialogContent = props => {
1147
+ if (props.isMobile) {
1148
+ return `
1149
+ height: calc(100vh - 56px - 64px - 48px);
1150
+ `;
1151
+ }
1152
+ return '';
1153
+ };
1154
+ const DialogContentWrapper = styled(DialogContentText)`
1155
+ ${({
1156
+ className
1157
+ }) => {
1158
+ // mobile extra style
1159
+ if (className === 'mobileStyle') {
1160
+ return `
1161
+ & > div{
1162
+ height: 100%;
1163
+ }
1164
+ .root-header {
1165
+ .app-name-content {
1166
+ display: none;
1167
+ }
1168
+ }
1169
+
1170
+ // content-panel
1171
+ .root-header + div{
1172
+ padding-top: 0;
1173
+ position: relative;
1174
+ & > div {
1175
+ padding-top: 0;
1176
+ }
1177
+ }
1178
+
1179
+ `;
1180
+ }
1181
+ return `
1182
+ height: 72vh;
1183
+ position: relative;
1184
+ .root-header {
1185
+ z-index: auto !important;
1186
+ position: fixed !important;
1187
+ }
1188
+ & > div {
1189
+ height: 100%;
1190
+ width: 100%;
1191
+ max-width: 100%;
1192
+ & > div {
1193
+ max-height: unset !important;
1194
+ max-width: 100%;
1195
+ & > div {
1196
+ // left-panel
1197
+ &:first-child {
1198
+ padding-top: 0;
1199
+ // padding-left: 0;
1200
+ width: 25%;
1201
+ min-width: 240px;
1202
+ & > div:first-child {
1203
+ display: none;
1204
+ }
1205
+ // step
1206
+ & > div:last-child {
1207
+ // margin-top: 32px;
1208
+ margin-top: 0;
1209
+ }
1210
+ }
1211
+ // right-panel
1212
+ &:last-child {
1213
+ padding-top: 0;
1214
+ padding-right: 24px;
1215
+ overflow-y: auto;
1216
+ .app-content {
1217
+ padding: 0 0 24px 0;
1218
+ }
1219
+ .button-container {
1220
+ padding-right: 0;
1221
+ }
1222
+ }
1223
+ }
1224
+ }
1225
+ }
1226
+
1227
+ `;
1228
+ }}
1229
+
1230
+ & .flex-justify-center {
1231
+ display: flex;
1232
+ justify-content: center;
1233
+ }
1234
+
1235
+ & .flex-align-center {
1236
+ display: flex;
1237
+ height: 100%;
1238
+ align-items: center;
1239
+ ${props => isMobileDialogContent(props)}
1240
+ }
1241
+
1242
+ & .agreement-wrapper {
1243
+ ${props => isMobileDialogContent(props)}
1244
+ max-height: 60vh;
1245
+ .eula-trigger {
1246
+ padding-right: 0;
1247
+ }
1248
+ .next-button {
1249
+ display: none;
1250
+ }
1251
+ }
1252
+
1253
+ & .connect {
1254
+ background: white;
1255
+ }
1256
+ `;
1257
+ const PageHeaderWrapper = styled(PageHeader)`
1258
+ margin-bottom: 24px;
1259
+ `;
1260
+ const StoreBlockletItemWrapper = styled.div`
1261
+ position: relative;
1262
+
1263
+ .choose-blocklet {
1264
+ background-color: rgb(236, 251, 253);
1265
+ border-color: rgb(236, 251, 253);
1266
+ border-radius: 8px;
1267
+ }
1268
+
1269
+ .check-container {
1270
+ position: absolute;
1271
+ right: 0;
1272
+ bottom: 0;
1273
+ display: flex;
1274
+ justify-content: flex-end;
1275
+ align-items: flex-end;
1276
+ width: 30px;
1277
+ height: 30px;
1278
+ border-radius: 0 0 8px 0;
1279
+ color: ${props => props.theme.palette.common.white};
1280
+ overflow: hidden;
1281
+ transition: all ease 0.3s;
1282
+ &:after {
1283
+ position: absolute;
1284
+ z-index: 0;
1285
+ display: block;
1286
+ width: 0;
1287
+ height: 0;
1288
+ border-top: transparent solid 15px;
1289
+ border-left: transparent solid 15px;
1290
+ border-bottom: ${props => props.theme.palette.primary.main} solid 15px;
1291
+ border-right: ${props => props.theme.palette.primary.main} solid 15px;
1292
+ transition: all ease 0.1s;
1293
+ content: '';
1294
+ }
1295
+
1296
+ .check-icon {
1297
+ position: relative;
1298
+ z-index: 2;
1299
+ margin: 0 1px 1px 0;
1300
+ font-size: 16px;
1301
+ transition: all ease 0.2s;
1302
+ }
1303
+ }
1304
+ `;
1305
+ const MessageDiv = styled.div`
1306
+ color: ${props => props.theme.palette.primary.main};
1307
+ .msg-before {
1308
+ display: inline-block;
1309
+ color: #aaa;
1310
+ font-size: 14px;
1311
+ margin-right: 6px;
1312
+ }
1313
+ `;