@blocklet/launcher-layout 1.7.31 → 1.7.34
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/compact-layout.js +1 -1
- package/lib/context/step.js +104 -17
- package/lib/header.js +9 -3
- package/lib/index.js +44 -23
- package/lib/nav.js +99 -40
- package/lib/page-header.js +14 -6
- package/lib/wizard/wizard-desc.js +11 -11
- package/package.json +8 -7
package/lib/compact-layout.js
CHANGED
package/lib/context/step.js
CHANGED
|
@@ -21,47 +21,134 @@ const {
|
|
|
21
21
|
Provider
|
|
22
22
|
} = StepContext;
|
|
23
23
|
|
|
24
|
+
const matchPath = function matchPath(path, exact) {
|
|
25
|
+
let currentPathname = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window.location.pathname.replace(/\/$/, '');
|
|
26
|
+
|
|
27
|
+
if (!path) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (exact) {
|
|
32
|
+
return path === currentPathname;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return new RegExp(path).test(currentPathname);
|
|
36
|
+
};
|
|
37
|
+
|
|
24
38
|
function StepProvider(_ref) {
|
|
25
39
|
let {
|
|
26
40
|
children,
|
|
27
41
|
steps,
|
|
28
42
|
mode
|
|
29
43
|
} = _ref;
|
|
30
|
-
const [
|
|
44
|
+
const [activeStepKey, setActiveStepKey] = (0, _react.useState)('');
|
|
45
|
+
|
|
46
|
+
if (!activeStepKey && steps.length) {
|
|
47
|
+
setActiveStepKey(steps[0].key);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const flatSteps = steps.map(item => {
|
|
51
|
+
if (item.children) {
|
|
52
|
+
return [{
|
|
53
|
+
key: item.key,
|
|
54
|
+
hasChild: true
|
|
55
|
+
}, item.children.map(childItem => {
|
|
56
|
+
return {
|
|
57
|
+
parentKey: item.key,
|
|
58
|
+
key: childItem.key
|
|
59
|
+
};
|
|
60
|
+
})];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
key: item.key
|
|
65
|
+
};
|
|
66
|
+
}).flat(Infinity);
|
|
67
|
+
const totalSteps = flatSteps.filter(e => !e.hasChild); // 根据 key 获取当前 step 处于的状态;before已超过该步骤;current处于当前步骤;after还未到这个步骤;
|
|
68
|
+
|
|
69
|
+
const getStepStatus = key => {
|
|
70
|
+
let activeParentStepKey;
|
|
71
|
+
const activeIndex = flatSteps.findIndex(e => {
|
|
72
|
+
if (e.key === activeStepKey) {
|
|
73
|
+
activeParentStepKey = e.parentKey;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return false;
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (activeParentStepKey === key) {
|
|
81
|
+
return 'current';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const targetIndex = flatSteps.findIndex(e => e.key === key);
|
|
85
|
+
|
|
86
|
+
if (targetIndex !== -1) {
|
|
87
|
+
if (targetIndex === activeIndex) {
|
|
88
|
+
return 'current';
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (targetIndex < activeIndex) {
|
|
92
|
+
return 'before';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return 'after';
|
|
97
|
+
}; // can use this to set the activeStep by key
|
|
98
|
+
|
|
31
99
|
|
|
32
100
|
function setActiveStepByKey(key) {
|
|
33
|
-
|
|
101
|
+
setActiveStepKey(key);
|
|
102
|
+
} // TODO: setIndex模式很难定位到child step,尽量使用key方式去定位
|
|
103
|
+
|
|
34
104
|
|
|
35
|
-
|
|
36
|
-
|
|
105
|
+
function setActiveStepByIndex(index) {
|
|
106
|
+
if (typeof index === 'function') {
|
|
107
|
+
const newIndex = index(totalSteps.findIndex(e => e.key === activeStepKey));
|
|
108
|
+
setActiveStepKey(totalSteps[newIndex].key);
|
|
109
|
+
} else {
|
|
110
|
+
setActiveStepKey(totalSteps[index].key);
|
|
37
111
|
}
|
|
38
112
|
}
|
|
39
113
|
|
|
114
|
+
const activeStep = totalSteps.findIndex(e => e.key === activeStepKey);
|
|
40
115
|
(0, _react.useEffect)(() => {
|
|
41
116
|
if (mode === 'history') {
|
|
42
|
-
let
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
117
|
+
let stepKey = '';
|
|
118
|
+
steps.some(step => {
|
|
119
|
+
if (step.children && step.children.length) {
|
|
120
|
+
return step.children.some(childStep => {
|
|
121
|
+
if (matchPath(childStep.path, childStep.exact)) {
|
|
122
|
+
stepKey = childStep.key;
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return false;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
48
129
|
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
130
|
+
if (matchPath(step.path, step.exact)) {
|
|
131
|
+
stepKey = step.key;
|
|
132
|
+
return true;
|
|
52
133
|
}
|
|
134
|
+
|
|
135
|
+
return false;
|
|
53
136
|
});
|
|
54
|
-
|
|
137
|
+
|
|
138
|
+
if (stepKey) {
|
|
139
|
+
setActiveStepKey(stepKey);
|
|
140
|
+
}
|
|
55
141
|
}
|
|
56
142
|
|
|
57
143
|
return () => {};
|
|
58
144
|
}, [steps, window.location.pathname]);
|
|
59
145
|
const value = {
|
|
60
146
|
steps,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
setActiveStepByIndex,
|
|
147
|
+
totalStepsCount: totalSteps.length,
|
|
148
|
+
getStepStatus,
|
|
64
149
|
setActiveStepByKey,
|
|
150
|
+
setActiveStepByIndex,
|
|
151
|
+
activeStep,
|
|
65
152
|
// judge node can be clicked to back if the mode is 'memory'
|
|
66
153
|
canBackToStep: nodeIndex => {
|
|
67
154
|
return mode === 'memory' && activeStep !== 0 && nodeIndex < activeStep;
|
package/lib/header.js
CHANGED
|
@@ -40,8 +40,14 @@ function AppHeader(_ref) {
|
|
|
40
40
|
const blockletSize = isMobile ? 18 : 48;
|
|
41
41
|
const appNameRef = (0, _react.useRef)(null);
|
|
42
42
|
const [appNameSize, setAppNameSize] = (0, _react.useState)('');
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
let blockletIcon = isMobile ? /*#__PURE__*/_react.default.createElement(_Skeleton.default, {
|
|
44
|
+
variant: "rectangular",
|
|
45
|
+
width: 100,
|
|
46
|
+
height: 16,
|
|
47
|
+
style: {
|
|
48
|
+
marginTop: 4
|
|
49
|
+
}
|
|
50
|
+
}) : /*#__PURE__*/_react.default.createElement(_Skeleton.default, {
|
|
45
51
|
variant: "rectangular",
|
|
46
52
|
width: blockletSize,
|
|
47
53
|
height: blockletSize
|
|
@@ -112,4 +118,4 @@ AppHeader.defaultProps = {
|
|
|
112
118
|
const Container = _styledComponents.default.div.withConfig({
|
|
113
119
|
displayName: "header__Container",
|
|
114
120
|
componentId: "sc-1twhts3-0"
|
|
115
|
-
})(["display:flex;justify-content:flex-start;align-items:flex-start;width:100%;", "{min-height:70px;}", "{align-items:center;}.app-name-content{width:100%;display:flex;align-items:center;justify-content:center;", "{align-items:flex-start;flex-direction:column;}", "{height:22px;}}.launching-context{flex-shrink:0;font-size:14px;font-weight:600;color:", ";", "{margin-bottom:4px;}", "{font-size:14px;line-height:15px;&:after{display:inline-block;margin:0 4px;content:':';}}}&.center-mode{align-items:flex-start;.launching-context{", "{margin-bottom:0;}}}.app-icon{flex-shrink:0;> *{display:block;vertical-align:middle;}}.header-title{flex:1;display:flex;flex-direction:column;justify-content:space-around;align-items:flex-start;margin-left:24px;", "{margin-left:16px;}.header-title-name{position:relative;display:flex;justify-content:center;align-items:center;flex:1;height:100%;color:", ";font-weight:700;", "{font-size:18px
|
|
121
|
+
})(["display:flex;justify-content:flex-start;align-items:flex-start;width:100%;", "{min-height:70px;}", "{align-items:center;}.app-name-content{width:100%;display:flex;align-items:center;justify-content:center;", "{align-items:flex-start;flex-direction:column;}", "{height:22px;}}.launching-context{flex-shrink:0;font-size:14px;font-weight:600;color:", ";", "{margin-bottom:4px;}", "{font-size:14px;line-height:15px;&:after{display:inline-block;margin:0 4px;content:':';}}}&.center-mode{align-items:flex-start;.launching-context{", "{margin-bottom:0;}}}.app-icon{flex-shrink:0;> *{display:block;vertical-align:middle;}}.header-title{flex:1;display:flex;flex-direction:column;justify-content:space-around;align-items:flex-start;margin-left:24px;", "{margin-left:16px;}.header-title-name{position:relative;display:flex;justify-content:center;align-items:center;flex:1;height:100%;color:", ";font-weight:700;", "{font-size:18px;&.middle-size{font-size:16px;}}", "{display:block;max-width:calc(100vw - 100px);font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}}.header-title-sub{color:", ";font-size:12px;line-height:16px;", "{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}}}"], props => props.theme.breakpoints.up('md'), props => props.theme.breakpoints.down('md'), props => props.theme.breakpoints.up('md'), props => props.theme.breakpoints.down('md'), props => props.theme.palette.grey[500], props => props.theme.breakpoints.up('md'), props => props.theme.breakpoints.down('md'), props => props.theme.breakpoints.up('sm'), props => props.theme.breakpoints.down('md'), props => props.theme.palette.common.black, props => props.theme.breakpoints.up('sm'), props => props.theme.breakpoints.down('md'), props => props.theme.palette.grey[700], props => props.theme.breakpoints.down('md'));
|
package/lib/index.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
@@ -17,7 +17,11 @@ var _useMediaQuery = _interopRequireDefault(require("@mui/material/useMediaQuery
|
|
|
17
17
|
|
|
18
18
|
var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _Center = _interopRequireDefault(require("@arcblock/ux/lib/Center"));
|
|
21
|
+
|
|
22
|
+
var _Spinner = _interopRequireDefault(require("@arcblock/ux/lib/Spinner"));
|
|
23
|
+
|
|
24
|
+
var _isObject = _interopRequireDefault(require("lodash/isObject"));
|
|
21
25
|
|
|
22
26
|
var _step = require("./context/step");
|
|
23
27
|
|
|
@@ -29,6 +33,10 @@ var _nav = _interopRequireDefault(require("./nav"));
|
|
|
29
33
|
|
|
30
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
35
|
|
|
36
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
37
|
+
|
|
38
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
|
+
|
|
32
40
|
const MobileContent = _styledComponents.default.div.withConfig({
|
|
33
41
|
displayName: "src__MobileContent",
|
|
34
42
|
componentId: "sc-11nbl7p-0"
|
|
@@ -37,7 +45,7 @@ const MobileContent = _styledComponents.default.div.withConfig({
|
|
|
37
45
|
const PcContent = _styledComponents.default.div.withConfig({
|
|
38
46
|
displayName: "src__PcContent",
|
|
39
47
|
componentId: "sc-11nbl7p-1"
|
|
40
|
-
})(["display:flex;max-width:1245px;min-width:
|
|
48
|
+
})(["display:flex;max-width:1245px;min-width:900px;max-height:880px;border-radius:8px;background-color:#fff;"]);
|
|
41
49
|
|
|
42
50
|
function Layout(_ref) {
|
|
43
51
|
let {
|
|
@@ -48,7 +56,8 @@ function Layout(_ref) {
|
|
|
48
56
|
headerEndAddons,
|
|
49
57
|
pcWidth,
|
|
50
58
|
pcHeight,
|
|
51
|
-
navLogo
|
|
59
|
+
navLogo,
|
|
60
|
+
useOfSkeleton
|
|
52
61
|
} = _ref;
|
|
53
62
|
const isMobile = (0, _useMediaQuery.default)(theme => theme.breakpoints.down('md'));
|
|
54
63
|
const {
|
|
@@ -57,19 +66,25 @@ function Layout(_ref) {
|
|
|
57
66
|
} = (0, _step.useStepContext)();
|
|
58
67
|
const Container = isMobile ? MobileContent : PcContent;
|
|
59
68
|
const translations = (0, _locale.getTranslations)(locale);
|
|
69
|
+
|
|
70
|
+
if (navLogo && ! /*#__PURE__*/(0, _react.isValidElement)(navLogo) && (0, _isObject.default)(navLogo)) {
|
|
71
|
+
if (isMobile) {
|
|
72
|
+
// eslint-disable-next-line no-param-reassign
|
|
73
|
+
navLogo = navLogo.mobile;
|
|
74
|
+
} else {
|
|
75
|
+
// eslint-disable-next-line no-param-reassign
|
|
76
|
+
navLogo = /*#__PURE__*/_react.default.createElement(LogoContainer, null, navLogo.desktop);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
60
80
|
return /*#__PURE__*/_react.default.createElement(Root, null, /*#__PURE__*/_react.default.createElement("header", {
|
|
61
81
|
className: "root-header"
|
|
62
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
63
|
-
mdUp: true
|
|
64
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
82
|
+
}, isMobile && /*#__PURE__*/_react.default.createElement("div", {
|
|
65
83
|
className: "left"
|
|
66
84
|
}, /*#__PURE__*/_react.default.createElement(_header.default, {
|
|
67
|
-
title:
|
|
85
|
+
title: /*#__PURE__*/_react.default.createElement("span", {
|
|
68
86
|
className: "ellipsis-title"
|
|
69
|
-
}, blockletMeta.title)
|
|
70
|
-
variant: "text",
|
|
71
|
-
width: 100
|
|
72
|
-
}),
|
|
87
|
+
}, blockletMeta.title),
|
|
73
88
|
navLogo: navLogo,
|
|
74
89
|
subTitle: /*#__PURE__*/_react.default.createElement("span", null, "".concat(translations.stepTip, " ").concat(activeStep + 1, "/").concat(totalStepsCount), /*#__PURE__*/_react.default.createElement("span", {
|
|
75
90
|
className: "circular"
|
|
@@ -90,7 +105,7 @@ function Layout(_ref) {
|
|
|
90
105
|
logoUrl: logoUrl,
|
|
91
106
|
did: blockletMeta.did,
|
|
92
107
|
locale: locale
|
|
93
|
-
}))
|
|
108
|
+
})), navLogo && !isMobile && /*#__PURE__*/_react.default.createElement("div", {
|
|
94
109
|
className: "left"
|
|
95
110
|
}, navLogo), headerEndAddons && /*#__PURE__*/_react.default.createElement("div", {
|
|
96
111
|
className: "right"
|
|
@@ -104,8 +119,13 @@ function Layout(_ref) {
|
|
|
104
119
|
}, /*#__PURE__*/_react.default.createElement(_nav.default, {
|
|
105
120
|
locale: locale,
|
|
106
121
|
blockletMeta: blockletMeta,
|
|
107
|
-
logoUrl: logoUrl
|
|
108
|
-
|
|
122
|
+
logoUrl: logoUrl,
|
|
123
|
+
useOfSkeleton: useOfSkeleton
|
|
124
|
+
})), /*#__PURE__*/_react.default.createElement(_react.Suspense, {
|
|
125
|
+
fallback: /*#__PURE__*/_react.default.createElement(_Center.default, {
|
|
126
|
+
relative: "parent"
|
|
127
|
+
}, /*#__PURE__*/_react.default.createElement(_Spinner.default, null))
|
|
128
|
+
}, children)));
|
|
109
129
|
}
|
|
110
130
|
|
|
111
131
|
Layout.propTypes = {
|
|
@@ -116,7 +136,8 @@ Layout.propTypes = {
|
|
|
116
136
|
headerEndAddons: _propTypes.default.any,
|
|
117
137
|
pcWidth: _propTypes.default.any,
|
|
118
138
|
pcHeight: _propTypes.default.any,
|
|
119
|
-
navLogo: _propTypes.default.
|
|
139
|
+
navLogo: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.object]),
|
|
140
|
+
useOfSkeleton: _propTypes.default.bool
|
|
120
141
|
};
|
|
121
142
|
Layout.defaultProps = {
|
|
122
143
|
logoUrl: '',
|
|
@@ -124,7 +145,8 @@ Layout.defaultProps = {
|
|
|
124
145
|
headerEndAddons: null,
|
|
125
146
|
pcWidth: '80%',
|
|
126
147
|
pcHeight: '80%',
|
|
127
|
-
navLogo: ''
|
|
148
|
+
navLogo: '',
|
|
149
|
+
useOfSkeleton: true
|
|
128
150
|
}; // 针对 safari 下的 chrome 适配
|
|
129
151
|
|
|
130
152
|
const ua = navigator.userAgent.toLocaleLowerCase();
|
|
@@ -137,13 +159,12 @@ if (ua.includes('iphone os') && ua.includes('crios')) {
|
|
|
137
159
|
const Root = _styledComponents.default.div.withConfig({
|
|
138
160
|
displayName: "src__Root",
|
|
139
161
|
componentId: "sc-11nbl7p-2"
|
|
140
|
-
})(["display:flex;flex-direction:column;justify-content:center;align-items:center;height:100vh;", " .circular{display:inline-block;position:relative;width:15px;height:12px;> *{position:absolute;left:3px;top:2px;width:100%;height:100%;}}.ellipsis-title{flex:1;position:absolute;left:0;top:0;width:100%;height:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;", "{left:26px;width:calc(100% - 26px);}}", "{background:#f6f8fa;}", "{background:", ";}.root-header{box-sizing:border-box;position:
|
|
162
|
+
})(["display:flex;flex-direction:column;justify-content:center;align-items:center;height:100vh;", " .circular{display:inline-block;position:relative;width:15px;height:12px;> *{position:absolute;left:3px;top:2px;width:100%;height:100%;}}.ellipsis-title{flex:1;position:absolute;left:0;top:0;width:100%;height:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;", "{left:26px;width:calc(100% - 26px);}}", "{background:#f6f8fa;}", "{background:", ";}.root-header{box-sizing:border-box;position:absolute;z-index:200;top:0;display:flex;width:100%;max-width:1245px;height:68px;align-items:center;", "{padding:24px;justify-content:flex-end;}", "{height:56px;padding:14px 16px;justify-content:space-between;background:#f6f8fa;}.left{flex:1;display:flex;align-items:center;}.right{display:flex;align-items:center;", "{button,a{padding-left:8px;padding-right:8px;}}}}"], injectStyle, props => props.theme.breakpoints.down('md'), props => props.theme.breakpoints.up('sm'), props => props.theme.breakpoints.down('md'), props => props.theme.palette.common.white, props => props.theme.breakpoints.up('sm'), props => props.theme.breakpoints.down('md'), props => props.theme.breakpoints.down('md'));
|
|
141
163
|
|
|
142
|
-
const
|
|
143
|
-
displayName: "
|
|
164
|
+
const LogoContainer = _styledComponents.default.div.withConfig({
|
|
165
|
+
displayName: "src__LogoContainer",
|
|
144
166
|
componentId: "sc-11nbl7p-3"
|
|
145
|
-
})(["
|
|
167
|
+
})(["display:block;margin-top:4px;"]);
|
|
146
168
|
|
|
147
|
-
exports.Center = Center;
|
|
148
169
|
var _default = Layout;
|
|
149
170
|
exports.default = _default;
|
package/lib/nav.js
CHANGED
|
@@ -27,16 +27,65 @@ function Nav(_ref) {
|
|
|
27
27
|
let {
|
|
28
28
|
blockletMeta,
|
|
29
29
|
logoUrl,
|
|
30
|
-
locale
|
|
30
|
+
locale,
|
|
31
|
+
useOfSkeleton
|
|
31
32
|
} = _ref;
|
|
32
33
|
const {
|
|
33
34
|
steps,
|
|
34
35
|
activeStep,
|
|
35
36
|
setActiveStepByKey,
|
|
36
37
|
setActiveStepByIndex,
|
|
38
|
+
getStepStatus,
|
|
37
39
|
canBackToStep
|
|
38
40
|
} = (0, _step.useStepContext)();
|
|
39
|
-
const showSkeleton = !blockletMeta || !blockletMeta.title;
|
|
41
|
+
const showSkeleton = useOfSkeleton ? !blockletMeta || !blockletMeta.title : false;
|
|
42
|
+
|
|
43
|
+
const getNodeClassName = (step, index) => {
|
|
44
|
+
const classNameList = ['step-block'];
|
|
45
|
+
const status = getStepStatus(step.key);
|
|
46
|
+
|
|
47
|
+
switch (status) {
|
|
48
|
+
case 'current':
|
|
49
|
+
classNameList.push('step-active');
|
|
50
|
+
break;
|
|
51
|
+
|
|
52
|
+
case 'before':
|
|
53
|
+
classNameList.push('step-checked');
|
|
54
|
+
break;
|
|
55
|
+
|
|
56
|
+
case 'after':
|
|
57
|
+
default:
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
switch (step.showChild) {
|
|
61
|
+
case 'activated':
|
|
62
|
+
if (status === 'after') {
|
|
63
|
+
classNameList.push('hide-step-child');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
break;
|
|
67
|
+
|
|
68
|
+
case 'activating':
|
|
69
|
+
if (status === 'after' || status === 'before') {
|
|
70
|
+
classNameList.push('hide-step-child');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
break;
|
|
74
|
+
|
|
75
|
+
case 'always':
|
|
76
|
+
classNameList.push('always-step-child');
|
|
77
|
+
break;
|
|
78
|
+
|
|
79
|
+
default:
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (step.optional === true && activeStep < index) {
|
|
83
|
+
classNameList.push('step-optional'); // optional在没有匹配到路由情况下会隐藏;超越这个步骤后就会一直出现
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return classNameList.join(' ');
|
|
87
|
+
};
|
|
88
|
+
|
|
40
89
|
return /*#__PURE__*/_react.default.createElement(Div, {
|
|
41
90
|
className: "nav-sidebar"
|
|
42
91
|
}, /*#__PURE__*/_react.default.createElement(_header.default, {
|
|
@@ -51,39 +100,12 @@ function Nav(_ref) {
|
|
|
51
100
|
did: blockletMeta.did,
|
|
52
101
|
logoUrl: logoUrl,
|
|
53
102
|
locale: locale
|
|
54
|
-
}), /*#__PURE__*/_react.default.createElement(StepContainer,
|
|
103
|
+
}), /*#__PURE__*/_react.default.createElement(StepContainer, {
|
|
104
|
+
className: "".concat(showSkeleton ? 'hide-child-step-desc' : '')
|
|
105
|
+
}, steps.map((step, index) => {
|
|
55
106
|
const canBack = !showSkeleton && canBackToStep(index);
|
|
56
|
-
|
|
57
|
-
const nodeClassName = (() => {
|
|
58
|
-
const classNameList = ['step-block'];
|
|
59
|
-
|
|
60
|
-
if (activeStep === index) {
|
|
61
|
-
classNameList.push('step-active');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (activeStep > index) {
|
|
65
|
-
classNameList.push('step-checked');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (step.optional === true && activeStep < index) {
|
|
69
|
-
classNameList.push('step-optional');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return classNameList.join(' ');
|
|
73
|
-
})();
|
|
74
|
-
|
|
75
107
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
76
|
-
|
|
77
|
-
if (canBack) {
|
|
78
|
-
if (step.key) {
|
|
79
|
-
setActiveStepByKey(step.key);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
setActiveStepByIndex(index);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
className: nodeClassName,
|
|
108
|
+
className: getNodeClassName(step, index),
|
|
87
109
|
key: step.key
|
|
88
110
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
89
111
|
className: "step-icon"
|
|
@@ -94,14 +116,49 @@ function Nav(_ref) {
|
|
|
94
116
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
95
117
|
className: "step-line"
|
|
96
118
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
97
|
-
className: "step-
|
|
119
|
+
className: "step-content",
|
|
98
120
|
title: step.name
|
|
99
121
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
100
|
-
className: "step-name
|
|
122
|
+
className: "step-content-name ".concat(canBack ? ' step-clickable' : ''),
|
|
123
|
+
onClick: () => {
|
|
124
|
+
if (canBack) {
|
|
125
|
+
if (step.key) {
|
|
126
|
+
setActiveStepByKey(step.key);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
setActiveStepByIndex(index);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
101
133
|
}, showSkeleton ? /*#__PURE__*/_react.default.createElement(_Skeleton.default, {
|
|
102
134
|
variant: "text",
|
|
103
135
|
width: 100
|
|
104
|
-
}) : step.name)
|
|
136
|
+
}) : step.name), step.description && /*#__PURE__*/_react.default.createElement("div", {
|
|
137
|
+
className: "step-desc"
|
|
138
|
+
}, step.description), step.children && step.children.length && /*#__PURE__*/_react.default.createElement("div", {
|
|
139
|
+
className: "step-children"
|
|
140
|
+
}, step.children.map(e => {
|
|
141
|
+
let className = '';
|
|
142
|
+
const childStepStatus = getStepStatus(e.key);
|
|
143
|
+
|
|
144
|
+
switch (childStepStatus) {
|
|
145
|
+
case 'before':
|
|
146
|
+
className = 'step-child-block-checked';
|
|
147
|
+
break;
|
|
148
|
+
|
|
149
|
+
case 'current':
|
|
150
|
+
className = 'step-child-block-active';
|
|
151
|
+
break;
|
|
152
|
+
|
|
153
|
+
case 'after':
|
|
154
|
+
default:
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
158
|
+
className: "step-child-block ".concat(className),
|
|
159
|
+
key: e.key
|
|
160
|
+
}, e.name);
|
|
161
|
+
}))));
|
|
105
162
|
})));
|
|
106
163
|
}
|
|
107
164
|
|
|
@@ -113,21 +170,23 @@ const AppLink = _styledComponents.default.a.withConfig({
|
|
|
113
170
|
const Div = _styledComponents.default.div.withConfig({
|
|
114
171
|
displayName: "nav__Div",
|
|
115
172
|
componentId: "sc-1qwhj4c-1"
|
|
116
|
-
})(["overflow-y:auto;", "{padding:24px;border-right:1px solid ", ";width:30%;min-width:260px;min-height:48px;.MuiStepConnector-vertical{padding:0;}}", "{padding:16px;.MuiStepConnector-lineVertical{border:none;}}.stepper{padding:0 !important;background:transparent;", "{margin-top:100px;}", "{margin-top:40px;}.step{cursor:pointer;}}"], props => props.theme.breakpoints.up('md'), props => props.theme.palette.grey[100], props => props.theme.breakpoints.down('md'), props => props.theme.breakpoints.up('sm'), props => props.theme.breakpoints.down('md'));
|
|
173
|
+
})(["overflow-y:auto;", "{padding:24px;border-right:1px solid ", ";width:30%;min-width:260px;min-height:48px;.MuiStepConnector-vertical{padding:0;}}", "{padding:16px;.MuiStepConnector-lineVertical{border:none;}}.stepper{padding:0 !important;background:transparent;", "{margin-top:100px;}", "{margin-top:40px;}.step{cursor:pointer;}}.always-step-child{.step-child-block{animation:none !important;}}"], props => props.theme.breakpoints.up('md'), props => props.theme.palette.grey[100], props => props.theme.breakpoints.down('md'), props => props.theme.breakpoints.up('sm'), props => props.theme.breakpoints.down('md'));
|
|
117
174
|
|
|
118
175
|
const StepContainer = _styledComponents.default.div.withConfig({
|
|
119
176
|
displayName: "nav__StepContainer",
|
|
120
177
|
componentId: "sc-1qwhj4c-2"
|
|
121
|
-
})(["display:flex;flex-direction:column;margin-top:60px;", "{margin-top:30px;}.step-clickable{cursor:pointer;&:hover{color:", ";}}.step-line{display:block;position:absolute;z-index:1;left:11px;top:12px;width:2px;height:100%;opacity:0.5;background-color:", ";transition:all ease 0.2s;}.step-icon{position:relative;z-index:2;display:flex;flex-shrink:0;justify-content:center;align-items:center;width:24px;height:24px;border-radius:13px;background-color:", ";color:", ";transition:all ease 0.3s;&:before{position:absolute;left:4px;top:4px;z-index:3;display:block;background-color:", ";width:16px;height:16px;border-radius:10px;content:'';transform:scale(0);transition:all ease 0.3s;}& > *{transform:scale(0);transition:all ease 0.2s;}}.step-
|
|
178
|
+
})(["display:flex;flex-direction:column;margin-top:60px;", "{margin-top:30px;}.step-clickable{cursor:pointer;&:hover{color:", ";}}.step-line{display:block;position:absolute;z-index:1;left:11px;top:12px;width:2px;height:100%;opacity:0.5;background-color:", ";transition:all ease 0.2s;}.step-icon{position:relative;z-index:2;display:flex;flex-shrink:0;justify-content:center;align-items:center;width:24px;height:24px;border-radius:13px;background-color:", ";color:", ";transition:all ease 0.3s;&:before{position:absolute;left:4px;top:4px;z-index:3;display:block;background-color:", ";width:16px;height:16px;border-radius:10px;content:'';transform:scale(0);transition:all ease 0.3s;}& > *{transform:scale(0);transition:all ease 0.2s;}}.step-content{position:relative;flex:1;padding-top:1px;margin-left:22px;font-size:16px;color:", ";white-space:nowrap;}.step-desc{margin-top:24px;font-size:12px;font-weight:500;height:17px;color:", ";transition:all ease 0.3s;overflow:hidden;}", "{.step-content-name{position:absolute;left:0;top:0;width:100%;overflow:hidden;text-overflow:ellipsis;}}&.hide-child-step-desc{.step-desc{margin:0;opacity:0;height:0;}}.step-block{position:relative;display:flex;min-height:70px;opacity:0.5;overflow:hidden;transition:all ease 0.2s;&:last-child{height:auto;min-height:auto;}&.step-optional{height:0;opacity:0;min-height:0px;}&.step-checked,&.step-active{.step-desc{margin:0;opacity:0;height:0;}}&.step-checked{opacity:1;.step-icon{color:", ";background-color:", ";& > *{transform:scale(1);}}.step-line{background-color:", ";opacity:1;}}&.step-active{opacity:1;.step-icon{background-color:", ";}.step-icon:before{transform:scale(1);}.step-content{color:", ";}}&:last-child{.step-line{display:none;}.step-child-block{&:last-child{padding-bottom:0;}}}&.hide-step-child{.step-children{.step-child-block{margin-top:0;height:0;opacity:0;&:last-child{padding-bottom:0;}}}}}.step-children{padding-top:20px;.step-child-block{margin-top:4px;height:24px;line-height:24px;font-size:14px;color:#9397a1;transition:all ease 0.3s;&:first-child{margin-top:8px;}&:last-child{padding-bottom:40px;}&.step-child-block-active{color:", ";font-weight:700;}&.step-child-block-checked{color:", ";}}}.step-active{.step-child-block{animation:stepChildAnime ease 0.3s;}}@keyframes stepChildAnime{0%{height:0;}100%{height:24px;}}"], props => props.theme.breakpoints.down('md'), props => props.theme.palette.primary.main, props => props.theme.palette.grey[400], props => props.theme.palette.grey[400], props => props.theme.palette.common.white, props => props.theme.palette.common.white, props => props.theme.palette.grey[700], props => props.theme.palette.grey[700], props => props.theme.breakpoints.up('md'), props => props.theme.palette.common.white, props => props.theme.palette.primary.main, props => props.theme.palette.primary.main, props => props.theme.palette.primary.main, props => props.theme.palette.primary.main, props => props.theme.palette.common.black, props => props.theme.palette.common.black);
|
|
122
179
|
|
|
123
180
|
Nav.propTypes = {
|
|
124
181
|
blockletMeta: _propTypes.default.object.isRequired,
|
|
125
182
|
logoUrl: _propTypes.default.string,
|
|
126
|
-
locale: _propTypes.default.string
|
|
183
|
+
locale: _propTypes.default.string,
|
|
184
|
+
useOfSkeleton: _propTypes.default.bool
|
|
127
185
|
};
|
|
128
186
|
Nav.defaultProps = {
|
|
129
187
|
logoUrl: '',
|
|
130
|
-
locale: ''
|
|
188
|
+
locale: '',
|
|
189
|
+
useOfSkeleton: false
|
|
131
190
|
};
|
|
132
191
|
var _default = Nav;
|
|
133
192
|
exports.default = _default;
|
package/lib/page-header.js
CHANGED
|
@@ -11,7 +11,9 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
11
11
|
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
var _ArrowBackIos = _interopRequireDefault(require("@mui/icons-material/ArrowBackIos"));
|
|
15
|
+
|
|
16
|
+
const _excluded = ["title", "subTitle", "onClickBack"];
|
|
15
17
|
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
|
|
@@ -22,11 +24,15 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
22
24
|
function PageHeader(_ref) {
|
|
23
25
|
let {
|
|
24
26
|
title,
|
|
25
|
-
subTitle
|
|
27
|
+
subTitle,
|
|
28
|
+
onClickBack
|
|
26
29
|
} = _ref,
|
|
27
30
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
28
31
|
|
|
29
|
-
return /*#__PURE__*/_react.default.createElement(Content, rest, /*#__PURE__*/_react.default.createElement(
|
|
32
|
+
return /*#__PURE__*/_react.default.createElement(Content, rest, onClickBack && /*#__PURE__*/_react.default.createElement(_ArrowBackIos.default, {
|
|
33
|
+
className: "back-btn",
|
|
34
|
+
onClick: onClickBack
|
|
35
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
30
36
|
className: "title"
|
|
31
37
|
}, title), /*#__PURE__*/_react.default.createElement("div", {
|
|
32
38
|
className: "sub-title"
|
|
@@ -36,15 +42,17 @@ function PageHeader(_ref) {
|
|
|
36
42
|
const Content = _styledComponents.default.div.withConfig({
|
|
37
43
|
displayName: "page-header__Content",
|
|
38
44
|
componentId: "sc-1j6254k-0"
|
|
39
|
-
})(["width:100%;text-align:center;.title{font-size:24px;font-weight:700;color:", ";}.sub-title{font-size:14px;color:", ";padding:0 14px;font-weight:400;}"], props => props.theme.palette.common.black, props => props.theme.palette.grey[600]);
|
|
45
|
+
})(["position:relative;width:100%;text-align:center;.title{font-size:24px;font-weight:700;color:", ";}.sub-title{font-size:14px;color:", ";padding:0 14px;font-weight:400;}.back-btn{position:absolute;left:25px;top:8px;color:#9397a1;font-size:18px;cursor:pointer;}"], props => props.theme.palette.common.black, props => props.theme.palette.grey[600]);
|
|
40
46
|
|
|
41
47
|
var _default = PageHeader;
|
|
42
48
|
exports.default = _default;
|
|
43
49
|
PageHeader.propTypes = {
|
|
44
50
|
title: _propTypes.default.string,
|
|
45
|
-
subTitle: _propTypes.default.string
|
|
51
|
+
subTitle: _propTypes.default.string,
|
|
52
|
+
onClickBack: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string])
|
|
46
53
|
};
|
|
47
54
|
PageHeader.defaultProps = {
|
|
48
55
|
title: '',
|
|
49
|
-
subTitle: ''
|
|
56
|
+
subTitle: '',
|
|
57
|
+
onClickBack: ''
|
|
50
58
|
};
|
|
@@ -11,7 +11,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
11
11
|
|
|
12
12
|
var _util = require("@blocklet/meta/lib/util");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _get = _interopRequireDefault(require("lodash/get"));
|
|
15
15
|
|
|
16
16
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
17
17
|
|
|
@@ -88,32 +88,32 @@ function WizardDesc(_ref) {
|
|
|
88
88
|
const blockletDesc = data && data.htmlAst ? renderAst(data.htmlAst) : '';
|
|
89
89
|
const isFree = isFreeBlocklet(data);
|
|
90
90
|
const infos = [{
|
|
91
|
-
key: (0,
|
|
91
|
+
key: (0, _get.default)(localeData[locale], 'appinfo.name'),
|
|
92
92
|
value: (0, _util.getDisplayName)({
|
|
93
93
|
meta: data
|
|
94
94
|
})
|
|
95
95
|
}, {
|
|
96
|
-
key: (0,
|
|
96
|
+
key: (0, _get.default)(localeData[locale], 'appinfo.version'),
|
|
97
97
|
value: data.version
|
|
98
98
|
}, {
|
|
99
|
-
key: (0,
|
|
100
|
-
value: (0,
|
|
99
|
+
key: (0, _get.default)(localeData[locale], 'appinfo.author'),
|
|
100
|
+
value: (0, _get.default)(data, 'author.name')
|
|
101
101
|
}, {
|
|
102
102
|
type: 'description',
|
|
103
|
-
key: (0,
|
|
103
|
+
key: (0, _get.default)(localeData[locale], 'appinfo.description'),
|
|
104
104
|
value: data.description
|
|
105
105
|
}];
|
|
106
106
|
|
|
107
107
|
if (data.requirements) {
|
|
108
108
|
infos.push({
|
|
109
|
-
key: (0,
|
|
109
|
+
key: (0, _get.default)(localeData[locale], 'appinfo.requirements'),
|
|
110
110
|
value: data.requirements.server
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
if (data.community) {
|
|
115
115
|
infos.push({
|
|
116
|
-
key: (0,
|
|
116
|
+
key: (0, _get.default)(localeData[locale], 'appinfo.community'),
|
|
117
117
|
value: /*#__PURE__*/_react.default.createElement("a", {
|
|
118
118
|
href: data.community,
|
|
119
119
|
target: "_blank",
|
|
@@ -124,7 +124,7 @@ function WizardDesc(_ref) {
|
|
|
124
124
|
|
|
125
125
|
if (data.documentation) {
|
|
126
126
|
infos.push({
|
|
127
|
-
key: (0,
|
|
127
|
+
key: (0, _get.default)(localeData[locale], 'appinfo.documentation'),
|
|
128
128
|
value: /*#__PURE__*/_react.default.createElement("a", {
|
|
129
129
|
href: data.documentation,
|
|
130
130
|
target: "_blank",
|
|
@@ -135,7 +135,7 @@ function WizardDesc(_ref) {
|
|
|
135
135
|
|
|
136
136
|
if (data.support) {
|
|
137
137
|
infos.push({
|
|
138
|
-
key: (0,
|
|
138
|
+
key: (0, _get.default)(localeData[locale], 'appinfo.support'),
|
|
139
139
|
value: /*#__PURE__*/_react.default.createElement("a", {
|
|
140
140
|
href: "mailto:".concat(data.support),
|
|
141
141
|
target: "_blank",
|
|
@@ -146,7 +146,7 @@ function WizardDesc(_ref) {
|
|
|
146
146
|
|
|
147
147
|
if (blockletDesc) {
|
|
148
148
|
infos.push({
|
|
149
|
-
key: (0,
|
|
149
|
+
key: (0, _get.default)(localeData[locale], 'appinfo.overview'),
|
|
150
150
|
value: ''
|
|
151
151
|
});
|
|
152
152
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/launcher-layout",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.34",
|
|
4
4
|
"description": "Common ux components of launcher",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -37,17 +37,17 @@
|
|
|
37
37
|
"react": ">=18.1.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@arcblock/did-connect": "^2.1.
|
|
41
|
-
"@arcblock/icons": "^2.1.
|
|
42
|
-
"@arcblock/ux": "^2.1.
|
|
43
|
-
"@blocklet/meta": "^1.7.
|
|
40
|
+
"@arcblock/did-connect": "^2.1.40",
|
|
41
|
+
"@arcblock/icons": "^2.1.40",
|
|
42
|
+
"@arcblock/ux": "^2.1.40",
|
|
43
|
+
"@blocklet/meta": "^1.7.27",
|
|
44
44
|
"@emotion/react": "^11.9.0",
|
|
45
45
|
"@emotion/styled": "^11.8.1",
|
|
46
46
|
"@mui/icons-material": "^5.6.2",
|
|
47
47
|
"@mui/lab": "^5.0.0-alpha.81",
|
|
48
48
|
"@mui/material": "^5.6.4",
|
|
49
49
|
"@mui/styles": "^5.6.2",
|
|
50
|
-
"lodash
|
|
50
|
+
"lodash": "^4.17.21",
|
|
51
51
|
"prop-types": "^15.8.1",
|
|
52
52
|
"rehype-react": "^7.0.4",
|
|
53
53
|
"styled-components": "^5.3.3",
|
|
@@ -58,8 +58,9 @@
|
|
|
58
58
|
"@babel/core": "^7.8.4",
|
|
59
59
|
"@babel/preset-env": "^7.8.4",
|
|
60
60
|
"@babel/preset-react": "^7.8.3",
|
|
61
|
+
"@storybook/react": "^6.5.4",
|
|
61
62
|
"babel-plugin-inline-react-svg": "^2.0.1",
|
|
62
63
|
"babel-plugin-styled-components": "^1.10.7"
|
|
63
64
|
},
|
|
64
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "c56c534bdbb962bc810511dfc929904882b966be"
|
|
65
66
|
}
|