@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/compact-layout.js +27 -78
- package/lib/content.js +16 -18
- package/lib/context/step.js +61 -126
- package/lib/header.js +107 -203
- package/lib/index.js +153 -219
- package/lib/info-list.js +54 -41
- package/lib/launch-result-message.js +39 -63
- package/lib/locale.js +9 -8
- package/lib/markdown-body.js +15 -19
- package/lib/nav.js +138 -190
- package/lib/page-header.js +22 -38
- package/lib/small-circle-progress.js +38 -45
- package/lib/theme-provider.js +21 -38
- package/lib/wizard/hotkey-submit.js +19 -35
- package/lib/wizard/server-eula.js +50 -65
- package/lib/wizard/wizard-desc.js +147 -240
- package/package.json +14 -24
- package/lib/LaunchResultMessage/demo/default.js +0 -82
- package/lib/LaunchResultMessage/result-message.stories.js +0 -27
- package/lib/Layout/demo/child-progress-in-memory-mode.js +0 -70
- package/lib/Layout/demo/child-progress.js +0 -54
- package/lib/Layout/demo/constants.js +0 -76
- package/lib/Layout/demo/default.js +0 -54
- package/lib/Layout/demo/extra-nav.js +0 -108
- package/lib/Layout/demo/logo-url.js +0 -31
- package/lib/Layout/demo/longest-steps-for-launch.js +0 -95
- package/lib/Layout/demo/memory-mode.js +0 -49
- package/lib/Layout/demo/old-code-compatible.js +0 -36
- package/lib/Layout/demo/optional-step.js +0 -61
- package/lib/Layout/demo/show-child.js +0 -93
- package/lib/Layout/demo/static-demo-data.json +0 -85
- package/lib/Layout/layout.stories.js +0 -28
package/lib/compact-layout.js
CHANGED
|
@@ -1,76 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const [scrollMode, setScrollMode] = useState(false);
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
let inTimer;
|
|
17
|
-
const fixSize = () => {
|
|
18
|
-
if (inTimer) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
inTimer = setTimeout(() => {
|
|
22
|
-
if (childsCon.current) {
|
|
23
|
-
if (childsCon.current.scrollHeight > mainCon.current.clientHeight - compactCon.current.clientHeight) {
|
|
24
|
-
if (isFix.current !== 'fix') {
|
|
25
|
-
onBottomFix('fix');
|
|
26
|
-
isFix.current = 'fix';
|
|
27
|
-
}
|
|
28
|
-
setScrollMode(true);
|
|
29
|
-
} else {
|
|
30
|
-
if (isFix.current !== 'scroll') {
|
|
31
|
-
onBottomFix('scroll');
|
|
32
|
-
isFix.current = 'scroll';
|
|
33
|
-
}
|
|
34
|
-
setScrollMode(false);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
inTimer = null;
|
|
38
|
-
}, 50);
|
|
1
|
+
import { jsxs as x, jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as n, useState as h, useEffect as v } from "react";
|
|
3
|
+
import w from "@emotion/styled";
|
|
4
|
+
import l from "prop-types";
|
|
5
|
+
import y from "lodash/noop";
|
|
6
|
+
function b({ children: m = [], bottom: d, onBottomFix: o = y }) {
|
|
7
|
+
const s = n(null), t = n(null), f = n(null), i = n(null), [p, a] = h(!1);
|
|
8
|
+
return v(() => {
|
|
9
|
+
let e;
|
|
10
|
+
const c = () => {
|
|
11
|
+
e || (e = setTimeout(() => {
|
|
12
|
+
t.current && (t.current.scrollHeight > s.current.clientHeight - f.current.clientHeight ? (i.current !== "fix" && (o("fix"), i.current = "fix"), a(!0)) : (i.current !== "scroll" && (o("scroll"), i.current = "scroll"), a(!1))), e = null;
|
|
13
|
+
}, 50));
|
|
39
14
|
};
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} else {
|
|
44
|
-
window.addEventListener('resize', fixSize);
|
|
45
|
-
}
|
|
46
|
-
resizeObs.observe(mainCon.current);
|
|
47
|
-
resizeObs.observe(childsCon.current);
|
|
48
|
-
return () => {
|
|
49
|
-
if (resizeObs) {
|
|
50
|
-
resizeObs.disconnect();
|
|
51
|
-
} else {
|
|
52
|
-
window.removeEventListener('resize', fixSize);
|
|
53
|
-
}
|
|
54
|
-
if (inTimer) {
|
|
55
|
-
clearTimeout(inTimer);
|
|
56
|
-
}
|
|
15
|
+
let r;
|
|
16
|
+
return window.ResizeObserver ? r = new ResizeObserver(c) : window.addEventListener("resize", c), r.observe(s.current), r.observe(t.current), () => {
|
|
17
|
+
r ? r.disconnect() : window.removeEventListener("resize", c), e && clearTimeout(e);
|
|
57
18
|
};
|
|
58
|
-
}, [
|
|
59
|
-
|
|
60
|
-
ref:
|
|
61
|
-
|
|
62
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
63
|
-
className: "compact-context",
|
|
64
|
-
ref: childsCon,
|
|
65
|
-
children: children
|
|
66
|
-
}), /*#__PURE__*/_jsx("div", {
|
|
67
|
-
className: "fix-container",
|
|
68
|
-
ref: compactCon,
|
|
69
|
-
children: bottom
|
|
70
|
-
})]
|
|
71
|
-
});
|
|
19
|
+
}, [o]), /* @__PURE__ */ x(g, { ref: s, className: `${p ? "scroll-mode" : ""}`, children: [
|
|
20
|
+
/* @__PURE__ */ u("div", { className: "compact-context", ref: t, children: m }),
|
|
21
|
+
/* @__PURE__ */ u("div", { className: "fix-container", ref: f, children: d })
|
|
22
|
+
] });
|
|
72
23
|
}
|
|
73
|
-
const
|
|
24
|
+
const g = w.div`
|
|
74
25
|
display: flex;
|
|
75
26
|
flex-direction: column;
|
|
76
27
|
width: 100%;
|
|
@@ -102,13 +53,11 @@ const Container = styled.div`
|
|
|
102
53
|
}
|
|
103
54
|
}
|
|
104
55
|
`;
|
|
105
|
-
|
|
106
|
-
children:
|
|
107
|
-
bottom:
|
|
108
|
-
onBottomFix:
|
|
56
|
+
b.propTypes = {
|
|
57
|
+
children: l.any,
|
|
58
|
+
bottom: l.element.isRequired,
|
|
59
|
+
onBottomFix: l.func
|
|
109
60
|
};
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
onBottomFix: () => {}
|
|
61
|
+
export {
|
|
62
|
+
b as default
|
|
113
63
|
};
|
|
114
|
-
export default CompactLayout;
|
package/lib/content.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
function
|
|
5
|
-
children
|
|
6
|
-
}) {
|
|
7
|
-
return /*#__PURE__*/_jsx(Container, {
|
|
8
|
-
children: children
|
|
9
|
-
});
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import n from "@emotion/styled";
|
|
3
|
+
import i from "prop-types";
|
|
4
|
+
function o({ children: t }) {
|
|
5
|
+
return /* @__PURE__ */ e(r, { children: t });
|
|
10
6
|
}
|
|
11
|
-
|
|
12
|
-
children:
|
|
7
|
+
o.propTypes = {
|
|
8
|
+
children: i.any.isRequired
|
|
13
9
|
};
|
|
14
|
-
|
|
15
|
-
const Container = styled.div`
|
|
10
|
+
const r = n.div`
|
|
16
11
|
display: flex;
|
|
17
12
|
flex-direction: column;
|
|
18
13
|
height: 100%;
|
|
@@ -33,7 +28,7 @@ const Container = styled.div`
|
|
|
33
28
|
align-items: center;
|
|
34
29
|
|
|
35
30
|
.toolbar_title {
|
|
36
|
-
color: ${
|
|
31
|
+
color: ${(t) => t.theme.palette.grey[900]};
|
|
37
32
|
font-size: 16px;
|
|
38
33
|
}
|
|
39
34
|
}
|
|
@@ -44,7 +39,7 @@ const Container = styled.div`
|
|
|
44
39
|
align-items: center;
|
|
45
40
|
|
|
46
41
|
width: 100%;
|
|
47
|
-
background: ${
|
|
42
|
+
background: ${(t) => t.theme.palette.background.paper};
|
|
48
43
|
|
|
49
44
|
.create-button {
|
|
50
45
|
margin-right: 32px;
|
|
@@ -55,7 +50,7 @@ const Container = styled.div`
|
|
|
55
50
|
margin: 0 8px;
|
|
56
51
|
}
|
|
57
52
|
|
|
58
|
-
${
|
|
53
|
+
${(t) => t.theme.breakpoints.up("md")} {
|
|
59
54
|
padding: 24px;
|
|
60
55
|
& > button,
|
|
61
56
|
.button {
|
|
@@ -64,9 +59,12 @@ const Container = styled.div`
|
|
|
64
59
|
}
|
|
65
60
|
}
|
|
66
61
|
|
|
67
|
-
${
|
|
62
|
+
${(t) => t.theme.breakpoints.down("md")} {
|
|
68
63
|
margin-top: auto;
|
|
69
64
|
padding: 16px;
|
|
70
65
|
}
|
|
71
66
|
}
|
|
72
|
-
`;
|
|
67
|
+
`;
|
|
68
|
+
export {
|
|
69
|
+
o as default
|
|
70
|
+
};
|
package/lib/context/step.js
CHANGED
|
@@ -1,137 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (item.children) {
|
|
28
|
-
return [{
|
|
29
|
-
key: item.key,
|
|
30
|
-
hasChild: true
|
|
31
|
-
}, item.children.map(childItem => {
|
|
32
|
-
return {
|
|
33
|
-
parentKey: item.key,
|
|
34
|
-
key: childItem.key
|
|
35
|
-
};
|
|
36
|
-
})];
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
key: item.key
|
|
40
|
-
};
|
|
41
|
-
}).flat(Infinity);
|
|
42
|
-
const totalSteps = flatSteps.filter(e => !e.hasChild);
|
|
43
|
-
|
|
44
|
-
// 根据 key 获取当前 step 处于的状态;before已超过该步骤;current处于当前步骤;after还未到这个步骤;
|
|
45
|
-
const getStepStatus = key => {
|
|
46
|
-
let activeParentStepKey;
|
|
47
|
-
const activeIndex = flatSteps.findIndex(e => {
|
|
48
|
-
if (e.key === activeStepKey) {
|
|
49
|
-
activeParentStepKey = e.parentKey;
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
return false;
|
|
53
|
-
});
|
|
54
|
-
if (activeParentStepKey === key) {
|
|
55
|
-
return 'current';
|
|
56
|
-
}
|
|
57
|
-
const targetIndex = flatSteps.findIndex(e => e.key === key);
|
|
58
|
-
if (targetIndex !== -1) {
|
|
59
|
-
if (targetIndex === activeIndex) {
|
|
60
|
-
return 'current';
|
|
61
|
-
}
|
|
62
|
-
if (targetIndex < activeIndex) {
|
|
63
|
-
return 'before';
|
|
64
|
-
}
|
|
1
|
+
import { jsx as I } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as m, useState as g, useEffect as K, use as C } from "react";
|
|
3
|
+
import p from "prop-types";
|
|
4
|
+
const k = m(), { Provider: w } = k, d = (o, r, i = window.location.pathname.replace(/\/$/, "/")) => o ? r ? o === i : new RegExp(o).test(i) : !1;
|
|
5
|
+
function P({ children: o, steps: r, mode: i = "history" }) {
|
|
6
|
+
const [c, f] = g("");
|
|
7
|
+
!c && r.length && f(r[0].key);
|
|
8
|
+
const y = r.map((e) => e.children ? [
|
|
9
|
+
{
|
|
10
|
+
key: e.key,
|
|
11
|
+
hasChild: !0
|
|
12
|
+
},
|
|
13
|
+
e.children.map((t) => ({ parentKey: e.key, key: t.key }))
|
|
14
|
+
] : {
|
|
15
|
+
key: e.key
|
|
16
|
+
}).flat(1 / 0), u = y.filter((e) => !e.hasChild), h = (e) => {
|
|
17
|
+
let t;
|
|
18
|
+
const n = y.findIndex((a) => a.key === c ? (t = a.parentKey, !0) : !1);
|
|
19
|
+
if (t === e)
|
|
20
|
+
return "current";
|
|
21
|
+
const l = y.findIndex((a) => a.key === e);
|
|
22
|
+
if (l !== -1) {
|
|
23
|
+
if (l === n)
|
|
24
|
+
return "current";
|
|
25
|
+
if (l < n)
|
|
26
|
+
return "before";
|
|
65
27
|
}
|
|
66
|
-
return
|
|
28
|
+
return "after";
|
|
67
29
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
function setActiveStepByKey(key) {
|
|
71
|
-
setActiveStepKey(key);
|
|
30
|
+
function x(e) {
|
|
31
|
+
f(e);
|
|
72
32
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
} else {
|
|
80
|
-
setActiveStepKey(totalSteps[index].key);
|
|
81
|
-
}
|
|
33
|
+
function S(e) {
|
|
34
|
+
if (typeof e == "function") {
|
|
35
|
+
const t = e(u.findIndex((n) => n.key === c));
|
|
36
|
+
f(u[t].key);
|
|
37
|
+
} else
|
|
38
|
+
f(u[e].key);
|
|
82
39
|
}
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
let
|
|
87
|
-
|
|
88
|
-
if (step.children && step.children.length) {
|
|
89
|
-
return step.children.some(childStep => {
|
|
90
|
-
if (matchPath(childStep.path, childStep.exact)) {
|
|
91
|
-
stepKey = childStep.key;
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
return false;
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
if (matchPath(step.path, step.exact)) {
|
|
98
|
-
stepKey = step.key;
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
return false;
|
|
102
|
-
});
|
|
103
|
-
if (stepKey) {
|
|
104
|
-
setActiveStepKey(stepKey);
|
|
105
|
-
}
|
|
40
|
+
const s = u.findIndex((e) => e.key === c);
|
|
41
|
+
K(() => {
|
|
42
|
+
if (i === "history") {
|
|
43
|
+
let e = "";
|
|
44
|
+
r.some((t) => t.children && t.children.length ? t.children.some((n) => d(n.path, n.exact) ? (e = n.key, !0) : !1) : d(t.path, t.exact) ? (e = t.key, !0) : !1), e && f(e);
|
|
106
45
|
}
|
|
107
|
-
return () => {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
46
|
+
return () => {
|
|
47
|
+
};
|
|
48
|
+
}, [r, i]);
|
|
49
|
+
const v = {
|
|
50
|
+
steps: r,
|
|
51
|
+
totalStepsCount: u.length,
|
|
52
|
+
getStepStatus: h,
|
|
53
|
+
setActiveStepByKey: x,
|
|
54
|
+
setActiveStepByIndex: S,
|
|
55
|
+
activeStep: s,
|
|
116
56
|
// judge node can be clicked to back if the mode is 'memory'
|
|
117
|
-
canBackToStep:
|
|
118
|
-
return mode === 'memory' && activeStep !== 0 && nodeIndex < activeStep;
|
|
119
|
-
}
|
|
57
|
+
canBackToStep: (e) => i === "memory" && s !== 0 && e < s
|
|
120
58
|
};
|
|
121
|
-
return
|
|
122
|
-
value: value,
|
|
123
|
-
children: children
|
|
124
|
-
});
|
|
59
|
+
return /* @__PURE__ */ I(w, { value: v, children: o });
|
|
125
60
|
}
|
|
126
|
-
function
|
|
127
|
-
return
|
|
61
|
+
function T() {
|
|
62
|
+
return C(k);
|
|
128
63
|
}
|
|
129
|
-
|
|
130
|
-
children:
|
|
131
|
-
steps:
|
|
132
|
-
mode:
|
|
64
|
+
P.propTypes = {
|
|
65
|
+
children: p.any.isRequired,
|
|
66
|
+
steps: p.array.isRequired,
|
|
67
|
+
mode: p.string
|
|
133
68
|
};
|
|
134
|
-
|
|
135
|
-
|
|
69
|
+
export {
|
|
70
|
+
P as StepProvider,
|
|
71
|
+
T as useStepContext
|
|
136
72
|
};
|
|
137
|
-
export { StepProvider, useStepContext };
|