@mpxjs/webpack-plugin 2.10.14-beta.1 → 2.10.14-beta.10
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/dependencies/ImportDependency.js +102 -0
- package/lib/index.js +9 -9
- package/lib/platform/style/wx/index.js +7 -1
- package/lib/platform/template/wx/component-config/button.js +13 -4
- package/lib/platform/template/wx/component-config/index.js +3 -1
- package/lib/platform/template/wx/component-config/nav-container.js +27 -0
- package/lib/react/processScript.js +4 -2
- package/lib/react/script-helper.js +3 -3
- package/lib/runtime/components/ali/mpx-nav-container.mpx +3 -0
- package/lib/runtime/components/react/context.ts +17 -6
- package/lib/runtime/components/react/dist/context.d.ts +78 -0
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/event.config.d.ts +7 -0
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +12 -0
- package/lib/runtime/components/react/dist/mpx-button.d.ts +68 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +23 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +6 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +20 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +10 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +2 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +32 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +52 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +20 -0
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +32 -0
- package/lib/runtime/components/react/dist/mpx-form.d.ts +27 -0
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +18 -0
- package/lib/runtime/components/react/dist/mpx-image.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-input.d.ts +50 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +36 -17
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +12 -0
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +66 -47
- package/lib/runtime/components/react/dist/mpx-label.d.ts +20 -0
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +20 -0
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +63 -0
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +24 -17
- package/lib/runtime/components/react/dist/mpx-nav-container.d.ts +9 -0
- package/lib/runtime/components/react/dist/mpx-nav-container.jsx +23 -0
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts +9 -0
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +6 -0
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +6 -0
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +6 -0
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +6 -0
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +2 -0
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +6 -0
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +6 -0
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +106 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +31 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +22 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +14 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +16 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +12 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +11 -0
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +22 -0
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +16 -0
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +15 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +29 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +9 -0
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +20 -0
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +26 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +1 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +24 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +14 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +54 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +26 -8
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +17 -0
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +15 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +18 -0
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +52 -0
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +48 -39
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +26 -0
- package/lib/runtime/components/react/dist/mpx-text.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-video.d.ts +101 -0
- package/lib/runtime/components/react/dist/mpx-view.d.ts +34 -0
- package/lib/runtime/components/react/dist/mpx-view.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +22 -0
- package/lib/runtime/components/react/dist/nav.d.ts +8 -0
- package/lib/runtime/components/react/dist/nav.jsx +137 -0
- package/lib/runtime/components/react/dist/parser.d.ts +39 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +32 -0
- package/lib/runtime/components/react/dist/useNavShared.d.ts +2 -0
- package/lib/runtime/components/react/dist/useNavShared.js +6 -0
- package/lib/runtime/components/react/dist/useNodesRef.d.ts +11 -0
- package/lib/runtime/components/react/dist/utils.d.ts +122 -0
- package/lib/runtime/components/react/mpx-input.tsx +46 -24
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +75 -46
- package/lib/runtime/components/react/mpx-movable-view.tsx +26 -20
- package/lib/runtime/components/react/mpx-nav-container.tsx +33 -0
- package/lib/runtime/components/react/mpx-scroll-view.tsx +30 -8
- package/lib/runtime/components/react/mpx-swiper.tsx +48 -37
- package/lib/runtime/components/react/mpx-view.tsx +1 -1
- package/lib/runtime/components/react/nav.tsx +163 -0
- package/lib/runtime/components/react/types/common.d.ts +19 -0
- package/lib/runtime/components/react/useNavShared.ts +8 -0
- package/lib/runtime/components/web/mpx-nav-container.vue +13 -0
- package/lib/runtime/components/wx/mpx-nav-container.mpx +9 -0
- package/lib/utils/dom-tag-config.js +2 -2
- package/package.json +1 -1
- package/lib/dependencies/ImportDependencyTemplate.js +0 -50
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ✔ src
|
|
3
|
+
* ✘ duration
|
|
4
|
+
* ✔ controls
|
|
5
|
+
* ✘ danmu-list
|
|
6
|
+
* ✘ danmu-btn
|
|
7
|
+
* ✘ enable-danmu
|
|
8
|
+
* ✔ autoplay
|
|
9
|
+
* ✔ loop
|
|
10
|
+
* ✔ muted
|
|
11
|
+
* ✔ initial-time
|
|
12
|
+
* ✘ page-gesture
|
|
13
|
+
* ✘ direction
|
|
14
|
+
* ✘ show-progress
|
|
15
|
+
* ✘ show-fullscreen-btn
|
|
16
|
+
* ✘ show-play-btn
|
|
17
|
+
* ✘ show-center-play-btn
|
|
18
|
+
* ✘ enable-progress-gesture
|
|
19
|
+
* ✔ object-fit
|
|
20
|
+
* ✔ poster
|
|
21
|
+
* ✘ show-mute-btn
|
|
22
|
+
* ✘ title
|
|
23
|
+
* ✘ play-btn-position
|
|
24
|
+
* ✘ enable-play-gesture
|
|
25
|
+
* ✘ auto-pause-if-navigate
|
|
26
|
+
* ✘ auto-pause-if-open-native
|
|
27
|
+
* ✘ vslide-gesture
|
|
28
|
+
* ✘ vslide-gesture-in-fullscreen
|
|
29
|
+
* ✘ show-bottom-progress(use show-progress)
|
|
30
|
+
* ✘ ad-unit-id
|
|
31
|
+
* ✘ poster-for-crawler
|
|
32
|
+
* ✘ show-casting-button
|
|
33
|
+
* ✘ picture-in-picture-mode
|
|
34
|
+
* ✘ picture-in-picture-show-progress
|
|
35
|
+
* ✘ picture-in-picture-init-position
|
|
36
|
+
* ✔ enable-auto-rotation (only ios)
|
|
37
|
+
* ✘ show-screen-lock-button
|
|
38
|
+
* ✘ show-snapshot-button
|
|
39
|
+
* ✘ show-background-playback-button
|
|
40
|
+
* ✘ background-poster
|
|
41
|
+
* ✘ referrer-policy
|
|
42
|
+
* ✔ is-drm
|
|
43
|
+
* ✘ is-live
|
|
44
|
+
* ✔ provision-url(android)
|
|
45
|
+
* ✔ certificate-url(ios)
|
|
46
|
+
* ✔ license-url
|
|
47
|
+
* ✔ preferred-peak-bit-rate
|
|
48
|
+
* ✔ bindplay
|
|
49
|
+
* ✔ bindpause
|
|
50
|
+
* ✔ bindended
|
|
51
|
+
* ✘ bindtimeupdate
|
|
52
|
+
* ✔ bindfullscreenchange
|
|
53
|
+
* ✔ bindwaiting
|
|
54
|
+
* ✔ binderror
|
|
55
|
+
* ✘ bindprogress
|
|
56
|
+
* ✔ bindloadedmetadata
|
|
57
|
+
* ✔ bindcontrolstoggle(only android)
|
|
58
|
+
* ✘ bindenterpictureinpicture
|
|
59
|
+
* ✘ bindleavepictureinpicture
|
|
60
|
+
* ✔ bindseekcomplete
|
|
61
|
+
* ✘ bindcastinguserselect
|
|
62
|
+
* ✘ bindcastingstatechange
|
|
63
|
+
* ✘ bindcastinginterrupt
|
|
64
|
+
*/
|
|
65
|
+
/// <reference types="react" />
|
|
66
|
+
import { View, ViewStyle } from 'react-native';
|
|
67
|
+
import { HandlerRef } from './useNodesRef';
|
|
68
|
+
interface VideoProps {
|
|
69
|
+
src: string;
|
|
70
|
+
autoplay?: boolean;
|
|
71
|
+
loop?: boolean;
|
|
72
|
+
muted?: boolean;
|
|
73
|
+
controls?: boolean;
|
|
74
|
+
poster?: string;
|
|
75
|
+
style?: ViewStyle;
|
|
76
|
+
'initial-time'?: number;
|
|
77
|
+
'object-fit'?: null | 'contain' | 'fill' | 'cover';
|
|
78
|
+
'is-drm'?: boolean;
|
|
79
|
+
'provision-url'?: string;
|
|
80
|
+
'certificate-url'?: string;
|
|
81
|
+
'license-url'?: string;
|
|
82
|
+
'preferred-peak-bit-rate'?: number;
|
|
83
|
+
'enable-auto-rotation'?: number;
|
|
84
|
+
'enable-var'?: boolean;
|
|
85
|
+
'external-var-context'?: Record<string, any>;
|
|
86
|
+
'parent-font-size'?: number;
|
|
87
|
+
'parent-width'?: number;
|
|
88
|
+
'parent-height'?: number;
|
|
89
|
+
bindplay?: (event: Record<string, any>) => void;
|
|
90
|
+
bindpause?: (event: Record<string, any>) => void;
|
|
91
|
+
bindended?: (event: Record<string, any>) => void;
|
|
92
|
+
bindtimeupdate?: (event: Record<string, any>) => void;
|
|
93
|
+
bindfullscreenchange?: (event: Record<string, any>) => void;
|
|
94
|
+
bindwaiting?: (event: Record<string, any>) => void;
|
|
95
|
+
binderror?: (event: Record<string, any>) => void;
|
|
96
|
+
bindloadedmetadata?: (event: Record<string, any>) => void;
|
|
97
|
+
bindcontrolstoggle?: (event: Record<string, any>) => void;
|
|
98
|
+
bindseekcomplete?: (event: Record<string, any>) => void;
|
|
99
|
+
}
|
|
100
|
+
declare const MpxVideo: import("react").ForwardRefExoticComponent<VideoProps & import("react").RefAttributes<HandlerRef<View, VideoProps>>>;
|
|
101
|
+
export default MpxVideo;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ✔ hover-class
|
|
3
|
+
* ✘ hover-stop-propagation
|
|
4
|
+
* ✔ hover-start-time
|
|
5
|
+
* ✔ hover-stay-time
|
|
6
|
+
*/
|
|
7
|
+
import { View, NativeSyntheticEvent, ViewProps } from 'react-native';
|
|
8
|
+
import { ReactNode } from 'react';
|
|
9
|
+
import type { AnimationProp } from './useAnimationHooks';
|
|
10
|
+
import { ExtendedViewStyle } from './types/common';
|
|
11
|
+
import { HandlerRef } from './useNodesRef';
|
|
12
|
+
export interface _ViewProps extends ViewProps {
|
|
13
|
+
style?: ExtendedViewStyle;
|
|
14
|
+
animation?: AnimationProp;
|
|
15
|
+
children?: ReactNode | ReactNode[];
|
|
16
|
+
'hover-style'?: ExtendedViewStyle;
|
|
17
|
+
'hover-start-time'?: number;
|
|
18
|
+
'hover-stay-time'?: number;
|
|
19
|
+
'enable-background'?: boolean;
|
|
20
|
+
'enable-var'?: boolean;
|
|
21
|
+
'enable-fast-image'?: boolean;
|
|
22
|
+
'external-var-context'?: Record<string, any>;
|
|
23
|
+
'parent-font-size'?: number;
|
|
24
|
+
'parent-width'?: number;
|
|
25
|
+
'parent-height'?: number;
|
|
26
|
+
'enable-animation'?: boolean;
|
|
27
|
+
bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
28
|
+
bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
29
|
+
bindtouchend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
30
|
+
bindtransitionend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
31
|
+
catchtransitionend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
32
|
+
}
|
|
33
|
+
declare const _View: import("react").ForwardRefExoticComponent<_ViewProps & import("react").RefAttributes<HandlerRef<View, _ViewProps>>>;
|
|
34
|
+
export default _View;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { WebView } from 'react-native-webview';
|
|
3
|
+
import { HandlerRef } from './useNodesRef';
|
|
4
|
+
type OnMessageCallbackEvent = {
|
|
5
|
+
detail: {
|
|
6
|
+
data: any[];
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
type CommonCallbackEvent = {
|
|
10
|
+
detail: {
|
|
11
|
+
src?: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
interface WebViewProps {
|
|
15
|
+
src?: string;
|
|
16
|
+
bindmessage?: (event: OnMessageCallbackEvent) => void;
|
|
17
|
+
bindload?: (event: CommonCallbackEvent) => void;
|
|
18
|
+
binderror?: (event: CommonCallbackEvent) => void;
|
|
19
|
+
[x: string]: any;
|
|
20
|
+
}
|
|
21
|
+
declare const _WebView: import("react").ForwardRefExoticComponent<Omit<WebViewProps, "ref"> & import("react").RefAttributes<HandlerRef<WebView<{}>, WebViewProps>>>;
|
|
22
|
+
export default _WebView;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare function useInnerHeaderHeight(pageConfig: PageConfig): number;
|
|
3
|
+
export interface MpxNavProps {
|
|
4
|
+
pageConfig: PageConfig;
|
|
5
|
+
navigation: any;
|
|
6
|
+
}
|
|
7
|
+
declare const MpxNav: import("react").MemoExoticComponent<({ pageConfig, navigation }: MpxNavProps) => import("react").JSX.Element>;
|
|
8
|
+
export default MpxNav;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/* eslint-disable space-before-function-paren */
|
|
2
|
+
import { useState, useMemo, memo } from 'react';
|
|
3
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
4
|
+
import { StatusBar, processColor, TouchableWithoutFeedback, Image, View, StyleSheet, Text } from 'react-native';
|
|
5
|
+
import { useNavShared } from './useNavShared';
|
|
6
|
+
function convertToHex(color) {
|
|
7
|
+
try {
|
|
8
|
+
const intColor = processColor(color);
|
|
9
|
+
if (intColor === null || intColor === undefined) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
// 将32位整数颜色值转换为RGBA
|
|
13
|
+
const r = (intColor >> 16) & 255;
|
|
14
|
+
const g = (intColor >> 8) & 255;
|
|
15
|
+
const b = intColor & 255;
|
|
16
|
+
// 转换为十六进制
|
|
17
|
+
const hexR = r.toString(16).padStart(2, '0');
|
|
18
|
+
const hexG = g.toString(16).padStart(2, '0');
|
|
19
|
+
const hexB = b.toString(16).padStart(2, '0');
|
|
20
|
+
return `#${hexR}${hexG}${hexB}`;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const titleHeight = 44;
|
|
27
|
+
export function useInnerHeaderHeight(pageConfig) {
|
|
28
|
+
const safeArea = useSafeAreaInsets();
|
|
29
|
+
if (pageConfig.navigationStyle === 'custom') {
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const safeAreaTop = safeArea?.top || 0;
|
|
34
|
+
const headerHeight = safeAreaTop + titleHeight;
|
|
35
|
+
return headerHeight;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const styles = StyleSheet.create({
|
|
39
|
+
header: {
|
|
40
|
+
elevation: 3
|
|
41
|
+
},
|
|
42
|
+
headerContent: {
|
|
43
|
+
flexDirection: 'row',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
justifyContent: 'center'
|
|
46
|
+
},
|
|
47
|
+
backButton: {
|
|
48
|
+
position: 'absolute',
|
|
49
|
+
height: '100%',
|
|
50
|
+
width: 40,
|
|
51
|
+
left: 0,
|
|
52
|
+
top: 0,
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
justifyContent: 'center'
|
|
55
|
+
},
|
|
56
|
+
backButtonImage: {
|
|
57
|
+
width: 22,
|
|
58
|
+
height: 22
|
|
59
|
+
},
|
|
60
|
+
title: {
|
|
61
|
+
fontSize: 17,
|
|
62
|
+
fontWeight: 600,
|
|
63
|
+
width: '60%',
|
|
64
|
+
textAlign: 'center'
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const NavColor = {
|
|
68
|
+
White: '#ffffff',
|
|
69
|
+
Black: '#000000'
|
|
70
|
+
};
|
|
71
|
+
// navigationBarTextStyle 只支持黑白 'white'/'black
|
|
72
|
+
const validBarTextStyle = (textStyle) => {
|
|
73
|
+
const textStyleColor = convertToHex(textStyle);
|
|
74
|
+
if (textStyle && textStyleColor && [NavColor.White, NavColor.Black].includes(textStyleColor)) {
|
|
75
|
+
return textStyleColor;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return NavColor.White;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const BACK_ICON = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABICAYAAACqT5alAAAA2UlEQVR4nO3bMQrCUBRE0Yla6AYEN2nnBrTL+izcitW3MRDkEUWSvPzJvfCqgMwhZbAppWhNbbIHzB1g9wATERFRVyvpkj1irlpJ5X326D7WHh1hbdFD2CLpLmmftm7kfsEe09aNHFiBrT+wAlt/YAW2/sAKbP2BFdj6Ayuwy+ufz6XPL893krZ//O6iu2n4LT8kndLWTRTo4EC7BDo40C6BDg60S6CDA+0S6OBAuwQ6uNWiD2nrJmoIfU7cNWkR2hbb1UfbY7uuWhGWiIg+a/iHuHmA3QPs3gu4JW9Gan+OJAAAAABJRU5ErkJggg==';
|
|
82
|
+
const MpxNav = memo(({ pageConfig, navigation }) => {
|
|
83
|
+
const [innerPageConfig, setPageConfig] = useState(pageConfig || {});
|
|
84
|
+
const [customNav] = useNavShared();
|
|
85
|
+
const safeAreaTop = useSafeAreaInsets()?.top || 0;
|
|
86
|
+
navigation.setPageConfig = (config) => {
|
|
87
|
+
setPageConfig(Object.assign({}, innerPageConfig, config));
|
|
88
|
+
};
|
|
89
|
+
const isCustom = innerPageConfig.navigationStyle === 'custom';
|
|
90
|
+
const navigationBarTextStyle = useMemo(() => validBarTextStyle(innerPageConfig.navigationBarTextStyle), [innerPageConfig.navigationBarTextStyle]);
|
|
91
|
+
// 状态栏的颜色
|
|
92
|
+
const statusBarElement = (<StatusBar translucent backgroundColor='transparent' barStyle={navigationBarTextStyle === NavColor.White ? 'light-content' : 'dark-content'}></StatusBar>);
|
|
93
|
+
if (isCustom)
|
|
94
|
+
return (<>
|
|
95
|
+
{statusBarElement}
|
|
96
|
+
{customNav}
|
|
97
|
+
</>);
|
|
98
|
+
// 假设是栈导航,获取栈的长度
|
|
99
|
+
const stackLength = navigation.getState()?.routes?.length;
|
|
100
|
+
const onStackTopBack = mpxGlobal?.__mpx?.config?.rnConfig?.onStackTopBack;
|
|
101
|
+
const isHandleStackTopBack = typeof onStackTopBack === 'function';
|
|
102
|
+
// 回退按钮与图标
|
|
103
|
+
// prettier-ignore
|
|
104
|
+
const backElement = stackLength > 1 || isHandleStackTopBack
|
|
105
|
+
? (<TouchableWithoutFeedback onPress={() => {
|
|
106
|
+
if (stackLength <= 1 && isHandleStackTopBack) {
|
|
107
|
+
onStackTopBack();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
navigation.goBack();
|
|
111
|
+
}}>
|
|
112
|
+
<View style={[styles.backButton]}>
|
|
113
|
+
<Image style={[styles.backButtonImage, { tintColor: navigationBarTextStyle }]} source={{ uri: BACK_ICON }}></Image>
|
|
114
|
+
</View>
|
|
115
|
+
</TouchableWithoutFeedback>)
|
|
116
|
+
: null;
|
|
117
|
+
return (<View style={[
|
|
118
|
+
styles.header,
|
|
119
|
+
{
|
|
120
|
+
paddingTop: safeAreaTop,
|
|
121
|
+
backgroundColor: innerPageConfig.navigationBarBackgroundColor || '#000000'
|
|
122
|
+
}
|
|
123
|
+
]}>
|
|
124
|
+
{statusBarElement}
|
|
125
|
+
{/* TODO: 确定 height 的有效性 */}
|
|
126
|
+
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
|
|
127
|
+
{/* @ts-expect-error */}
|
|
128
|
+
<View style={styles.headerContent} height={titleHeight}>
|
|
129
|
+
{backElement}
|
|
130
|
+
<Text style={[styles.title, { color: navigationBarTextStyle }]} numberOfLines={1}>
|
|
131
|
+
{innerPageConfig.navigationBarTitleText?.trim() || ''}
|
|
132
|
+
</Text>
|
|
133
|
+
</View>
|
|
134
|
+
</View>);
|
|
135
|
+
});
|
|
136
|
+
MpxNav.displayName = 'MpxNav';
|
|
137
|
+
export default MpxNav;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
interface Token {
|
|
2
|
+
type: string;
|
|
3
|
+
value: string | number;
|
|
4
|
+
}
|
|
5
|
+
interface ExpressionNode {
|
|
6
|
+
type: 'NUMBER';
|
|
7
|
+
value: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class ExpressionParser {
|
|
10
|
+
private tokens;
|
|
11
|
+
private formatter;
|
|
12
|
+
private functions;
|
|
13
|
+
private current;
|
|
14
|
+
constructor(input: string, formatter?: (val: string) => number, functions?: {
|
|
15
|
+
[key: string]: (...args: number[]) => number;
|
|
16
|
+
});
|
|
17
|
+
tokenize(input: string): Token[];
|
|
18
|
+
parse(): ExpressionNode;
|
|
19
|
+
private expression;
|
|
20
|
+
private term;
|
|
21
|
+
private factor;
|
|
22
|
+
private parseArguments;
|
|
23
|
+
private applyOperator;
|
|
24
|
+
private applyFunction;
|
|
25
|
+
}
|
|
26
|
+
interface FuncInfo {
|
|
27
|
+
start: number;
|
|
28
|
+
end: number;
|
|
29
|
+
args: string[];
|
|
30
|
+
}
|
|
31
|
+
export declare function parseFunc(str: string, funcName: string): FuncInfo[];
|
|
32
|
+
export declare class ReplaceSource {
|
|
33
|
+
private _source;
|
|
34
|
+
private _replacements;
|
|
35
|
+
constructor(source: string);
|
|
36
|
+
replace(start: number, end: number, content: string): void;
|
|
37
|
+
source(): string;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { MutableRefObject } from 'react';
|
|
2
|
+
import type { NativeSyntheticEvent } from 'react-native';
|
|
3
|
+
import { ExtendedViewStyle } from './types/common';
|
|
4
|
+
import type { _ViewProps } from './mpx-view';
|
|
5
|
+
type AnimatedOption = {
|
|
6
|
+
duration: number;
|
|
7
|
+
delay: number;
|
|
8
|
+
useNativeDriver: boolean;
|
|
9
|
+
timingFunction: 'linear' | 'ease' | 'ease-in' | 'ease-in-out' | 'ease-out';
|
|
10
|
+
transformOrigin: string;
|
|
11
|
+
};
|
|
12
|
+
export type AnimationStepItem = {
|
|
13
|
+
animatedOption: AnimatedOption;
|
|
14
|
+
rules: Map<string, number | string>;
|
|
15
|
+
transform: Map<string, number>;
|
|
16
|
+
};
|
|
17
|
+
export type AnimationProp = {
|
|
18
|
+
id: number;
|
|
19
|
+
actions: AnimationStepItem[];
|
|
20
|
+
};
|
|
21
|
+
export default function useAnimationHooks<T, P>(props: _ViewProps & {
|
|
22
|
+
enableAnimation?: boolean;
|
|
23
|
+
layoutRef: MutableRefObject<any>;
|
|
24
|
+
transitionend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
25
|
+
}): {
|
|
26
|
+
enableStyleAnimation: boolean;
|
|
27
|
+
animationStyle?: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
enableStyleAnimation: true;
|
|
30
|
+
animationStyle: ExtendedViewStyle;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RefObject, ForwardedRef } from 'react';
|
|
2
|
+
type Obj = Record<string, any>;
|
|
3
|
+
export type HandlerRef<T, P> = {
|
|
4
|
+
getNodeInstance(): {
|
|
5
|
+
props: RefObject<P>;
|
|
6
|
+
nodeRef: RefObject<T>;
|
|
7
|
+
instance: Obj;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export default function useNodesRef<T, P>(props: P, ref: ForwardedRef<HandlerRef<T, P>>, nodeRef: RefObject<T>, instance?: Obj): void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { ReactNode, ReactElement, Dispatch, SetStateAction, MutableRefObject } from 'react';
|
|
2
|
+
import { LayoutChangeEvent, TextStyle, ImageProps } from 'react-native';
|
|
3
|
+
import { FastImageProps } from '@d11/react-native-fast-image';
|
|
4
|
+
import type { AnyFunc } from './types/common';
|
|
5
|
+
export declare const TEXT_STYLE_REGEX: RegExp;
|
|
6
|
+
export declare const PERCENT_REGEX: RegExp;
|
|
7
|
+
export declare const URL_REGEX: RegExp;
|
|
8
|
+
export declare const SVG_REGEXP: RegExp;
|
|
9
|
+
export declare const BACKGROUND_REGEX: RegExp;
|
|
10
|
+
export declare const TEXT_PROPS_REGEX: RegExp;
|
|
11
|
+
export declare const DEFAULT_FONT_SIZE = 16;
|
|
12
|
+
export declare const HIDDEN_STYLE: {
|
|
13
|
+
opacity: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const isIOS: boolean;
|
|
16
|
+
export declare const isAndroid: boolean;
|
|
17
|
+
export declare const isHarmony: boolean;
|
|
18
|
+
export declare function useNavigation(): Record<string, any> | undefined;
|
|
19
|
+
export declare function omit<T, K extends string>(obj: T, fields: K[]): Omit<T, K>;
|
|
20
|
+
/**
|
|
21
|
+
* 用法等同于 useEffect,但是会忽略首次执行,只在依赖更新时执行
|
|
22
|
+
*/
|
|
23
|
+
export declare const useUpdateEffect: (effect: any, deps: any) => void;
|
|
24
|
+
export declare const parseUrl: (cssUrl?: string) => string | undefined;
|
|
25
|
+
export declare const getRestProps: (transferProps?: any, originProps?: any, deletePropsKey?: any) => any;
|
|
26
|
+
export declare function isText(ele: ReactNode): ele is ReactElement;
|
|
27
|
+
export declare function every(children: ReactNode, callback: (children: ReactNode) => boolean): boolean;
|
|
28
|
+
type GroupData<T> = Record<string, Partial<T>>;
|
|
29
|
+
export declare function groupBy<T extends Record<string, any>>(obj: T, callback: (key: string, val: T[keyof T]) => string, group?: GroupData<T>): GroupData<T>;
|
|
30
|
+
export declare function splitStyle<T extends Record<string, any>>(styleObj: T): {
|
|
31
|
+
textStyle?: Partial<T>;
|
|
32
|
+
backgroundStyle?: Partial<T>;
|
|
33
|
+
innerStyle?: Partial<T>;
|
|
34
|
+
};
|
|
35
|
+
interface TransformStyleConfig {
|
|
36
|
+
enableVar?: boolean;
|
|
37
|
+
externalVarContext?: Record<string, any>;
|
|
38
|
+
parentFontSize?: number;
|
|
39
|
+
parentWidth?: number;
|
|
40
|
+
parentHeight?: number;
|
|
41
|
+
}
|
|
42
|
+
export declare function useTransformStyle(styleObj: Record<string, any> | undefined, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight }: TransformStyleConfig): {
|
|
43
|
+
hasVarDec: boolean;
|
|
44
|
+
varContextRef: MutableRefObject<{}>;
|
|
45
|
+
setWidth: Dispatch<SetStateAction<number>>;
|
|
46
|
+
setHeight: Dispatch<SetStateAction<number>>;
|
|
47
|
+
normalStyle: Record<string, any>;
|
|
48
|
+
hasSelfPercent: boolean;
|
|
49
|
+
hasPositionFixed: boolean;
|
|
50
|
+
};
|
|
51
|
+
export interface VisitorArg {
|
|
52
|
+
target: Record<string, any>;
|
|
53
|
+
key: string;
|
|
54
|
+
value: any;
|
|
55
|
+
keyPath: Array<string>;
|
|
56
|
+
}
|
|
57
|
+
export declare function traverseStyle(styleObj: Record<string, any>, visitors: Array<(arg: VisitorArg) => void>): void;
|
|
58
|
+
export declare function setStyle(styleObj: Record<string, any>, keyPath: Array<string>, setter: (arg: VisitorArg) => void): void;
|
|
59
|
+
export declare function splitProps<T extends Record<string, any>>(props: T): {
|
|
60
|
+
textProps?: Partial<T>;
|
|
61
|
+
innerProps?: Partial<T>;
|
|
62
|
+
};
|
|
63
|
+
interface LayoutConfig {
|
|
64
|
+
props: Record<string, any>;
|
|
65
|
+
hasSelfPercent: boolean;
|
|
66
|
+
setWidth?: Dispatch<SetStateAction<number>>;
|
|
67
|
+
setHeight?: Dispatch<SetStateAction<number>>;
|
|
68
|
+
onLayout?: (event?: LayoutChangeEvent) => void;
|
|
69
|
+
nodeRef: React.RefObject<any>;
|
|
70
|
+
}
|
|
71
|
+
export declare const useLayout: ({ props, hasSelfPercent, setWidth, setHeight, onLayout, nodeRef }: LayoutConfig) => {
|
|
72
|
+
layoutRef: MutableRefObject<{}>;
|
|
73
|
+
layoutStyle: {};
|
|
74
|
+
layoutProps: Record<string, any>;
|
|
75
|
+
};
|
|
76
|
+
export interface WrapChildrenConfig {
|
|
77
|
+
hasVarDec: boolean;
|
|
78
|
+
varContext?: Record<string, any>;
|
|
79
|
+
textStyle?: TextStyle;
|
|
80
|
+
textProps?: Record<string, any>;
|
|
81
|
+
}
|
|
82
|
+
export declare function wrapChildren(props: Record<string, any> | undefined, { hasVarDec, varContext, textStyle, textProps }: WrapChildrenConfig): any;
|
|
83
|
+
export declare const debounce: <T extends AnyFunc>(func: T, delay: number) => ((...args: Parameters<T>) => void) & {
|
|
84
|
+
clear: () => void;
|
|
85
|
+
};
|
|
86
|
+
export declare const useDebounceCallback: <T extends AnyFunc>(func: T, delay: number) => ((...args: Parameters<T>) => void) & {
|
|
87
|
+
clear: () => void;
|
|
88
|
+
};
|
|
89
|
+
export declare const useStableCallback: <T extends AnyFunc | null | undefined>(callback: T) => T extends AnyFunc ? T : () => void;
|
|
90
|
+
export declare function usePrevious<T>(value: T): T | undefined;
|
|
91
|
+
export interface GestureHandler {
|
|
92
|
+
nodeRefs?: Array<{
|
|
93
|
+
getNodeInstance: () => {
|
|
94
|
+
nodeRef: unknown;
|
|
95
|
+
};
|
|
96
|
+
}>;
|
|
97
|
+
current?: unknown;
|
|
98
|
+
}
|
|
99
|
+
export declare function flatGesture(gestures?: Array<GestureHandler>): any[];
|
|
100
|
+
export declare const extendObject: {
|
|
101
|
+
<T extends {}, U>(target: T, source: U): T & U;
|
|
102
|
+
<T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
|
|
103
|
+
<T_2 extends {}, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
|
|
104
|
+
(target: object, ...sources: any[]): any;
|
|
105
|
+
};
|
|
106
|
+
export declare function getCurrentPage(pageId: number | null | undefined): any;
|
|
107
|
+
export declare function renderImage(imageProps: ImageProps | FastImageProps, enableFastImage?: boolean): ReactElement<ImageProps | FastImageProps, string | import("react").JSXElementConstructor<any>>;
|
|
108
|
+
export declare function pickStyle(styleObj: Record<string, any> | undefined, pickedKeys: Array<string>, callback?: (key: string, val: number | string) => number | string): Record<string, any>;
|
|
109
|
+
export declare function useHover({ enableHover, hoverStartTime, hoverStayTime, disabled }: {
|
|
110
|
+
enableHover: boolean;
|
|
111
|
+
hoverStartTime: number;
|
|
112
|
+
hoverStayTime: number;
|
|
113
|
+
disabled?: boolean;
|
|
114
|
+
}): {
|
|
115
|
+
isHover: boolean;
|
|
116
|
+
gesture?: undefined;
|
|
117
|
+
} | {
|
|
118
|
+
isHover: boolean;
|
|
119
|
+
gesture: import("react-native-gesture-handler/lib/typescript/handlers/gestures/panGesture").PanGesture;
|
|
120
|
+
};
|
|
121
|
+
export declare function useRunOnJSCallback(callbackMapRef: MutableRefObject<Record<string, AnyFunc>>): (key: string, ...args: any) => any;
|
|
122
|
+
export {};
|
|
@@ -95,13 +95,15 @@ export interface InputProps {
|
|
|
95
95
|
'selection-start'?: number
|
|
96
96
|
'selection-end'?: number
|
|
97
97
|
'placeholder-style'?: { color?: string }
|
|
98
|
-
'enable-offset'?: boolean
|
|
98
|
+
'enable-offset'?: boolean
|
|
99
99
|
'enable-var'?: boolean
|
|
100
100
|
'external-var-context'?: Record<string, any>
|
|
101
101
|
'parent-font-size'?: number
|
|
102
102
|
'parent-width'?: number
|
|
103
103
|
'parent-height'?: number
|
|
104
|
-
|
|
104
|
+
// 只有 RN 环境读取
|
|
105
|
+
'keyboard-type'?: string
|
|
106
|
+
'adjust-position': boolean
|
|
105
107
|
bindinput?: (evt: NativeSyntheticEvent<TextInputTextInputEventData> | unknown) => void
|
|
106
108
|
bindfocus?: (evt: NativeSyntheticEvent<TextInputFocusEventData> | unknown) => void
|
|
107
109
|
bindblur?: (evt: NativeSyntheticEvent<TextInputFocusEventData> | unknown) => void
|
|
@@ -118,11 +120,11 @@ export interface PrivateInputProps {
|
|
|
118
120
|
|
|
119
121
|
type FinalInputProps = InputProps & PrivateInputProps
|
|
120
122
|
|
|
121
|
-
const
|
|
122
|
-
text: '
|
|
123
|
+
const inputModeMap: Record<Type, string> = {
|
|
124
|
+
text: 'text',
|
|
123
125
|
number: 'numeric',
|
|
124
|
-
idcard: '
|
|
125
|
-
digit:
|
|
126
|
+
idcard: 'text',
|
|
127
|
+
digit: 'decimal'
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps>((props: FinalInputProps, ref): JSX.Element => {
|
|
@@ -150,6 +152,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
150
152
|
'parent-width': parentWidth,
|
|
151
153
|
'parent-height': parentHeight,
|
|
152
154
|
'adjust-position': adjustPosition = true,
|
|
155
|
+
'keyboard-type': originalKeyboardType,
|
|
153
156
|
bindinput,
|
|
154
157
|
bindfocus,
|
|
155
158
|
bindblur,
|
|
@@ -182,7 +185,6 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
182
185
|
return ''
|
|
183
186
|
}
|
|
184
187
|
|
|
185
|
-
const keyboardType = keyboardTypeMap[type]
|
|
186
188
|
const defaultValue = parseValue(value)
|
|
187
189
|
const textAlignVertical = multiline ? 'top' : 'auto'
|
|
188
190
|
|
|
@@ -280,8 +282,8 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
280
282
|
}
|
|
281
283
|
|
|
282
284
|
const setKeyboardAvoidContext = () => {
|
|
283
|
-
if (
|
|
284
|
-
keyboardAvoid.current = { cursorSpacing, ref: nodeRef }
|
|
285
|
+
if (keyboardAvoid) {
|
|
286
|
+
keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition }
|
|
285
287
|
}
|
|
286
288
|
}
|
|
287
289
|
|
|
@@ -295,20 +297,39 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
295
297
|
}
|
|
296
298
|
|
|
297
299
|
const onFocus = (evt: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
300
|
+
if (!keyboardAvoid?.current) {
|
|
301
|
+
setKeyboardAvoidContext()
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (bindfocus && keyboardAvoid?.current) {
|
|
305
|
+
const focusAction = () => {
|
|
306
|
+
bindfocus(
|
|
307
|
+
getCustomEvent(
|
|
308
|
+
'focus',
|
|
309
|
+
evt,
|
|
310
|
+
{
|
|
311
|
+
detail: {
|
|
312
|
+
value: tmpValue.current || '',
|
|
313
|
+
height: keyboardAvoid.current?.keyboardHeight,
|
|
314
|
+
},
|
|
315
|
+
layoutRef
|
|
316
|
+
},
|
|
317
|
+
props
|
|
318
|
+
)
|
|
319
|
+
)
|
|
320
|
+
if (keyboardAvoid.current?.onKeyboardShow) {
|
|
321
|
+
keyboardAvoid.current.onKeyboardShow = undefined
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (keyboardAvoid.current.keyboardHeight) {
|
|
325
|
+
// iOS: keyboard 获取高度时机 keyboardWillShow 在 input focus 之前,可以立即执行
|
|
326
|
+
focusAction()
|
|
327
|
+
} else {
|
|
328
|
+
// Android,Harmony: keyboard 获取高度时机 keyboardDidShow 在 input focus 之后,需要延迟回调
|
|
329
|
+
evt.persist()
|
|
330
|
+
keyboardAvoid.current.onKeyboardShow = focusAction
|
|
331
|
+
}
|
|
332
|
+
}
|
|
312
333
|
}
|
|
313
334
|
|
|
314
335
|
const onBlur = (evt: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
@@ -440,7 +461,8 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
440
461
|
ref: nodeRef,
|
|
441
462
|
style: extendObject({}, normalStyle, layoutStyle),
|
|
442
463
|
allowFontScaling,
|
|
443
|
-
|
|
464
|
+
inputMode: originalKeyboardType ? undefined : inputModeMap[type],
|
|
465
|
+
keyboardType: originalKeyboardType,
|
|
444
466
|
secureTextEntry: !!password,
|
|
445
467
|
defaultValue: defaultValue,
|
|
446
468
|
value: inputValue,
|