@blocklet/launcher-layout 2.13.69 → 3.0.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/lib/nav.js CHANGED
@@ -1,178 +1,132 @@
1
- import styled from '@emotion/styled';
2
- import Check from '@mui/icons-material/Check';
3
- import { Button, Skeleton, Tooltip, Typography } from '@mui/material';
4
- import PropTypes from 'prop-types';
5
- import { useStepContext } from './context/step';
6
- import AppHeader from './header';
7
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
- function Nav({
9
- blockletMeta,
10
- logoUrl,
11
- locale,
12
- useOfSkeleton,
13
- subTitle,
14
- loading,
15
- extraNav
1
+ import { jsxs as l, jsx as o } from "react/jsx-runtime";
2
+ import k from "@emotion/styled";
3
+ import { Check as B } from "@mui/icons-material";
4
+ import { Box as x, Skeleton as A, Tooltip as P, Button as g, Typography as I } from "@mui/material";
5
+ import s from "prop-types";
6
+ import { useStepContext as M } from "./context/step.js";
7
+ import N from "./header.js";
8
+ function _({
9
+ blockletMeta: e,
10
+ logoUrl: f = "",
11
+ locale: u = "",
12
+ useOfSkeleton: y = !1,
13
+ subTitle: w = "",
14
+ loading: d = !1,
15
+ extraNav: t = null,
16
+ sx: v
16
17
  }) {
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');
18
+ var m, b;
19
+ const { steps: $, activeStep: S, setActiveStepByKey: C, setActiveStepByIndex: z, getStepStatus: h, canBackToStep: T } = M(), c = y ? d : !1, j = (i, p) => {
20
+ const n = ["step-block"], a = h(i.key);
21
+ switch (a) {
22
+ case "current":
23
+ n.push("step-active");
32
24
  break;
33
- case 'before':
34
- classNameList.push('step-checked');
25
+ case "before":
26
+ n.push("step-checked");
35
27
  break;
36
- case 'after':
37
- default:
38
28
  }
39
- switch (step.showChild) {
40
- case 'activated':
41
- if (status === 'after') {
42
- classNameList.push('hide-step-child');
43
- }
29
+ switch (i.showChild) {
30
+ case "activated":
31
+ a === "after" && n.push("hide-step-child");
44
32
  break;
45
- case 'activating':
46
- if (status === 'after' || status === 'before') {
47
- classNameList.push('hide-step-child');
48
- }
33
+ case "activating":
34
+ (a === "after" || a === "before") && n.push("hide-step-child");
49
35
  break;
50
- case 'always':
51
- classNameList.push('always-step-child');
36
+ case "always":
37
+ n.push("always-step-child");
52
38
  break;
53
- default:
54
39
  }
55
- if (step.optional === true && activeStep < index) {
56
- classNameList.push('step-optional'); // optional在没有匹配到路由情况下会隐藏;超越这个步骤后就会一直出现
57
- }
58
- return classNameList.join(' ');
40
+ return i.optional === !0 && S < p && n.push("step-optional"), n.join(" ");
59
41
  };
60
- return /*#__PURE__*/_jsxs(Div, {
61
- children: [/*#__PURE__*/_jsx(AppHeader, {
62
- blockletMeta: blockletMeta,
63
- loading: loading,
64
- logoUrl: logoUrl,
65
- locale: locale,
66
- subTitle: subTitle
67
- }), /*#__PURE__*/_jsx(StepContainer, {
68
- className: `${showSkeleton ? 'hide-child-step-desc' : ''}`,
69
- children: steps.map((step, index) => {
70
- const canBack = !showSkeleton && canBackToStep(index);
71
- return /*#__PURE__*/_jsxs("div", {
72
- className: getNodeClassName(step, index),
73
- children: [/*#__PURE__*/_jsx("div", {
74
- className: "step-icon",
75
- children: /*#__PURE__*/_jsx(Check, {
76
- style: {
77
- fontSize: 16
78
- }
79
- })
80
- }), /*#__PURE__*/_jsx("div", {
81
- className: "step-line"
82
- }), /*#__PURE__*/_jsxs("div", {
83
- className: "step-content",
84
- title: step.name,
85
- children: [/*#__PURE__*/_jsx("span", {
86
- className: `step-content-name ${canBack ? ' step-clickable' : ''}`,
42
+ return /* @__PURE__ */ l(q, { sx: v, children: [
43
+ /* @__PURE__ */ o(N, { blockletMeta: e, loading: d, logoUrl: f, locale: u, subTitle: w }),
44
+ /* @__PURE__ */ o(D, { className: `${c ? "hide-child-step-desc" : ""}`, children: $.map((i, p) => {
45
+ const n = !c && T(p);
46
+ return /* @__PURE__ */ l("div", { className: j(i, p), children: [
47
+ /* @__PURE__ */ o("div", { className: "step-icon", children: /* @__PURE__ */ o(B, { style: { fontSize: 16 } }) }),
48
+ /* @__PURE__ */ o("div", { className: "step-line" }),
49
+ /* @__PURE__ */ l("div", { className: "step-content", title: i.name, children: [
50
+ /* @__PURE__ */ o(
51
+ "span",
52
+ {
53
+ className: `step-content-name ${n ? " step-clickable" : ""}`,
87
54
  onClick: () => {
88
- if (canBack) {
89
- if (step.key) {
90
- setActiveStepByKey(step.key);
55
+ if (n) {
56
+ if (i.key) {
57
+ C(i.key);
91
58
  return;
92
59
  }
93
- setActiveStepByIndex(index);
60
+ z(p);
94
61
  }
95
62
  },
96
- children: showSkeleton ? /*#__PURE__*/_jsx(Skeleton, {
97
- variant: "text",
98
- width: 100
99
- }) : step.name
100
- }), step.description && /*#__PURE__*/_jsx("div", {
101
- className: "step-desc",
102
- children: step.description
103
- }), step.children && step.children.length && /*#__PURE__*/_jsx("div", {
104
- className: "step-children",
105
- children: step.children.map(e => {
106
- let className = '';
107
- const childStepStatus = getStepStatus(e.key);
108
- switch (childStepStatus) {
109
- case 'before':
110
- className = 'step-child-block-checked';
111
- break;
112
- case 'current':
113
- className = 'step-child-block-active';
114
- break;
115
- case 'after':
116
- default:
117
- }
118
- return /*#__PURE__*/_jsx("div", {
119
- className: `step-child-block ${className}`,
120
- children: e.name
121
- }, e.key);
122
- })
123
- })]
124
- })]
125
- }, step.key);
126
- })
127
- }), extraNav && /*#__PURE__*/_jsxs("div", {
128
- className: "extra-nav",
129
- children: [extraNav.tooltipText ? /*#__PURE__*/_jsx(Tooltip, {
130
- title: extraNav.tooltipText,
131
- children: /*#__PURE__*/_jsx(Button, {
132
- variant: extraNav.buttonProps?.variant || 'text',
133
- onClick: () => {
134
- if (extraNav.link) {
135
- window.open(extraNav.link, '_blank');
63
+ children: c ? /* @__PURE__ */ o(A, { variant: "text", width: 100 }) : i.name
64
+ }
65
+ ),
66
+ i.description && /* @__PURE__ */ o("div", { className: "step-desc", children: i.description }),
67
+ i.children && i.children.length && /* @__PURE__ */ o("div", { className: "step-children", children: i.children.map((a) => {
68
+ let r = "";
69
+ switch (h(a.key)) {
70
+ case "before":
71
+ r = "step-child-block-checked";
72
+ break;
73
+ case "current":
74
+ r = "step-child-block-active";
75
+ break;
136
76
  }
77
+ return /* @__PURE__ */ o("div", { className: `step-child-block ${r}`, children: a.name }, a.key);
78
+ }) })
79
+ ] })
80
+ ] }, i.key);
81
+ }) }),
82
+ t && /* @__PURE__ */ l("div", { className: "extra-nav", children: [
83
+ t.tooltipText ? /* @__PURE__ */ o(P, { title: t.tooltipText, children: /* @__PURE__ */ o(
84
+ g,
85
+ {
86
+ variant: ((m = t.buttonProps) == null ? void 0 : m.variant) || "text",
87
+ onClick: () => {
88
+ t.link && window.open(t.link, "_blank");
137
89
  },
138
- startIcon: extraNav.icon,
90
+ startIcon: t.icon,
139
91
  className: "extra-nav-button",
140
92
  size: "small",
141
- ...extraNav.buttonProps,
142
- children: extraNav.text
143
- })
144
- }) : /*#__PURE__*/_jsx(Button, {
145
- variant: extraNav.buttonProps?.variant || 'text',
146
- onClick: () => {
147
- if (extraNav.link) {
148
- window.open(extraNav.link, '_blank');
149
- }
150
- },
151
- startIcon: extraNav.icon,
152
- size: "small",
153
- className: "extra-nav-button",
154
- ...extraNav.buttonProps,
155
- children: extraNav.text
156
- }), extraNav.description && /*#__PURE__*/_jsx(Typography, {
157
- variant: "caption",
158
- sx: {
159
- color: 'text.secondary',
160
- mt: 0.5
161
- },
162
- component: "p",
163
- className: "extra-nav-description",
164
- children: extraNav.description
165
- })]
166
- })]
167
- });
93
+ ...t.buttonProps,
94
+ children: t.text
95
+ }
96
+ ) }) : /* @__PURE__ */ o(
97
+ g,
98
+ {
99
+ variant: ((b = t.buttonProps) == null ? void 0 : b.variant) || "text",
100
+ onClick: () => {
101
+ t.link && window.open(t.link, "_blank");
102
+ },
103
+ startIcon: t.icon,
104
+ size: "small",
105
+ className: "extra-nav-button",
106
+ ...t.buttonProps,
107
+ children: t.text
108
+ }
109
+ ),
110
+ t.description && /* @__PURE__ */ o(
111
+ I,
112
+ {
113
+ variant: "caption",
114
+ sx: { color: "text.secondary", mt: 0.5 },
115
+ component: "p",
116
+ className: "extra-nav-description",
117
+ children: t.description
118
+ }
119
+ )
120
+ ] })
121
+ ] });
168
122
  }
169
- const Div = styled.div`
123
+ const q = k(x)`
170
124
  overflow-y: auto;
171
125
  display: flex;
172
126
  flex-direction: column;
173
- ${props => props.theme.breakpoints.up('md')} {
127
+ ${(e) => e.theme.breakpoints.up("md")} {
174
128
  padding: 24px;
175
- border-right: 1px solid ${props => props.theme.palette.divider};
129
+ border-right: 1px solid ${(e) => e.theme.palette.divider};
176
130
  flex: 0 0 280px;
177
131
  min-height: 48px;
178
132
 
@@ -181,7 +135,7 @@ const Div = styled.div`
181
135
  }
182
136
  }
183
137
 
184
- ${props => props.theme.breakpoints.down('md')} {
138
+ ${(e) => e.theme.breakpoints.down("md")} {
185
139
  padding: 16px;
186
140
 
187
141
  .MuiStepConnector-lineVertical {
@@ -193,11 +147,11 @@ const Div = styled.div`
193
147
  padding: 0 !important;
194
148
  background: transparent;
195
149
 
196
- ${props => props.theme.breakpoints.up('sm')} {
150
+ ${(e) => e.theme.breakpoints.up("sm")} {
197
151
  margin-top: 100px;
198
152
  }
199
153
 
200
- ${props => props.theme.breakpoints.down('md')} {
154
+ ${(e) => e.theme.breakpoints.down("md")} {
201
155
  margin-top: 40px;
202
156
  }
203
157
 
@@ -214,8 +168,7 @@ const Div = styled.div`
214
168
  .extra-nav-button {
215
169
  cursor: pointer;
216
170
  }
217
- `;
218
- const StepContainer = styled.div`
171
+ `, D = k(x)`
219
172
  display: flex;
220
173
  flex-direction: column;
221
174
  margin-top: 60px;
@@ -225,13 +178,13 @@ const StepContainer = styled.div`
225
178
  margin-top: 32px;
226
179
  }
227
180
 
228
- ${props => props.theme.breakpoints.down('md')} {
181
+ ${(e) => e.theme.breakpoints.down("md")} {
229
182
  margin-top: 30px;
230
183
  }
231
184
  .step-clickable {
232
185
  cursor: pointer;
233
186
  &:hover {
234
- color: ${props => props.theme.palette.primary.main};
187
+ color: ${(e) => e.theme.palette.primary.main};
235
188
  }
236
189
  }
237
190
  .step-line {
@@ -243,7 +196,7 @@ const StepContainer = styled.div`
243
196
  width: 2px;
244
197
  height: 100%;
245
198
  opacity: 0.5;
246
- background-color: ${props => props.theme.palette.grey[400]};
199
+ background-color: ${(e) => e.theme.palette.grey[400]};
247
200
  transition: all ease 0.2s;
248
201
  }
249
202
  .step-icon {
@@ -256,9 +209,9 @@ const StepContainer = styled.div`
256
209
  box-sizing: border-box;
257
210
  width: 24px;
258
211
  height: 24px;
259
- border: 4px solid ${props => props.theme.palette.grey[400]};
212
+ border: 4px solid ${(e) => e.theme.palette.grey[400]};
260
213
  border-radius: 13px;
261
- color: ${props => props.theme.palette.common.white};
214
+ color: ${(e) => e.theme.palette.common.white};
262
215
  transition: all ease 0.3s;
263
216
 
264
217
  & > * {
@@ -272,7 +225,7 @@ const StepContainer = styled.div`
272
225
  padding-top: 1px;
273
226
  margin-left: 22px;
274
227
  font-size: 16px;
275
- color: ${props => props.theme.palette.grey[700]};
228
+ color: ${(e) => e.theme.palette.grey[700]};
276
229
  white-space: nowrap;
277
230
  }
278
231
  .step-desc {
@@ -280,11 +233,11 @@ const StepContainer = styled.div`
280
233
  font-size: 12px;
281
234
  font-weight: 500;
282
235
  height: 17px;
283
- color: ${props => props.theme.palette.grey[700]};
236
+ color: ${(e) => e.theme.palette.grey[700]};
284
237
  transition: all ease 0.3s;
285
238
  overflow: hidden;
286
239
  }
287
- ${props => props.theme.breakpoints.up('md')} {
240
+ ${(e) => e.theme.breakpoints.up("md")} {
288
241
  .step-content-name {
289
242
  position: absolute;
290
243
  left: 0;
@@ -330,16 +283,16 @@ const StepContainer = styled.div`
330
283
  &.step-checked {
331
284
  opacity: 1;
332
285
  .step-icon {
333
- color: ${props => props.theme.palette.primary.white};
334
- border-color: ${props => props.theme.palette.primary.main};
335
- background-color: ${props => props.theme.palette.primary.main};
286
+ color: ${(e) => e.theme.palette.primary.white};
287
+ border-color: ${(e) => e.theme.palette.primary.main};
288
+ background-color: ${(e) => e.theme.palette.primary.main};
336
289
  & > * {
337
290
  transform: scale(1);
338
291
  }
339
292
  }
340
293
 
341
294
  .step-line {
342
- background-color: ${props => props.theme.palette.primary.main};
295
+ background-color: ${(e) => e.theme.palette.primary.main};
343
296
  opacity: 1;
344
297
  }
345
298
  }
@@ -347,10 +300,10 @@ const StepContainer = styled.div`
347
300
  &.step-active {
348
301
  opacity: 1;
349
302
  .step-icon {
350
- border-color: ${props => props.theme.palette.primary.main};
303
+ border-color: ${(e) => e.theme.palette.primary.main};
351
304
  }
352
305
  .step-content {
353
- color: ${props => props.theme.palette.primary.main};
306
+ color: ${(e) => e.theme.palette.primary.main};
354
307
  }
355
308
  }
356
309
 
@@ -386,7 +339,7 @@ const StepContainer = styled.div`
386
339
  height: 24px;
387
340
  line-height: 24px;
388
341
  font-size: 14px;
389
- color: ${props => props.theme.palette.grey[500]};
342
+ color: ${(e) => e.theme.palette.grey[500]};
390
343
  transition: all ease 0.3s;
391
344
  &:first-of-type {
392
345
  margin-top: 8px;
@@ -395,11 +348,11 @@ const StepContainer = styled.div`
395
348
  padding-bottom: 40px;
396
349
  }
397
350
  &.step-child-block-active {
398
- color: ${props => props.theme.palette.text.primary};
351
+ color: ${(e) => e.theme.palette.text.primary};
399
352
  font-weight: 700;
400
353
  }
401
354
  &.step-child-block-checked {
402
- color: ${props => props.theme.palette.text.primary};
355
+ color: ${(e) => e.theme.palette.text.primary};
403
356
  }
404
357
  }
405
358
  }
@@ -419,21 +372,16 @@ const StepContainer = styled.div`
419
372
  }
420
373
  }
421
374
  `;
422
- Nav.propTypes = {
423
- blockletMeta: PropTypes.object.isRequired,
424
- logoUrl: PropTypes.string,
425
- locale: PropTypes.string,
426
- useOfSkeleton: PropTypes.bool,
427
- subTitle: PropTypes.string,
428
- loading: PropTypes.bool,
429
- extraNav: PropTypes.object
375
+ _.propTypes = {
376
+ blockletMeta: s.object.isRequired,
377
+ logoUrl: s.string,
378
+ locale: s.string,
379
+ useOfSkeleton: s.bool,
380
+ subTitle: s.string,
381
+ loading: s.bool,
382
+ extraNav: s.object,
383
+ sx: s.any
430
384
  };
431
- Nav.defaultProps = {
432
- logoUrl: '',
433
- locale: '',
434
- useOfSkeleton: false,
435
- subTitle: '',
436
- loading: false,
437
- extraNav: null
385
+ export {
386
+ _ as default
438
387
  };
439
- export default Nav;
@@ -1,28 +1,15 @@
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, jsxs as _jsxs } from "react/jsx-runtime";
5
- function PageHeader({
6
- title,
7
- subTitle,
8
- onClickBack,
9
- ...rest
10
- }) {
11
- return /*#__PURE__*/_jsxs(Content, {
12
- ...rest,
13
- children: [onClickBack && /*#__PURE__*/_jsx(ArrowBackIosIcon, {
14
- className: "back-btn",
15
- onClick: onClickBack
16
- }), /*#__PURE__*/_jsx("div", {
17
- className: "title",
18
- children: title
19
- }), /*#__PURE__*/_jsx("div", {
20
- className: "sub-title",
21
- children: subTitle
22
- })]
23
- });
1
+ import { jsxs as s, jsx as o } from "react/jsx-runtime";
2
+ import p from "@emotion/styled";
3
+ import e from "prop-types";
4
+ import { ArrowBackIos as l } from "@mui/icons-material";
5
+ function a({ title: t = "", subTitle: r = "", onClickBack: i = "", ...n }) {
6
+ return /* @__PURE__ */ s(c, { ...n, children: [
7
+ i && /* @__PURE__ */ o(l, { className: "back-btn", onClick: i }),
8
+ /* @__PURE__ */ o("div", { className: "title", children: t }),
9
+ /* @__PURE__ */ o("div", { className: "sub-title", children: r })
10
+ ] });
24
11
  }
25
- const Content = styled.div`
12
+ const c = p.div`
26
13
  position: relative;
27
14
  width: 100%;
28
15
  text-align: center;
@@ -30,16 +17,16 @@ const Content = styled.div`
30
17
  .title {
31
18
  font-size: 24px;
32
19
  font-weight: 700;
33
- color: ${props => props.theme.palette.text.primary};
20
+ color: ${(t) => t.theme.palette.text.primary};
34
21
 
35
- ${props => props.theme.breakpoints.down('md')} {
22
+ ${(t) => t.theme.breakpoints.down("md")} {
36
23
  font-size: 20px;
37
24
  }
38
25
  }
39
26
 
40
27
  .sub-title {
41
28
  font-size: 14px;
42
- color: ${props => props.theme.palette.text.secondary};
29
+ color: ${(t) => t.theme.palette.text.secondary};
43
30
  padding: 0 14px;
44
31
  font-weight: 400;
45
32
  }
@@ -48,19 +35,16 @@ const Content = styled.div`
48
35
  position: absolute;
49
36
  left: 0;
50
37
  top: 8px;
51
- color: ${props => props.theme.palette.grey[500]};
38
+ color: ${(t) => t.theme.palette.grey[500]};
52
39
  font-size: 18px;
53
40
  cursor: pointer;
54
41
  }
55
42
  `;
56
- export default PageHeader;
57
- PageHeader.propTypes = {
58
- title: PropTypes.string,
59
- subTitle: PropTypes.string,
60
- onClickBack: PropTypes.oneOfType([PropTypes.func, PropTypes.string])
43
+ a.propTypes = {
44
+ title: e.string,
45
+ subTitle: e.string,
46
+ onClickBack: e.oneOfType([e.func, e.string])
47
+ };
48
+ export {
49
+ a as default
61
50
  };
62
- PageHeader.defaultProps = {
63
- title: '',
64
- subTitle: '',
65
- onClickBack: ''
66
- };
@@ -1,50 +1,40 @@
1
- import PropTypes from 'prop-types';
2
- import styled from '@emotion/styled';
3
- import CircularProgress from '@mui/material/CircularProgress';
4
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
- export default function SmallCircleProgress({
6
- value,
7
- size,
8
- style,
9
- ...rest
10
- }) {
11
- return /*#__PURE__*/_jsxs(Content, {
12
- style: {
13
- width: size,
14
- height: size,
15
- ...style
16
- },
17
- ...rest,
18
- children: [/*#__PURE__*/_jsx(CircularProgress, {
19
- variant: "determinate",
20
- role: "progressbar",
21
- value: 100,
22
- size: size,
23
- "aria-label": "decorative progress bar",
24
- thickness: 10,
25
- sx: {
26
- color: 'grey.300'
1
+ import { jsxs as l, jsx as t } from "react/jsx-runtime";
2
+ import e from "prop-types";
3
+ import n from "@emotion/styled";
4
+ import { CircularProgress as o } from "@mui/material";
5
+ function p({ value: s, size: r = 10, style: i = {}, ...a }) {
6
+ return /* @__PURE__ */ l(m, { style: { width: r, height: r, ...i }, ...a, children: [
7
+ /* @__PURE__ */ t(
8
+ o,
9
+ {
10
+ variant: "determinate",
11
+ role: "progressbar",
12
+ value: 100,
13
+ size: r,
14
+ "aria-label": "decorative progress bar",
15
+ thickness: 10,
16
+ sx: { color: "grey.300" }
27
17
  }
28
- }), /*#__PURE__*/_jsx(CircularProgress, {
29
- variant: "determinate",
30
- value: value,
31
- role: "progressbar",
32
- size: size,
33
- thickness: 10,
34
- "aria-label": "main progress bar"
35
- })]
36
- });
18
+ ),
19
+ /* @__PURE__ */ t(
20
+ o,
21
+ {
22
+ variant: "determinate",
23
+ value: s,
24
+ role: "progressbar",
25
+ size: r,
26
+ thickness: 10,
27
+ "aria-label": "main progress bar"
28
+ }
29
+ )
30
+ ] });
37
31
  }
38
- SmallCircleProgress.propTypes = {
39
- value: PropTypes.number.isRequired,
40
- size: PropTypes.number,
41
- style: PropTypes.object
42
- };
43
- SmallCircleProgress.defaultProps = {
44
- size: 10,
45
- style: {}
32
+ p.propTypes = {
33
+ value: e.number.isRequired,
34
+ size: e.number,
35
+ style: e.object
46
36
  };
47
- const Content = styled.span`
37
+ const m = n.span`
48
38
  display: inline-block;
49
39
  position: relative;
50
40
  > * {
@@ -54,4 +44,7 @@ const Content = styled.span`
54
44
  width: 100%;
55
45
  height: 100%;
56
46
  }
57
- `;
47
+ `;
48
+ export {
49
+ p as default
50
+ };