@lemon-fe/mini-app 0.1.24 → 0.1.25
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/components/AppContainer/index.d.ts +2 -1
- package/es/components/AppContainer/index.js +5 -3
- package/es/components/Screen/index.css +11 -7
- package/es/components/Screen/index.js +9 -6
- package/es/context/index.d.ts +2 -0
- package/es/global.d.ts +5 -1
- package/es/global.js +2 -1
- package/package.json +5 -3
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
1
|
+
import { CSSProperties, ReactElement } from 'react';
|
|
2
2
|
import type { NavigationStackScreen } from '../../typings';
|
|
3
3
|
import './index.css';
|
|
4
4
|
interface Props {
|
|
5
5
|
pages: NavigationStackScreen[];
|
|
6
6
|
children?: ReactElement | null;
|
|
7
|
+
headerStyle?: CSSProperties;
|
|
7
8
|
}
|
|
8
9
|
declare function App(props: Props): JSX.Element;
|
|
9
10
|
export default App;
|
|
@@ -35,7 +35,8 @@ import './index.css';
|
|
|
35
35
|
|
|
36
36
|
function App(props) {
|
|
37
37
|
var pages = props.pages,
|
|
38
|
-
children = props.children
|
|
38
|
+
children = props.children,
|
|
39
|
+
headerStyle = props.headerStyle;
|
|
39
40
|
|
|
40
41
|
var _useState = useState({
|
|
41
42
|
routes: [{
|
|
@@ -117,9 +118,10 @@ function App(props) {
|
|
|
117
118
|
navigation: {
|
|
118
119
|
navigate: navigate,
|
|
119
120
|
goBack: goBack
|
|
120
|
-
}
|
|
121
|
+
},
|
|
122
|
+
headerStyle: headerStyle
|
|
121
123
|
};
|
|
122
|
-
}, [navigate, goBack]);
|
|
124
|
+
}, [navigate, goBack, headerStyle]);
|
|
123
125
|
var screens = /*#__PURE__*/React.createElement(TransitionGroup, {
|
|
124
126
|
className: "lemon-routes"
|
|
125
127
|
}, state.routes.map(function (item, index) {
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
.lemon-route {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
2
|
position: absolute;
|
|
5
3
|
top: 0;
|
|
6
4
|
right: 0;
|
|
7
5
|
bottom: 0;
|
|
8
|
-
left: 0;
|
|
9
|
-
|
|
6
|
+
left: 0;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
10
9
|
color: #333;
|
|
10
|
+
background-color: #fff;
|
|
11
11
|
transition: transform 300ms;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
.lemon-route-header {
|
|
15
|
+
padding-top: env(safe-area-inset-top);
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
.lemon-route-header-content {
|
|
15
19
|
position: relative;
|
|
16
20
|
height: 44px;
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
.lemon-route-header-left {
|
|
20
|
-
display: flex;
|
|
21
|
-
align-items: center;
|
|
22
24
|
position: absolute;
|
|
23
25
|
top: 0;
|
|
24
26
|
bottom: 0;
|
|
25
27
|
left: 0;
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
26
30
|
padding-left: 15px;
|
|
27
31
|
line-height: 1;
|
|
28
32
|
}
|
|
@@ -30,8 +34,8 @@
|
|
|
30
34
|
.lemon-route-header-center {
|
|
31
35
|
font-weight: bold;
|
|
32
36
|
font-size: 16px;
|
|
33
|
-
text-align: center;
|
|
34
37
|
line-height: 44px;
|
|
38
|
+
text-align: center;
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
.lemon-route-body {
|
|
@@ -4,9 +4,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
|
-
import React, { createElement, memo, useMemo } from 'react';
|
|
8
|
-
import { ScreenContext } from '../../context';
|
|
9
|
-
import { useNavigation } from '../../hooks';
|
|
7
|
+
import React, { createElement, memo, useContext, useMemo } from 'react';
|
|
8
|
+
import { NavigationContext, ScreenContext } from '../../context';
|
|
10
9
|
import { mini } from '../../global';
|
|
11
10
|
import './index.css';
|
|
12
11
|
|
|
@@ -22,16 +21,20 @@ function Screen(props) {
|
|
|
22
21
|
var statusBarHeight = useMemo(function () {
|
|
23
22
|
return mini.getSystemInfoSync().statusBarHeight;
|
|
24
23
|
}, []);
|
|
25
|
-
|
|
24
|
+
|
|
25
|
+
var _useContext = useContext(NavigationContext),
|
|
26
|
+
navigation = _useContext.navigation,
|
|
27
|
+
headerStyle = _useContext.headerStyle;
|
|
28
|
+
|
|
26
29
|
return /*#__PURE__*/React.createElement(ScreenContext.Provider, {
|
|
27
30
|
value: ctx
|
|
28
31
|
}, /*#__PURE__*/React.createElement("div", {
|
|
29
32
|
className: "lemon-route"
|
|
30
33
|
}, /*#__PURE__*/React.createElement("div", {
|
|
31
34
|
className: "lemon-route-header",
|
|
32
|
-
style: _objectSpread({
|
|
35
|
+
style: _objectSpread(_objectSpread({
|
|
33
36
|
paddingTop: statusBarHeight
|
|
34
|
-
}, route.headerStyle)
|
|
37
|
+
}, headerStyle), route.headerStyle)
|
|
35
38
|
}, /*#__PURE__*/React.createElement("div", {
|
|
36
39
|
className: "lemon-route-header-content"
|
|
37
40
|
}, index > 0 && /*#__PURE__*/React.createElement("div", {
|
package/es/context/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
1
2
|
export declare const NavigationContext: import("react").Context<{
|
|
2
3
|
navigation: {
|
|
3
4
|
navigate: (path: string, params?: Record<string, any> | undefined) => void;
|
|
4
5
|
goBack: () => void;
|
|
5
6
|
};
|
|
7
|
+
headerStyle?: CSSProperties | undefined;
|
|
6
8
|
}>;
|
|
7
9
|
export declare const ScreenContext: import("react").Context<{
|
|
8
10
|
params?: Record<string, any> | undefined;
|
package/es/global.d.ts
CHANGED
|
@@ -11,9 +11,13 @@ interface Mini {
|
|
|
11
11
|
};
|
|
12
12
|
addListener(cb: (e: string) => void): void;
|
|
13
13
|
getExtraPayload(): unknown;
|
|
14
|
-
scanCode(
|
|
14
|
+
scanCode(opts: {
|
|
15
15
|
success: (value: string) => void;
|
|
16
16
|
}): void;
|
|
17
|
+
setStatusBarStyle(opt: {
|
|
18
|
+
success?: () => void;
|
|
19
|
+
params: 'default' | 'light-content' | 'dark-content';
|
|
20
|
+
}): void;
|
|
17
21
|
exit(): void;
|
|
18
22
|
}
|
|
19
23
|
declare global {
|
package/es/global.js
CHANGED
|
@@ -14,7 +14,8 @@ export var mini = {
|
|
|
14
14
|
addListener: function addListener() {},
|
|
15
15
|
getExtraPayload: function getExtraPayload() {},
|
|
16
16
|
scanCode: function scanCode() {},
|
|
17
|
-
exit: function exit() {}
|
|
17
|
+
exit: function exit() {},
|
|
18
|
+
setStatusBarStyle: function setStatusBarStyle() {}
|
|
18
19
|
};
|
|
19
20
|
export function createApp(render) {
|
|
20
21
|
var count = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/mini-app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "鲁盛杰 <lusj@cnlemon.net>",
|
|
6
6
|
"homepage": "",
|
|
@@ -27,10 +27,12 @@
|
|
|
27
27
|
"react-transition-group": "^4.4.2"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
+
"color-string": "^1.6.0",
|
|
30
31
|
"react": ">=17.0.2"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"@types/react-transition-group": "^4.4.4"
|
|
34
|
+
"@types/react-transition-group": "^4.4.4",
|
|
35
|
+
"color-string": "^1.9.0"
|
|
34
36
|
},
|
|
35
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "ea6abf747e0deb1b7f8bdf638639800206b59b42"
|
|
36
38
|
}
|