@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/index.js CHANGED
@@ -1,244 +1,182 @@
1
- import Center from '@arcblock/ux/lib/Center';
2
- import { deepmerge } from '@arcblock/ux/lib/Theme';
3
- import { ThemeProvider as EmotionThemeProvider } from '@emotion/react';
4
- import { CircularProgress, Hidden, styled, StyledEngineProvider, ThemeProvider, Typography, useMediaQuery, useTheme } from '@mui/material';
5
- import isObject from 'lodash/isObject';
6
- import PropTypes from 'prop-types';
7
- import { Suspense, isValidElement } from 'react';
8
- import { HeaderAddons } from '@arcblock/ux/lib/Header';
9
- import { useStepContext } from './context/step';
10
- import AppHeader from './header';
11
- import { getTranslations } from './locale';
12
- import Nav from './nav';
13
- import SmallCircleProgress from './small-circle-progress';
14
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
15
- const HEADER_HEIGHT_MD = '72px';
16
- const MobileContent = styled('div')`
1
+ import { jsx as i, jsxs as r, Fragment as O } from "react/jsx-runtime";
2
+ import z from "@arcblock/ux/lib/Center";
3
+ import { deepmerge as A } from "@arcblock/ux/lib/Theme";
4
+ import { ThemeProvider as W } from "@emotion/react";
5
+ import { styled as l, useTheme as R, useMediaQuery as _, StyledEngineProvider as D, ThemeProvider as F, Typography as k, CircularProgress as q } from "@mui/material";
6
+ import G from "lodash/isObject";
7
+ import t from "prop-types";
8
+ import { isValidElement as I, Suspense as Q } from "react";
9
+ import { HeaderAddons as V } from "@arcblock/ux/lib/Header";
10
+ import { useStepContext as B } from "./context/step.js";
11
+ import J from "./header.js";
12
+ import { getTranslations as K } from "./locale.js";
13
+ import U from "./nav.js";
14
+ import X from "./small-circle-progress.js";
15
+ const p = "72px", Y = l("div")`
17
16
  box-sizing: border-box;
18
17
  display: flex;
19
18
  overflow: hidden;
20
19
  width: 100%;
21
20
  height: 100%;
22
- padding-top: ${HEADER_HEIGHT_MD};
23
- `;
24
- const PcContent = styled('div')`
21
+ padding-top: ${p};
22
+ `, Z = l("div")`
25
23
  display: flex;
26
24
  min-width: 900px;
27
- max-width: ${props => props.contentMaxWidth};
25
+ max-width: ${(e) => e.contentMaxWidth};
28
26
  max-height: 880px;
29
27
  border-radius: 8px;
30
- background-color: ${({
31
- theme
32
- }) => theme.palette.background.paper};
33
- width: ${props => props.width || '80%'};
34
- height: ${props => props.height || '80%'};
28
+ background-color: ${({ theme: e }) => e.palette.background.paper};
29
+ width: ${(e) => e.width || "80%"};
30
+ height: ${(e) => e.height || "80%"};
35
31
 
36
32
  @media (max-height: 1200px) {
37
- margin-top: ${HEADER_HEIGHT_MD};
33
+ margin-top: ${p};
38
34
  height: 100%;
39
35
  max-height: 100%;
40
36
  }
41
37
  `;
42
- function Layout({
43
- blockletMeta: tmpBlockletMeta,
44
- loading,
45
- children,
46
- logoUrl,
47
- locale,
48
- header,
49
- headerEndAddons,
50
- pcWidth,
51
- pcHeight,
52
- navLogo,
53
- useOfSkeleton,
54
- stepTip,
55
- navSubTitle,
56
- contentMaxWidth,
57
- theme: userTheme,
58
- themeOverrides,
59
- extraNav,
60
- ...rest
38
+ function L({
39
+ blockletMeta: e = {},
40
+ loading: c = !1,
41
+ children: T,
42
+ logoUrl: m = "",
43
+ locale: d = "en",
44
+ header: s = null,
45
+ headerEndAddons: h = null,
46
+ pcWidth: j = "80%",
47
+ navLogo: n = "",
48
+ useOfSkeleton: v = !0,
49
+ navSubTitle: u = "",
50
+ contentMaxWidth: g = "1245px",
51
+ theme: C = null,
52
+ themeOverrides: S = null,
53
+ extraNav: o = null,
54
+ ...M
61
55
  }) {
62
- const parentTheme = useTheme();
63
- const isMobile = useMediaQuery(t => t.breakpoints.down('md'));
64
- const {
65
- activeStep,
66
- totalStepsCount
67
- } = useStepContext();
68
- const blockletMeta = tmpBlockletMeta || {};
69
- const Container = isMobile ? MobileContent : PcContent;
70
- const translations = getTranslations(locale);
71
- if (navLogo && ! /*#__PURE__*/isValidElement(navLogo) && isObject(navLogo)) {
72
- if (isMobile) {
73
- // eslint-disable-next-line no-param-reassign
74
- navLogo = navLogo.mobile;
75
- } else {
76
- // eslint-disable-next-line no-param-reassign
77
- navLogo = /*#__PURE__*/_jsx(LogoContainer, {
78
- children: navLogo.desktop
79
- });
80
- }
81
- }
82
- const mergedTheme = deepmerge(parentTheme, userTheme || {}, themeOverrides || {});
83
- return /*#__PURE__*/_jsx(StyledEngineProvider, {
84
- injectFirst: true,
85
- children: /*#__PURE__*/_jsx(ThemeProvider, {
86
- theme: mergedTheme,
87
- children: /*#__PURE__*/_jsx(EmotionThemeProvider, {
88
- theme: mergedTheme,
89
- children: /*#__PURE__*/_jsxs(Root, {
90
- ...rest,
91
- children: [/*#__PURE__*/_jsxs(Header, {
92
- maxWidth: contentMaxWidth,
93
- width: pcWidth,
94
- className: "ll-header",
95
- children: [header && header, !header && /*#__PURE__*/_jsxs(_Fragment, {
96
- children: [isMobile && /*#__PURE__*/_jsx("div", {
97
- className: "left",
98
- children: /*#__PURE__*/_jsx(AppHeader, {
99
- blockletMeta: blockletMeta,
100
- navLogo: navLogo,
101
- subTitle: /*#__PURE__*/_jsxs("span", {
102
- children: [`${navSubTitle || translations.defaultNavSubTitle} ${activeStep + 1}/${totalStepsCount}`, /*#__PURE__*/_jsx(SmallCircleProgress, {
103
- value: (activeStep + 1) / totalStepsCount * 100,
104
- style: {
105
- marginLeft: 3
106
- }
107
- }), extraNav && /*#__PURE__*/_jsx(Typography, {
108
- variant: "caption",
109
- className: "extra-nav-text",
110
- onClick: () => {
111
- if (extraNav.link) {
112
- window.open(extraNav.link, '_blank');
113
- }
114
- },
115
- sx: {
116
- ml: 1,
117
- color: 'primary.main',
118
- cursor: 'pointer',
119
- '&:hover': {
120
- opacity: 0.8
121
- }
122
- },
123
- children: extraNav.appText || extraNav.text
124
- })]
125
- }),
126
- logoUrl: logoUrl,
127
- locale: locale,
128
- loading: loading
129
- })
130
- }), navLogo && !isMobile && /*#__PURE__*/_jsx("div", {
131
- className: "left",
132
- children: navLogo
133
- }), headerEndAddons && /*#__PURE__*/_jsx(HeaderAddons, {
134
- className: "right",
135
- children: headerEndAddons
136
- })]
137
- })]
138
- }), /*#__PURE__*/_jsxs(Container, {
139
- contentMaxWidth: contentMaxWidth,
140
- className: "ll-container",
141
- children: [/*#__PURE__*/_jsx(Hidden, {
142
- mdDown: true,
143
- children: /*#__PURE__*/_jsx(Nav, {
144
- locale: locale,
145
- blockletMeta: blockletMeta,
146
- logoUrl: logoUrl,
147
- useOfSkeleton: useOfSkeleton,
148
- subTitle: navSubTitle,
149
- loading: loading,
150
- extraNav: extraNav
151
- })
152
- }), /*#__PURE__*/_jsx(Typography, {
153
- component: "div",
154
- className: "layout-content",
155
- children: /*#__PURE__*/_jsx(Suspense, {
156
- fallback: /*#__PURE__*/_jsx(Center, {
157
- relative: "parent",
158
- children: /*#__PURE__*/_jsx(CircularProgress, {
159
- style: {
160
- marginTop: 36
56
+ const P = R(), a = _((N) => N.breakpoints.down("md")), { activeStep: x, totalStepsCount: f } = B(), b = e || {}, H = a ? Y : Z, E = K(d);
57
+ n && !I(n) && G(n) && (a ? n = n.mobile : n = /* @__PURE__ */ i(ie, { children: n.desktop }));
58
+ const y = A(P, C || {}, S || {});
59
+ return /* @__PURE__ */ i(D, { injectFirst: !0, children: /* @__PURE__ */ i(F, { theme: y, children: /* @__PURE__ */ i(W, { theme: y, children: /* @__PURE__ */ r(te, { ...M, children: [
60
+ /* @__PURE__ */ r(ee, { maxWidth: g, width: j, className: "ll-header", children: [
61
+ s && s,
62
+ !s && /* @__PURE__ */ r(O, { children: [
63
+ a && /* @__PURE__ */ i("div", { className: "left", children: /* @__PURE__ */ i(
64
+ J,
65
+ {
66
+ blockletMeta: b,
67
+ navLogo: n,
68
+ subTitle: /* @__PURE__ */ r("span", { children: [
69
+ `${u || E.defaultNavSubTitle} ${x + 1}/${f}`,
70
+ /* @__PURE__ */ i(
71
+ X,
72
+ {
73
+ value: (x + 1) / f * 100,
74
+ style: { marginLeft: 3 }
75
+ }
76
+ ),
77
+ o && /* @__PURE__ */ i(
78
+ k,
79
+ {
80
+ variant: "caption",
81
+ className: "extra-nav-text",
82
+ onClick: () => {
83
+ o.link && window.open(o.link, "_blank");
84
+ },
85
+ sx: {
86
+ ml: 1,
87
+ color: "primary.main",
88
+ cursor: "pointer",
89
+ "&:hover": {
90
+ opacity: 0.8
161
91
  }
162
- })
163
- }),
164
- children: children
165
- })
166
- })]
167
- })]
168
- })
169
- })
170
- })
171
- });
92
+ },
93
+ children: o.appText || o.text
94
+ }
95
+ )
96
+ ] }),
97
+ logoUrl: m,
98
+ locale: d,
99
+ loading: c
100
+ }
101
+ ) }),
102
+ n && !a && /* @__PURE__ */ i("div", { className: "left", children: n }),
103
+ h && /* @__PURE__ */ i(V, { className: "right", children: h })
104
+ ] })
105
+ ] }),
106
+ /* @__PURE__ */ r(H, { contentMaxWidth: g, className: "ll-container", children: [
107
+ /* @__PURE__ */ i(
108
+ U,
109
+ {
110
+ sx: {
111
+ display: {
112
+ xs: "none",
113
+ md: "block"
114
+ }
115
+ },
116
+ locale: d,
117
+ blockletMeta: b,
118
+ logoUrl: m,
119
+ useOfSkeleton: v,
120
+ subTitle: u,
121
+ loading: c,
122
+ extraNav: o
123
+ }
124
+ ),
125
+ /* @__PURE__ */ i(k, { component: "div", className: "layout-content", children: /* @__PURE__ */ i(
126
+ Q,
127
+ {
128
+ fallback: /* @__PURE__ */ i(z, { relative: "parent", children: /* @__PURE__ */ i(q, { style: { marginTop: 36 } }) }),
129
+ children: T
130
+ }
131
+ ) })
132
+ ] })
133
+ ] }) }) }) });
172
134
  }
173
- Layout.propTypes = {
174
- loading: PropTypes.bool,
175
- blockletMeta: PropTypes.object,
176
- children: PropTypes.object.isRequired,
177
- logoUrl: PropTypes.string,
178
- locale: PropTypes.oneOf(['en', 'zh']),
179
- header: PropTypes.any,
180
- headerEndAddons: PropTypes.any,
181
- pcWidth: PropTypes.any,
182
- pcHeight: PropTypes.any,
183
- contentMaxWidth: PropTypes.string,
184
- navLogo: PropTypes.oneOfType([PropTypes.node, PropTypes.object]),
185
- useOfSkeleton: PropTypes.bool,
186
- stepTip: PropTypes.string,
187
- navSubTitle: PropTypes.string,
135
+ L.propTypes = {
136
+ loading: t.bool,
137
+ blockletMeta: t.object,
138
+ children: t.object.isRequired,
139
+ logoUrl: t.string,
140
+ locale: t.oneOf(["en", "zh"]),
141
+ header: t.any,
142
+ headerEndAddons: t.any,
143
+ pcWidth: t.any,
144
+ pcHeight: t.any,
145
+ contentMaxWidth: t.string,
146
+ navLogo: t.oneOfType([t.node, t.object]),
147
+ useOfSkeleton: t.bool,
148
+ stepTip: t.string,
149
+ navSubTitle: t.string,
188
150
  /** @deprecated Please use themeOverrides instead */
189
- theme: PropTypes.object,
190
- themeOverrides: PropTypes.object,
191
- extraNav: PropTypes.object
151
+ theme: t.object,
152
+ themeOverrides: t.object,
153
+ extraNav: t.object
192
154
  };
193
- Layout.defaultProps = {
194
- loading: false,
195
- blockletMeta: {},
196
- logoUrl: '',
197
- locale: 'en',
198
- header: null,
199
- headerEndAddons: null,
200
- pcWidth: '80%',
201
- pcHeight: '80%',
202
- contentMaxWidth: '1245px',
203
- navLogo: '',
204
- useOfSkeleton: true,
205
- stepTip: '',
206
- navSubTitle: '',
207
- theme: null,
208
- themeOverrides: null,
209
- extraNav: null
210
- };
211
-
212
- // 针对 safari 下的 chrome 适配
213
- const ua = navigator.userAgent.toLocaleLowerCase();
214
- let injectStyle = '';
215
- if (ua.includes('iphone os') && ua.includes('crios')) {
216
- injectStyle = 'height: calc(100vh - 60px);';
217
- }
218
- const Header = styled('header')`
219
- width: ${props => props.width || '80%'};
155
+ const w = navigator.userAgent.toLocaleLowerCase();
156
+ let $ = "";
157
+ w.includes("iphone os") && w.includes("crios") && ($ = "height: calc(100vh - 60px);");
158
+ const ee = l("header")`
159
+ width: ${(e) => e.width || "80%"};
220
160
  min-width: 900px;
221
161
  box-sizing: border-box;
222
162
  position: absolute;
223
163
  z-index: 200;
224
164
  top: 0;
225
165
  display: flex;
226
- max-width: ${props => props.maxWidth};
166
+ max-width: ${(e) => e.maxWidth};
227
167
  height: 68px;
228
168
  align-items: center;
229
169
 
230
- ${props => `${props.theme.breakpoints.up('sm')} and (min-height: 900px)`} {
170
+ ${(e) => `${e.theme.breakpoints.up("sm")} and (min-height: 900px)`} {
231
171
  justify-content: flex-end;
232
172
  }
233
173
 
234
- ${props => props.theme.breakpoints.down('md')} {
174
+ ${(e) => e.theme.breakpoints.down("md")} {
235
175
  min-width: 360px;
236
176
  width: 100%;
237
- height: ${HEADER_HEIGHT_MD};
177
+ height: ${p};
238
178
  justify-content: space-between;
239
- background-color: ${({
240
- theme
241
- }) => theme.palette.mode === 'dark' ? theme.palette.background.default : theme.palette.grey[100]};
179
+ background-color: ${({ theme: e }) => e.palette.mode === "dark" ? e.palette.background.default : e.palette.grey[100]};
242
180
  }
243
181
 
244
182
  .left {
@@ -246,17 +184,14 @@ const Header = styled('header')`
246
184
  display: flex;
247
185
  align-items: center;
248
186
  }
249
- `;
250
- const Root = styled('div')`
187
+ `, te = l("div")`
251
188
  display: flex;
252
189
  flex-direction: column;
253
190
  justify-content: center;
254
191
  align-items: center;
255
192
  letter-spacing: normal;
256
- background: ${({
257
- theme
258
- }) => theme.palette.mode === 'dark' ? theme.palette.background.default : theme.palette.grey[100]};
259
- ${injectStyle}
193
+ background: ${({ theme: e }) => e.palette.mode === "dark" ? e.palette.background.default : e.palette.grey[100]};
194
+ ${$}
260
195
 
261
196
  header:empty {
262
197
  display: none;
@@ -287,17 +222,16 @@ const Root = styled('div')`
287
222
  flex-grow: 1;
288
223
  height: 100%;
289
224
  padding: 32px;
290
- background-color: ${({
291
- theme
292
- }) => theme.palette.background.paper};
225
+ background-color: ${({ theme: e }) => e.palette.background.paper};
293
226
 
294
- ${props => props.theme.breakpoints.down('md')} {
227
+ ${(e) => e.theme.breakpoints.down("md")} {
295
228
  padding: 16px;
296
229
  }
297
230
  }
298
- `;
299
- const LogoContainer = styled('div')`
231
+ `, ie = l("div")`
300
232
  display: block;
301
233
  margin-top: 4px;
302
234
  `;
303
- export default Layout;
235
+ export {
236
+ L as default
237
+ };
package/lib/info-list.js CHANGED
@@ -1,45 +1,58 @@
1
- import PropTypes from 'prop-types';
2
- import { Box } from '@mui/material';
3
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
4
- export default function InfoTable({
5
- infoList = []
6
- }) {
7
- return /*#__PURE__*/_jsx(Box, {
8
- className: "info-table",
9
- sx: {
10
- display: 'grid',
11
- gridTemplateColumns: {
12
- xs: '1fr',
13
- md: 'max-content 1fr'
14
- },
15
- columnGap: 4,
16
- rowGap: 1.5
17
- },
18
- children: infoList.map(item => /*#__PURE__*/_jsxs(_Fragment, {
19
- children: [/*#__PURE__*/_jsx(Box, {
20
- component: "span",
21
- sx: {
22
- fontWeight: 'bold',
23
- whiteSpace: 'nowrap'
1
+ import { jsx as n, jsxs as p, Fragment as s } from "react/jsx-runtime";
2
+ import r from "prop-types";
3
+ import { Box as o } from "@mui/material";
4
+ function t({ infoList: a = [] }) {
5
+ return /* @__PURE__ */ n(
6
+ o,
7
+ {
8
+ className: "info-table",
9
+ sx: {
10
+ display: "grid",
11
+ gridTemplateColumns: {
12
+ xs: "1fr",
13
+ md: "max-content 1fr"
24
14
  },
25
- children: item.key
26
- }), /*#__PURE__*/_jsx(Box, {
27
- component: "span",
28
- sx: {
29
- marginTop: {
30
- xs: -1,
31
- md: 0
15
+ columnGap: 4,
16
+ rowGap: 1.5
17
+ },
18
+ children: a.map((e) => /* @__PURE__ */ p(s, { children: [
19
+ /* @__PURE__ */ n(
20
+ o,
21
+ {
22
+ component: "span",
23
+ sx: {
24
+ fontWeight: "bold",
25
+ whiteSpace: "nowrap"
26
+ },
27
+ children: e.key
32
28
  }
33
- },
34
- children: item.value
35
- })]
36
- }))
37
- });
29
+ ),
30
+ /* @__PURE__ */ n(
31
+ o,
32
+ {
33
+ component: "span",
34
+ sx: {
35
+ marginTop: {
36
+ xs: -1,
37
+ md: 0
38
+ }
39
+ },
40
+ children: e.value
41
+ }
42
+ )
43
+ ] }))
44
+ }
45
+ );
38
46
  }
39
- InfoTable.propTypes = {
47
+ t.propTypes = {
40
48
  // eslint-disable-next-line react/require-default-props
41
- infoList: PropTypes.arrayOf(PropTypes.shape({
42
- key: PropTypes.string,
43
- value: PropTypes.string
44
- }))
45
- };
49
+ infoList: r.arrayOf(
50
+ r.shape({
51
+ key: r.string,
52
+ value: r.string
53
+ })
54
+ )
55
+ };
56
+ export {
57
+ t as default
58
+ };