@blocklet/launcher-layout 2.1.108 → 2.2.1

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/nav.js ADDED
@@ -0,0 +1,407 @@
1
+ import styled from '@emotion/styled';
2
+ import Check from '@mui/icons-material/Check';
3
+ import Skeleton from '@mui/material/Skeleton';
4
+ import PropTypes from 'prop-types';
5
+ import { useStepContext } from './context/step';
6
+ import AppHeader from './header';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { jsxs as _jsxs } from "react/jsx-runtime";
9
+ function Nav({
10
+ blockletMeta,
11
+ logoUrl,
12
+ locale,
13
+ useOfSkeleton,
14
+ subTitle,
15
+ loading
16
+ }) {
17
+ const {
18
+ steps,
19
+ activeStep,
20
+ setActiveStepByKey,
21
+ setActiveStepByIndex,
22
+ getStepStatus,
23
+ canBackToStep
24
+ } = useStepContext();
25
+ const showSkeleton = useOfSkeleton ? loading : false;
26
+ const getNodeClassName = (step, index) => {
27
+ const classNameList = ['step-block'];
28
+ const status = getStepStatus(step.key);
29
+ switch (status) {
30
+ case 'current':
31
+ classNameList.push('step-active');
32
+ break;
33
+ case 'before':
34
+ classNameList.push('step-checked');
35
+ break;
36
+ case 'after':
37
+ default:
38
+ }
39
+ switch (step.showChild) {
40
+ case 'activated':
41
+ if (status === 'after') {
42
+ classNameList.push('hide-step-child');
43
+ }
44
+ break;
45
+ case 'activating':
46
+ if (status === 'after' || status === 'before') {
47
+ classNameList.push('hide-step-child');
48
+ }
49
+ break;
50
+ case 'always':
51
+ classNameList.push('always-step-child');
52
+ break;
53
+ default:
54
+ }
55
+ if (step.optional === true && activeStep < index) {
56
+ classNameList.push('step-optional'); // optional在没有匹配到路由情况下会隐藏;超越这个步骤后就会一直出现
57
+ }
58
+
59
+ return classNameList.join(' ');
60
+ };
61
+ return /*#__PURE__*/_jsxs(Div, {
62
+ children: [/*#__PURE__*/_jsx(AppHeader, {
63
+ blockletMeta: blockletMeta,
64
+ loading: loading,
65
+ logoUrl: logoUrl,
66
+ locale: locale,
67
+ subTitle: subTitle
68
+ }), /*#__PURE__*/_jsx(StepContainer, {
69
+ className: `${showSkeleton ? 'hide-child-step-desc' : ''}`,
70
+ children: steps.map((step, index) => {
71
+ const canBack = !showSkeleton && canBackToStep(index);
72
+ return /*#__PURE__*/_jsxs("div", {
73
+ className: getNodeClassName(step, index),
74
+ children: [/*#__PURE__*/_jsx("div", {
75
+ className: "step-icon",
76
+ children: /*#__PURE__*/_jsx(Check, {
77
+ style: {
78
+ fontSize: 16
79
+ }
80
+ })
81
+ }), /*#__PURE__*/_jsx("div", {
82
+ className: "step-line"
83
+ }), /*#__PURE__*/_jsxs("div", {
84
+ className: "step-content",
85
+ title: step.name,
86
+ children: [/*#__PURE__*/_jsx("span", {
87
+ className: `step-content-name ${canBack ? ' step-clickable' : ''}`,
88
+ onClick: () => {
89
+ if (canBack) {
90
+ if (step.key) {
91
+ setActiveStepByKey(step.key);
92
+ return;
93
+ }
94
+ setActiveStepByIndex(index);
95
+ }
96
+ },
97
+ children: showSkeleton ? /*#__PURE__*/_jsx(Skeleton, {
98
+ variant: "text",
99
+ width: 100
100
+ }) : step.name
101
+ }), step.description && /*#__PURE__*/_jsx("div", {
102
+ className: "step-desc",
103
+ children: step.description
104
+ }), step.children && step.children.length && /*#__PURE__*/_jsx("div", {
105
+ className: "step-children",
106
+ children: step.children.map(e => {
107
+ let className = '';
108
+ const childStepStatus = getStepStatus(e.key);
109
+ switch (childStepStatus) {
110
+ case 'before':
111
+ className = 'step-child-block-checked';
112
+ break;
113
+ case 'current':
114
+ className = 'step-child-block-active';
115
+ break;
116
+ case 'after':
117
+ default:
118
+ }
119
+ return /*#__PURE__*/_jsx("div", {
120
+ className: `step-child-block ${className}`,
121
+ children: e.name
122
+ }, e.key);
123
+ })
124
+ })]
125
+ })]
126
+ }, step.key);
127
+ })
128
+ })]
129
+ });
130
+ }
131
+ const Div = styled.div`
132
+ overflow-y: auto;
133
+ ${props => props.theme.breakpoints.up('md')} {
134
+ padding: 24px;
135
+ border-right: 1px solid ${props => props.theme.palette.grey[100]};
136
+ flex: 0 0 280px;
137
+ min-height: 48px;
138
+
139
+ .MuiStepConnector-vertical {
140
+ padding: 0;
141
+ }
142
+ }
143
+
144
+ ${props => props.theme.breakpoints.down('md')} {
145
+ padding: 16px;
146
+
147
+ .MuiStepConnector-lineVertical {
148
+ border: none;
149
+ }
150
+ }
151
+
152
+ .stepper {
153
+ padding: 0 !important;
154
+ background: transparent;
155
+
156
+ ${props => props.theme.breakpoints.up('sm')} {
157
+ margin-top: 100px;
158
+ }
159
+
160
+ ${props => props.theme.breakpoints.down('md')} {
161
+ margin-top: 40px;
162
+ }
163
+
164
+ .step {
165
+ cursor: pointer;
166
+ }
167
+ }
168
+
169
+ .always-step-child {
170
+ .step-child-block {
171
+ animation: none !important;
172
+ }
173
+ }
174
+ `;
175
+ const StepContainer = styled.div`
176
+ display: flex;
177
+ flex-direction: column;
178
+ margin-top: 60px;
179
+
180
+ @media (max-height: 900px) {
181
+ margin-top: 32px;
182
+ }
183
+
184
+ ${props => props.theme.breakpoints.down('md')} {
185
+ margin-top: 30px;
186
+ }
187
+ .step-clickable {
188
+ cursor: pointer;
189
+ &:hover {
190
+ color: ${props => props.theme.palette.primary.main};
191
+ }
192
+ }
193
+ .step-line {
194
+ display: block;
195
+ position: absolute;
196
+ z-index: 1;
197
+ left: 11px;
198
+ top: 12px;
199
+ width: 2px;
200
+ height: 100%;
201
+ opacity: 0.5;
202
+ background-color: ${props => props.theme.palette.grey[400]};
203
+ transition: all ease 0.2s;
204
+ }
205
+ .step-icon {
206
+ position: relative;
207
+ z-index: 2;
208
+ display: flex;
209
+ flex-shrink: 0;
210
+ justify-content: center;
211
+ align-items: center;
212
+ width: 24px;
213
+ height: 24px;
214
+ border-radius: 13px;
215
+ background-color: ${props => props.theme.palette.grey[400]};
216
+ color: ${props => props.theme.palette.common.white};
217
+ transition: all ease 0.3s;
218
+ &:before {
219
+ position: absolute;
220
+ left: 4px;
221
+ top: 4px;
222
+ z-index: 3;
223
+ display: block;
224
+ background-color: ${props => props.theme.palette.common.white};
225
+ width: 16px;
226
+ height: 16px;
227
+ border-radius: 10px;
228
+ content: '';
229
+ transform: scale(0);
230
+ transition: all ease 0.3s;
231
+ }
232
+ & > * {
233
+ transform: scale(0);
234
+ transition: all ease 0.2s;
235
+ }
236
+ }
237
+ .step-content {
238
+ position: relative;
239
+ flex: 1;
240
+ padding-top: 1px;
241
+ margin-left: 22px;
242
+ font-size: 16px;
243
+ color: ${props => props.theme.palette.grey[700]};
244
+ white-space: nowrap;
245
+ }
246
+ .step-desc {
247
+ margin-top: 24px;
248
+ font-size: 12px;
249
+ font-weight: 500;
250
+ height: 17px;
251
+ color: ${props => props.theme.palette.grey[700]};
252
+ transition: all ease 0.3s;
253
+ overflow: hidden;
254
+ }
255
+ ${props => props.theme.breakpoints.up('md')} {
256
+ .step-content-name {
257
+ position: absolute;
258
+ left: 0;
259
+ top: 0;
260
+ width: 100%;
261
+ overflow: hidden;
262
+ text-overflow: ellipsis;
263
+ }
264
+ }
265
+ &.hide-child-step-desc {
266
+ .step-desc {
267
+ margin: 0;
268
+ opacity: 0;
269
+ height: 0;
270
+ }
271
+ }
272
+ .step-block {
273
+ position: relative;
274
+ display: flex;
275
+ min-height: 70px;
276
+ opacity: 0.5;
277
+ overflow: hidden;
278
+ transition: all ease 0.2s;
279
+ &:last-child {
280
+ height: auto;
281
+ min-height: auto;
282
+ }
283
+ &.step-optional {
284
+ height: 0;
285
+ opacity: 0;
286
+ min-height: 0px;
287
+ }
288
+
289
+ &.step-checked,
290
+ &.step-active {
291
+ .step-desc {
292
+ margin: 0;
293
+ opacity: 0;
294
+ height: 0;
295
+ }
296
+ }
297
+
298
+ &.step-checked {
299
+ opacity: 1;
300
+ .step-icon {
301
+ color: ${props => props.theme.palette.common.white};
302
+ background-color: ${props => props.theme.palette.primary.main};
303
+ & > * {
304
+ transform: scale(1);
305
+ }
306
+ }
307
+
308
+ .step-line {
309
+ background-color: ${props => props.theme.palette.primary.main};
310
+ opacity: 1;
311
+ }
312
+ }
313
+
314
+ &.step-active {
315
+ opacity: 1;
316
+ .step-icon {
317
+ background-color: ${props => props.theme.palette.primary.main};
318
+ }
319
+ .step-icon:before {
320
+ transform: scale(1);
321
+ }
322
+ .step-content {
323
+ color: ${props => props.theme.palette.primary.main};
324
+ }
325
+ }
326
+
327
+ &:last-child {
328
+ .step-line {
329
+ display: none;
330
+ }
331
+
332
+ .step-child-block {
333
+ &:last-child {
334
+ padding-bottom: 0;
335
+ }
336
+ }
337
+ }
338
+
339
+ &.hide-step-child {
340
+ .step-children {
341
+ .step-child-block {
342
+ margin-top: 0;
343
+ height: 0;
344
+ opacity: 0;
345
+ &:last-child {
346
+ padding-bottom: 0;
347
+ }
348
+ }
349
+ }
350
+ }
351
+ }
352
+ .step-children {
353
+ padding-top: 20px;
354
+ .step-child-block {
355
+ margin-top: 4px;
356
+ height: 24px;
357
+ line-height: 24px;
358
+ font-size: 14px;
359
+ color: #9397a1;
360
+ transition: all ease 0.3s;
361
+ &:first-of-type {
362
+ margin-top: 8px;
363
+ }
364
+ &:last-child {
365
+ padding-bottom: 40px;
366
+ }
367
+ &.step-child-block-active {
368
+ color: ${props => props.theme.palette.common.black};
369
+ font-weight: 700;
370
+ }
371
+ &.step-child-block-checked {
372
+ color: ${props => props.theme.palette.common.black};
373
+ }
374
+ }
375
+ }
376
+
377
+ .step-active {
378
+ .step-child-block {
379
+ animation: stepChildAnime ease 0.3s;
380
+ }
381
+ }
382
+
383
+ @keyframes stepChildAnime {
384
+ 0% {
385
+ height: 0;
386
+ }
387
+ 100% {
388
+ height: 24px;
389
+ }
390
+ }
391
+ `;
392
+ Nav.propTypes = {
393
+ blockletMeta: PropTypes.object.isRequired,
394
+ logoUrl: PropTypes.string,
395
+ locale: PropTypes.string,
396
+ useOfSkeleton: PropTypes.bool,
397
+ subTitle: PropTypes.string,
398
+ loading: PropTypes.bool
399
+ };
400
+ Nav.defaultProps = {
401
+ logoUrl: '',
402
+ locale: '',
403
+ useOfSkeleton: false,
404
+ subTitle: '',
405
+ loading: false
406
+ };
407
+ export default Nav;
@@ -0,0 +1,67 @@
1
+ import styled from '@emotion/styled';
2
+ import PropTypes from 'prop-types';
3
+ import ArrowBackIosIcon from '@mui/icons-material/ArrowBackIos';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { jsxs as _jsxs } from "react/jsx-runtime";
6
+ function PageHeader({
7
+ title,
8
+ subTitle,
9
+ onClickBack,
10
+ ...rest
11
+ }) {
12
+ return /*#__PURE__*/_jsxs(Content, {
13
+ ...rest,
14
+ children: [onClickBack && /*#__PURE__*/_jsx(ArrowBackIosIcon, {
15
+ className: "back-btn",
16
+ onClick: onClickBack
17
+ }), /*#__PURE__*/_jsx("div", {
18
+ className: "title",
19
+ children: title
20
+ }), /*#__PURE__*/_jsx("div", {
21
+ className: "sub-title",
22
+ children: subTitle
23
+ })]
24
+ });
25
+ }
26
+ const Content = styled.div`
27
+ position: relative;
28
+ width: 100%;
29
+ text-align: center;
30
+
31
+ .title {
32
+ font-size: 24px;
33
+ font-weight: 700;
34
+ color: ${props => props.theme.palette.common.black};
35
+
36
+ ${props => props.theme.breakpoints.down('md')} {
37
+ font-size: 20px;
38
+ }
39
+ }
40
+
41
+ .sub-title {
42
+ font-size: 14px;
43
+ color: ${props => props.theme.palette.grey[600]};
44
+ padding: 0 14px;
45
+ font-weight: 400;
46
+ }
47
+
48
+ .back-btn {
49
+ position: absolute;
50
+ left: 0;
51
+ top: 8px;
52
+ color: #9397a1;
53
+ font-size: 18px;
54
+ cursor: pointer;
55
+ }
56
+ `;
57
+ export default PageHeader;
58
+ PageHeader.propTypes = {
59
+ title: PropTypes.string,
60
+ subTitle: PropTypes.string,
61
+ onClickBack: PropTypes.oneOfType([PropTypes.func, PropTypes.string])
62
+ };
63
+ PageHeader.defaultProps = {
64
+ title: '',
65
+ subTitle: '',
66
+ onClickBack: ''
67
+ };
@@ -0,0 +1,41 @@
1
+ import { createContext, useEffect, useState, useContext } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { ThemeProvider as EmotionThemeProvider } from '@emotion/react';
4
+ import { ThemeProvider as UxThemeProvider, create } from '@arcblock/ux/lib/Theme';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const defaultTheme = create({});
7
+ const ThemeContext = /*#__PURE__*/createContext({});
8
+ export default function ThemeProvider({
9
+ children,
10
+ theme: _theme
11
+ } = {}) {
12
+ const [theme, setTheme] = useState(defaultTheme);
13
+ useEffect(() => {
14
+ if (_theme && typeof _theme === 'object') setTheme(_theme);
15
+ }, [_theme]);
16
+ if (theme) {
17
+ return /*#__PURE__*/_jsx(ThemeContext.Provider, {
18
+ value: theme,
19
+ children: /*#__PURE__*/_jsx(ThemeContext.Consumer, {
20
+ children: themeValue => {
21
+ return /*#__PURE__*/_jsx(UxThemeProvider, {
22
+ theme: themeValue,
23
+ children: /*#__PURE__*/_jsx(EmotionThemeProvider, {
24
+ theme: themeValue,
25
+ children: children
26
+ })
27
+ });
28
+ }
29
+ })
30
+ });
31
+ }
32
+ return children;
33
+ }
34
+ ThemeProvider.propTypes = {
35
+ children: PropTypes.any.isRequired,
36
+ theme: PropTypes.object.isRequired
37
+ };
38
+ function useThemeContext() {
39
+ return useContext(ThemeContext);
40
+ }
41
+ export { ThemeProvider, useThemeContext };
@@ -0,0 +1,98 @@
1
+ /* eslint-disable react/jsx-wrap-multilines */
2
+ import { useState } from 'react';
3
+ import styled from '@emotion/styled';
4
+ import PropTypes from 'prop-types';
5
+ import Spinner from '@mui/material/CircularProgress';
6
+ import Button from '@arcblock/ux/lib/Button';
7
+ import Dialog from '@arcblock/ux/lib/Dialog';
8
+ import SubmitHotKey from '@blocklet/launcher-ux/lib/hot-key/submit';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { Fragment as _Fragment } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ function ServerEula({
13
+ onContinue,
14
+ nextDisabled,
15
+ launching,
16
+ texts,
17
+ description
18
+ }) {
19
+ const [open, setOpen] = useState(false);
20
+ const handleOpen = () => setOpen(x => !x);
21
+ return /*#__PURE__*/_jsxs(_Fragment, {
22
+ children: [/*#__PURE__*/_jsx(Div, {
23
+ children: /*#__PURE__*/_jsxs(SubmitHotKey, {
24
+ disabled: nextDisabled,
25
+ onConfirm: onContinue,
26
+ children: [/*#__PURE__*/_jsx("div", {
27
+ className: "eula-trigger",
28
+ onClick: handleOpen,
29
+ children: texts.listenName
30
+ }), /*#__PURE__*/_jsx(Button, {
31
+ disabled: nextDisabled,
32
+ color: "primary",
33
+ variant: "contained",
34
+ className: "next-button",
35
+ onClick: onContinue,
36
+ children: launching ? /*#__PURE__*/_jsxs(_Fragment, {
37
+ children: [/*#__PURE__*/_jsx(Spinner, {
38
+ size: 14
39
+ }), texts.launchingText]
40
+ }) : texts.buttonNext
41
+ })]
42
+ })
43
+ }), /*#__PURE__*/_jsx(Dialog, {
44
+ open: open,
45
+ title: texts.listenName,
46
+ onClose: () => setOpen(false),
47
+ children: description
48
+ })]
49
+ });
50
+ }
51
+ ServerEula.propTypes = {
52
+ onContinue: PropTypes.func.isRequired,
53
+ nextDisabled: PropTypes.bool,
54
+ launching: PropTypes.bool,
55
+ description: PropTypes.any,
56
+ texts: PropTypes.object
57
+ };
58
+ ServerEula.defaultProps = {
59
+ nextDisabled: false,
60
+ launching: false,
61
+ description: '',
62
+ texts: {
63
+ listenName: '',
64
+ launchingText: '',
65
+ buttonNext: ''
66
+ }
67
+ };
68
+ const Div = styled.div`
69
+ margin: 0 auto;
70
+ display: flex;
71
+ justify-content: space-between;
72
+ align-items: center;
73
+
74
+ @media (max-width: ${props => props.theme.breakpoints.values.sm}px) {
75
+ flex-direction: column;
76
+ }
77
+
78
+ .eula-trigger {
79
+ cursor: pointer;
80
+ text-decoration: underline;
81
+ ${props => props.theme.breakpoints.up('md')} {
82
+ padding-right: 24px;
83
+ }
84
+ ${props => props.theme.breakpoints.down('md')} {
85
+ padding: 16px;
86
+ }
87
+ font-size: 14px;
88
+ white-space: nowrap;
89
+ &:hover {
90
+ color: ${props => props.theme.palette.primary.main};
91
+ }
92
+ }
93
+
94
+ .next-button {
95
+ min-width: 200px;
96
+ }
97
+ `;
98
+ export default ServerEula;