@blocklet/launcher-layout 2.1.108 → 2.2.0
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.
- package/es/assets/blocklet-default-logo.png +0 -0
- package/es/compact-layout.js +115 -0
- package/es/content.js +72 -0
- package/es/context/step.js +137 -0
- package/es/header.js +337 -0
- package/es/index.js +302 -0
- package/es/launch-result-message.js +145 -0
- package/es/locale.js +13 -0
- package/es/nav.js +407 -0
- package/es/page-header.js +67 -0
- package/es/theme-provider.js +41 -0
- package/es/wizard/server-eula.js +98 -0
- package/es/wizard/wizard-desc.js +240 -0
- package/lib/header.js +3 -3
- package/lib/index.js +2 -2
- package/lib/launch-result-message.js +2 -2
- package/lib/locale.js +6 -4
- package/lib/page-header.js +2 -2
- package/package.json +24 -7
package/es/index.js
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import Center from '@arcblock/ux/lib/Center';
|
|
2
|
+
import { create } from '@arcblock/ux/lib/Theme';
|
|
3
|
+
import SmallCircleProgress from '@blocklet/launcher-ux/lib/small-circle-progress';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
5
|
+
import Spinner from '@mui/material/CircularProgress';
|
|
6
|
+
import Hidden from '@mui/material/Hidden';
|
|
7
|
+
import { ThemeProvider as EmotionThemeProvider } from '@emotion/react';
|
|
8
|
+
import { StyledEngineProvider, ThemeProvider } from '@mui/material/styles';
|
|
9
|
+
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
10
|
+
import Typography from '@mui/material/Typography';
|
|
11
|
+
import isObject from 'lodash/isObject';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import { Suspense, isValidElement } from 'react';
|
|
14
|
+
import { useStepContext } from './context/step';
|
|
15
|
+
import AppHeader from './header';
|
|
16
|
+
import { getTranslations } from './locale';
|
|
17
|
+
import Nav from './nav';
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
21
|
+
const HEADER_HEIGHT_MD = '72px';
|
|
22
|
+
const MobileContent = styled.div`
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
display: flex;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
28
|
+
padding-top: ${HEADER_HEIGHT_MD};
|
|
29
|
+
`;
|
|
30
|
+
const PcContent = styled.div`
|
|
31
|
+
display: flex;
|
|
32
|
+
min-width: 900px;
|
|
33
|
+
max-width: ${props => props.contentMaxWidth};
|
|
34
|
+
max-height: 880px;
|
|
35
|
+
border-radius: 8px;
|
|
36
|
+
background-color: #fff;
|
|
37
|
+
width: ${props => props.width || '80%'};
|
|
38
|
+
height: ${props => props.height || '80%'};
|
|
39
|
+
|
|
40
|
+
@media (max-height: 900px) {
|
|
41
|
+
margin-top: ${HEADER_HEIGHT_MD};
|
|
42
|
+
width: 100%;
|
|
43
|
+
height: 100%;
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
const theme = create({
|
|
47
|
+
typography: {
|
|
48
|
+
fontSize: 14
|
|
49
|
+
},
|
|
50
|
+
palette: {
|
|
51
|
+
primary: {
|
|
52
|
+
main: '#1dc1c7',
|
|
53
|
+
contrastText: '#fff'
|
|
54
|
+
},
|
|
55
|
+
secondary: {
|
|
56
|
+
main: '#1976d2',
|
|
57
|
+
contrastText: '#fff'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
function Layout({
|
|
62
|
+
blockletMeta: tmpBlockletMeta,
|
|
63
|
+
loading,
|
|
64
|
+
children,
|
|
65
|
+
logoUrl,
|
|
66
|
+
locale,
|
|
67
|
+
header,
|
|
68
|
+
headerEndAddons,
|
|
69
|
+
pcWidth,
|
|
70
|
+
pcHeight,
|
|
71
|
+
navLogo,
|
|
72
|
+
useOfSkeleton,
|
|
73
|
+
stepTip,
|
|
74
|
+
navSubTitle,
|
|
75
|
+
contentMaxWidth,
|
|
76
|
+
theme: userTheme,
|
|
77
|
+
...rest
|
|
78
|
+
}) {
|
|
79
|
+
const isMobile = useMediaQuery(t => t.breakpoints.down('md'));
|
|
80
|
+
const {
|
|
81
|
+
activeStep,
|
|
82
|
+
totalStepsCount
|
|
83
|
+
} = useStepContext();
|
|
84
|
+
const blockletMeta = tmpBlockletMeta || {};
|
|
85
|
+
const Container = isMobile ? MobileContent : PcContent;
|
|
86
|
+
const translations = getTranslations(locale);
|
|
87
|
+
if (navLogo && ! /*#__PURE__*/isValidElement(navLogo) && isObject(navLogo)) {
|
|
88
|
+
if (isMobile) {
|
|
89
|
+
// eslint-disable-next-line no-param-reassign
|
|
90
|
+
navLogo = navLogo.mobile;
|
|
91
|
+
} else {
|
|
92
|
+
// eslint-disable-next-line no-param-reassign
|
|
93
|
+
navLogo = /*#__PURE__*/_jsx(LogoContainer, {
|
|
94
|
+
children: navLogo.desktop
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const tempTheme = Object.assign(theme, userTheme || {});
|
|
99
|
+
return /*#__PURE__*/_jsx(StyledEngineProvider, {
|
|
100
|
+
injectFirst: true,
|
|
101
|
+
children: /*#__PURE__*/_jsx(ThemeProvider, {
|
|
102
|
+
theme: tempTheme,
|
|
103
|
+
children: /*#__PURE__*/_jsx(EmotionThemeProvider, {
|
|
104
|
+
theme: tempTheme,
|
|
105
|
+
children: /*#__PURE__*/_jsxs(Root, {
|
|
106
|
+
...rest,
|
|
107
|
+
children: [/*#__PURE__*/_jsxs(Header, {
|
|
108
|
+
maxWidth: contentMaxWidth,
|
|
109
|
+
width: pcWidth,
|
|
110
|
+
children: [header && header, !header && /*#__PURE__*/_jsxs(_Fragment, {
|
|
111
|
+
children: [isMobile && /*#__PURE__*/_jsx("div", {
|
|
112
|
+
className: "left",
|
|
113
|
+
children: /*#__PURE__*/_jsx(AppHeader, {
|
|
114
|
+
blockletMeta: blockletMeta,
|
|
115
|
+
navLogo: navLogo,
|
|
116
|
+
subTitle: /*#__PURE__*/_jsxs("span", {
|
|
117
|
+
children: [`${navSubTitle || translations.defaultNavSubTitle} ${activeStep + 1}/${totalStepsCount}`, /*#__PURE__*/_jsx(SmallCircleProgress, {
|
|
118
|
+
value: (activeStep + 1) / totalStepsCount * 100,
|
|
119
|
+
style: {
|
|
120
|
+
marginLeft: 3
|
|
121
|
+
}
|
|
122
|
+
})]
|
|
123
|
+
}),
|
|
124
|
+
logoUrl: logoUrl,
|
|
125
|
+
locale: locale,
|
|
126
|
+
loading: loading
|
|
127
|
+
})
|
|
128
|
+
}), navLogo && !isMobile && /*#__PURE__*/_jsx("div", {
|
|
129
|
+
className: "left",
|
|
130
|
+
children: navLogo
|
|
131
|
+
}), headerEndAddons && /*#__PURE__*/_jsx("div", {
|
|
132
|
+
className: "right",
|
|
133
|
+
children: headerEndAddons
|
|
134
|
+
})]
|
|
135
|
+
})]
|
|
136
|
+
}), /*#__PURE__*/_jsxs(Container, {
|
|
137
|
+
contentMaxWidth: contentMaxWidth,
|
|
138
|
+
width: pcWidth,
|
|
139
|
+
height: pcHeight,
|
|
140
|
+
children: [/*#__PURE__*/_jsx(Hidden, {
|
|
141
|
+
mdDown: true,
|
|
142
|
+
children: /*#__PURE__*/_jsx(Nav, {
|
|
143
|
+
locale: locale,
|
|
144
|
+
blockletMeta: blockletMeta,
|
|
145
|
+
logoUrl: logoUrl,
|
|
146
|
+
useOfSkeleton: useOfSkeleton,
|
|
147
|
+
subTitle: navSubTitle,
|
|
148
|
+
loading: loading
|
|
149
|
+
})
|
|
150
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
|
151
|
+
component: "div",
|
|
152
|
+
className: "layout-content",
|
|
153
|
+
children: /*#__PURE__*/_jsx(Suspense, {
|
|
154
|
+
fallback: /*#__PURE__*/_jsx(Center, {
|
|
155
|
+
relative: "parent",
|
|
156
|
+
children: /*#__PURE__*/_jsx(Spinner, {
|
|
157
|
+
style: {
|
|
158
|
+
marginTop: 36
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
}),
|
|
162
|
+
children: children
|
|
163
|
+
})
|
|
164
|
+
})]
|
|
165
|
+
})]
|
|
166
|
+
})
|
|
167
|
+
})
|
|
168
|
+
})
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
Layout.propTypes = {
|
|
172
|
+
loading: PropTypes.bool,
|
|
173
|
+
blockletMeta: PropTypes.object,
|
|
174
|
+
children: PropTypes.object.isRequired,
|
|
175
|
+
logoUrl: PropTypes.string,
|
|
176
|
+
locale: PropTypes.oneOf(['en', 'zh']),
|
|
177
|
+
header: PropTypes.any,
|
|
178
|
+
headerEndAddons: PropTypes.any,
|
|
179
|
+
pcWidth: PropTypes.any,
|
|
180
|
+
pcHeight: PropTypes.any,
|
|
181
|
+
contentMaxWidth: PropTypes.string,
|
|
182
|
+
navLogo: PropTypes.oneOfType([PropTypes.node, PropTypes.object]),
|
|
183
|
+
useOfSkeleton: PropTypes.bool,
|
|
184
|
+
stepTip: PropTypes.string,
|
|
185
|
+
navSubTitle: PropTypes.string,
|
|
186
|
+
theme: PropTypes.object
|
|
187
|
+
};
|
|
188
|
+
Layout.defaultProps = {
|
|
189
|
+
loading: false,
|
|
190
|
+
blockletMeta: {},
|
|
191
|
+
logoUrl: '',
|
|
192
|
+
locale: 'en',
|
|
193
|
+
header: null,
|
|
194
|
+
headerEndAddons: null,
|
|
195
|
+
pcWidth: '80%',
|
|
196
|
+
pcHeight: '80%',
|
|
197
|
+
contentMaxWidth: '1245px',
|
|
198
|
+
navLogo: '',
|
|
199
|
+
useOfSkeleton: true,
|
|
200
|
+
stepTip: '',
|
|
201
|
+
navSubTitle: '',
|
|
202
|
+
theme: null
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// 针对 safari 下的 chrome 适配
|
|
206
|
+
const ua = navigator.userAgent.toLocaleLowerCase();
|
|
207
|
+
let injectStyle = '';
|
|
208
|
+
if (ua.includes('iphone os') && ua.includes('crios')) {
|
|
209
|
+
injectStyle = 'height: calc(100vh - 60px);';
|
|
210
|
+
}
|
|
211
|
+
const Header = styled.header`
|
|
212
|
+
width: ${props => props.width || '80%'};
|
|
213
|
+
min-width: 900px;
|
|
214
|
+
box-sizing: border-box;
|
|
215
|
+
position: absolute;
|
|
216
|
+
z-index: 200;
|
|
217
|
+
top: 0;
|
|
218
|
+
display: flex;
|
|
219
|
+
max-width: ${props => props.maxWidth};
|
|
220
|
+
height: 68px;
|
|
221
|
+
align-items: center;
|
|
222
|
+
|
|
223
|
+
@media (max-height: 900px) {
|
|
224
|
+
width: 100%;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
${props => props.theme.breakpoints.up('sm')} and (min-height: 900px) {
|
|
228
|
+
justify-content: flex-end;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
${props => props.theme.breakpoints.down('md')} {
|
|
232
|
+
min-width: 360px;
|
|
233
|
+
width: 100%;
|
|
234
|
+
height: ${HEADER_HEIGHT_MD};
|
|
235
|
+
padding: 14px 16px;
|
|
236
|
+
justify-content: space-between;
|
|
237
|
+
background: #f6f8fa;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.left {
|
|
241
|
+
flex: 1;
|
|
242
|
+
display: flex;
|
|
243
|
+
align-items: center;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.right {
|
|
247
|
+
display: flex;
|
|
248
|
+
align-items: center;
|
|
249
|
+
${props => props.theme.breakpoints.down('md')} {
|
|
250
|
+
button,
|
|
251
|
+
a {
|
|
252
|
+
padding-left: 8px;
|
|
253
|
+
padding-right: 8px;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
`;
|
|
258
|
+
const Root = styled.div`
|
|
259
|
+
display: flex;
|
|
260
|
+
flex-direction: column;
|
|
261
|
+
justify-content: center;
|
|
262
|
+
align-items: center;
|
|
263
|
+
letter-spacing: normal;
|
|
264
|
+
${injectStyle}
|
|
265
|
+
|
|
266
|
+
.circular {
|
|
267
|
+
display: inline-block;
|
|
268
|
+
position: relative;
|
|
269
|
+
width: 15px;
|
|
270
|
+
height: 12px;
|
|
271
|
+
> * {
|
|
272
|
+
position: absolute;
|
|
273
|
+
left: 3px;
|
|
274
|
+
top: 2px;
|
|
275
|
+
width: 100%;
|
|
276
|
+
height: 100%;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.layout-content {
|
|
281
|
+
width: 100%;
|
|
282
|
+
height: 100%;
|
|
283
|
+
padding: 32px;
|
|
284
|
+
|
|
285
|
+
${props => props.theme.breakpoints.down('md')} {
|
|
286
|
+
padding: 16px;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
${props => props.theme.breakpoints.up('sm')} {
|
|
291
|
+
background: #f6f8fa;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
${props => props.theme.breakpoints.down('md')} {
|
|
295
|
+
background: ${props => props.theme.palette.common.white};
|
|
296
|
+
}
|
|
297
|
+
`;
|
|
298
|
+
const LogoContainer = styled.div`
|
|
299
|
+
display: block;
|
|
300
|
+
margin-top: 4px;
|
|
301
|
+
`;
|
|
302
|
+
export default Layout;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import Check from '@mui/icons-material/Check';
|
|
4
|
+
import Close from '@mui/icons-material/Close';
|
|
5
|
+
import Spinner from '@mui/material/CircularProgress';
|
|
6
|
+
import PriorityHigh from '@mui/icons-material/PriorityHigh';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
function LaunchResultMessage({
|
|
10
|
+
variant,
|
|
11
|
+
title,
|
|
12
|
+
subTitle,
|
|
13
|
+
footer,
|
|
14
|
+
...props
|
|
15
|
+
}) {
|
|
16
|
+
let Icon;
|
|
17
|
+
switch (variant) {
|
|
18
|
+
case 'error':
|
|
19
|
+
Icon = Close;
|
|
20
|
+
break;
|
|
21
|
+
case 'info':
|
|
22
|
+
Icon = PriorityHigh;
|
|
23
|
+
break;
|
|
24
|
+
case 'loading':
|
|
25
|
+
Icon = Spinner;
|
|
26
|
+
break;
|
|
27
|
+
default:
|
|
28
|
+
Icon = Check;
|
|
29
|
+
}
|
|
30
|
+
return /*#__PURE__*/_jsx(Container, {
|
|
31
|
+
variant: variant,
|
|
32
|
+
...props,
|
|
33
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
34
|
+
className: "result-body",
|
|
35
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
36
|
+
className: `result-icon color-${variant}`,
|
|
37
|
+
children: /*#__PURE__*/_jsx(Icon, {})
|
|
38
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
39
|
+
className: `result-title color-${variant} ${title ? '' : 'ele-hide'}`,
|
|
40
|
+
children: title
|
|
41
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
42
|
+
className: `result-sub-title ${subTitle ? '' : 'ele-hide'}`,
|
|
43
|
+
children: subTitle
|
|
44
|
+
}), footer && /*#__PURE__*/_jsx("div", {
|
|
45
|
+
className: "result-footer",
|
|
46
|
+
children: footer
|
|
47
|
+
})]
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
LaunchResultMessage.propTypes = {
|
|
52
|
+
variant: PropTypes.oneOf(['success', 'error', 'info', 'loading']),
|
|
53
|
+
title: PropTypes.string,
|
|
54
|
+
subTitle: PropTypes.any,
|
|
55
|
+
footer: PropTypes.any
|
|
56
|
+
};
|
|
57
|
+
LaunchResultMessage.defaultProps = {
|
|
58
|
+
variant: 'success',
|
|
59
|
+
title: '',
|
|
60
|
+
subTitle: '',
|
|
61
|
+
footer: null
|
|
62
|
+
};
|
|
63
|
+
export default LaunchResultMessage;
|
|
64
|
+
const Container = styled.div`
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
align-items: center;
|
|
68
|
+
justify-content: center;
|
|
69
|
+
text-align: center;
|
|
70
|
+
width: 100%;
|
|
71
|
+
height: 100%;
|
|
72
|
+
|
|
73
|
+
.result-body {
|
|
74
|
+
padding: 0 14px;
|
|
75
|
+
max-width: 500px;
|
|
76
|
+
text-align: center;
|
|
77
|
+
margin-top: -64px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.result-icon {
|
|
81
|
+
display: inline-flex;
|
|
82
|
+
justify-content: center;
|
|
83
|
+
align-items: center;
|
|
84
|
+
margin-bottom: 24px;
|
|
85
|
+
width: 48px;
|
|
86
|
+
height: 48px;
|
|
87
|
+
border-radius: 100%;
|
|
88
|
+
color: ${props => props.theme.palette.common.white};
|
|
89
|
+
transition: all ease 0.3s;
|
|
90
|
+
&.color-success {
|
|
91
|
+
background-color: ${props => props.theme.palette.success.main};
|
|
92
|
+
}
|
|
93
|
+
&.color-error {
|
|
94
|
+
background-color: ${props => props.theme.palette.error.main};
|
|
95
|
+
}
|
|
96
|
+
&.color-info {
|
|
97
|
+
background-color: ${props => props.theme.palette.primary.main};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.result-title {
|
|
102
|
+
height: 34px;
|
|
103
|
+
font-size: 21px;
|
|
104
|
+
margin-bottom: 8px;
|
|
105
|
+
font-weight: bolder;
|
|
106
|
+
transition: all ease 0.3s;
|
|
107
|
+
transition-delay: 0.2s;
|
|
108
|
+
&.color-success {
|
|
109
|
+
color: ${props => props.theme.palette.success.main};
|
|
110
|
+
}
|
|
111
|
+
&.color-error {
|
|
112
|
+
color: ${props => props.theme.palette.error.main};
|
|
113
|
+
}
|
|
114
|
+
&.color-info {
|
|
115
|
+
color: ${props => props.theme.palette.primary.main};
|
|
116
|
+
}
|
|
117
|
+
&.ele-hide {
|
|
118
|
+
height: 0;
|
|
119
|
+
opacity: 0;
|
|
120
|
+
margin-bottom: 0;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.result-sub-title {
|
|
125
|
+
margin: 0 auto;
|
|
126
|
+
min-height: 17px;
|
|
127
|
+
color: ${props => props.theme.palette.grey[700]};
|
|
128
|
+
font-size: 14px;
|
|
129
|
+
line-height: 1.21em; // 0.01可以解决视网膜屏轻微偏移问题
|
|
130
|
+
transition: all ease 0.3s;
|
|
131
|
+
transition-delay: 0.2s;
|
|
132
|
+
word-break: break-word;
|
|
133
|
+
&.ele-hide {
|
|
134
|
+
line-height: 0;
|
|
135
|
+
opacity: 0;
|
|
136
|
+
min-height: 0;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.result-footer {
|
|
141
|
+
padding-top: 24px;
|
|
142
|
+
transition: all ease 0.3s;
|
|
143
|
+
transition-delay: 0.2s;
|
|
144
|
+
}
|
|
145
|
+
`;
|
package/es/locale.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const translations = {
|
|
2
|
+
en: {
|
|
3
|
+
optional: 'Optional',
|
|
4
|
+
defaultNavSubTitle: 'Launching'
|
|
5
|
+
},
|
|
6
|
+
zh: {
|
|
7
|
+
optional: '可选',
|
|
8
|
+
defaultNavSubTitle: '启动'
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const getTranslations = locale => translations[locale] ? translations[locale] : translations.en;
|
|
12
|
+
const getLaunchingText = locale => locale === 'zh' ? '启动' : 'Launching';
|
|
13
|
+
export { getTranslations, getLaunchingText };
|