@mpxjs/webpack-plugin 2.10.3-beta.5 → 2.10.3-beta.7
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/runtime/components/react/dist/mpx-input.jsx +4 -0
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +23 -30
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +2 -2
- package/lib/runtime/components/react/mpx-input.tsx +7 -1
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +30 -41
- package/lib/runtime/components/react/mpx-swiper-item.tsx +2 -2
- package/package.json +1 -1
|
@@ -154,6 +154,9 @@ const Input = forwardRef((props, ref) => {
|
|
|
154
154
|
// sometimes the focus event occurs later than the keyboardWillShow event
|
|
155
155
|
setKeyboardAvoidContext();
|
|
156
156
|
};
|
|
157
|
+
const onTouchEnd = (evt) => {
|
|
158
|
+
evt.nativeEvent.origin = 'input';
|
|
159
|
+
};
|
|
157
160
|
const onFocus = (evt) => {
|
|
158
161
|
setKeyboardAvoidContext();
|
|
159
162
|
bindfocus && bindfocus(getCustomEvent('focus', evt, {
|
|
@@ -267,6 +270,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
267
270
|
multiline: !!multiline
|
|
268
271
|
}, !!multiline && confirmType === 'return' ? {} : { enterKeyHint: confirmType }, layoutProps, {
|
|
269
272
|
onTouchStart,
|
|
273
|
+
onTouchEnd,
|
|
270
274
|
onFocus,
|
|
271
275
|
onBlur,
|
|
272
276
|
onChange,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React, { useContext, useEffect
|
|
2
|
-
import { Keyboard,
|
|
1
|
+
import React, { useContext, useEffect } from 'react';
|
|
2
|
+
import { Keyboard, View, Platform } from 'react-native';
|
|
3
3
|
import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing } from 'react-native-reanimated';
|
|
4
|
-
import { GestureDetector, Gesture } from 'react-native-gesture-handler';
|
|
5
4
|
import { KeyboardAvoidContext } from './context';
|
|
6
5
|
const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
7
6
|
const isIOS = Platform.OS === 'ios';
|
|
@@ -10,20 +9,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
10
9
|
const offset = useSharedValue(0);
|
|
11
10
|
const basic = useSharedValue('auto');
|
|
12
11
|
const keyboardAvoid = useContext(KeyboardAvoidContext);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return Gesture.Tap()
|
|
18
|
-
.onEnd(() => {
|
|
19
|
-
dismiss();
|
|
20
|
-
}).runOnJS(true);
|
|
21
|
-
}, []);
|
|
22
|
-
const animatedStyle = useAnimatedStyle(() => {
|
|
23
|
-
return Object.assign({
|
|
24
|
-
transform: [{ translateY: -offset.value }]
|
|
25
|
-
}, isIOS ? {} : { flexBasis: basic.value });
|
|
26
|
-
});
|
|
12
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
13
|
+
transform: [{ translateY: -offset.value }],
|
|
14
|
+
flexBasis: basic.value
|
|
15
|
+
}));
|
|
27
16
|
const resetKeyboard = () => {
|
|
28
17
|
if (keyboardAvoid?.current) {
|
|
29
18
|
keyboardAvoid.current = null;
|
|
@@ -31,6 +20,11 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
31
20
|
offset.value = withTiming(0, { duration, easing });
|
|
32
21
|
basic.value = 'auto';
|
|
33
22
|
};
|
|
23
|
+
const onTouchEnd = ({ nativeEvent }) => {
|
|
24
|
+
if (nativeEvent.origin !== 'input') {
|
|
25
|
+
Keyboard.isVisible() && Keyboard.dismiss();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
34
28
|
useEffect(() => {
|
|
35
29
|
let subscriptions = [];
|
|
36
30
|
if (isIOS) {
|
|
@@ -46,7 +40,12 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
46
40
|
const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
|
|
47
41
|
const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing);
|
|
48
42
|
const value = aboveOffset > 0 ? belowValue : aboveValue;
|
|
49
|
-
offset.value = withTiming(value, { duration, easing })
|
|
43
|
+
offset.value = withTiming(value, { duration, easing }, (finished) => {
|
|
44
|
+
if (finished) {
|
|
45
|
+
// Set flexBasic after animation to trigger re-layout and reset layout information
|
|
46
|
+
basic.value = '99.99%';
|
|
47
|
+
}
|
|
48
|
+
});
|
|
50
49
|
});
|
|
51
50
|
});
|
|
52
51
|
}),
|
|
@@ -68,11 +67,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
68
67
|
const value = aboveOffset > 0 ? belowValue : aboveValue;
|
|
69
68
|
offset.value = withTiming(value, { duration, easing }, (finished) => {
|
|
70
69
|
if (finished) {
|
|
71
|
-
|
|
72
|
-
* In the Android environment, the layout information is not synchronized after the animation,
|
|
73
|
-
* which results in the inability to correctly trigger element events.
|
|
74
|
-
* Here, we utilize flexBasic to proactively trigger a re-layout
|
|
75
|
-
*/
|
|
70
|
+
// Set flexBasic after animation to trigger re-layout and reset layout information
|
|
76
71
|
basic.value = '99.99%';
|
|
77
72
|
}
|
|
78
73
|
});
|
|
@@ -85,16 +80,14 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
85
80
|
subscriptions.forEach(subscription => subscription.remove());
|
|
86
81
|
};
|
|
87
82
|
}, [keyboardAvoid]);
|
|
88
|
-
return (<
|
|
89
|
-
<View style={
|
|
90
|
-
<Animated.View style={[
|
|
83
|
+
return (<View style={style} onTouchEnd={onTouchEnd}>
|
|
84
|
+
<Animated.View style={[
|
|
91
85
|
contentContainerStyle,
|
|
92
86
|
animatedStyle
|
|
93
87
|
]}>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
</GestureDetector>);
|
|
88
|
+
{children}
|
|
89
|
+
</Animated.View>
|
|
90
|
+
</View>);
|
|
98
91
|
};
|
|
99
92
|
KeyboardAvoidingView.displayName = 'MpxKeyboardAvoidingView';
|
|
100
93
|
export default KeyboardAvoidingView;
|
|
@@ -2,7 +2,7 @@ import Animated, { useAnimatedStyle, interpolate } from 'react-native-reanimated
|
|
|
2
2
|
import { forwardRef, useRef, useContext } from 'react';
|
|
3
3
|
import useInnerProps from './getInnerListeners';
|
|
4
4
|
import useNodesRef from './useNodesRef'; // 引入辅助函数
|
|
5
|
-
import { useTransformStyle, splitStyle, splitProps, wrapChildren, useLayout } from './utils';
|
|
5
|
+
import { useTransformStyle, splitStyle, splitProps, wrapChildren, useLayout, isHarmony } from './utils';
|
|
6
6
|
import { SwiperContext } from './context';
|
|
7
7
|
const _SwiperItem = forwardRef((props, ref) => {
|
|
8
8
|
const { 'enable-var': enableVar, 'external-var-context': externalVarContext, style, customStyle, itemIndex } = props;
|
|
@@ -30,7 +30,7 @@ const _SwiperItem = forwardRef((props, ref) => {
|
|
|
30
30
|
'style'
|
|
31
31
|
], { layoutRef });
|
|
32
32
|
const itemAnimatedStyle = useAnimatedStyle(() => {
|
|
33
|
-
if (!step.value)
|
|
33
|
+
if (!step.value && !isHarmony)
|
|
34
34
|
return {};
|
|
35
35
|
const inputRange = [step.value, 0];
|
|
36
36
|
const outputRange = [0.7, 1];
|
|
@@ -51,7 +51,8 @@ import {
|
|
|
51
51
|
TextInputSelectionChangeEventData,
|
|
52
52
|
TextInputFocusEventData,
|
|
53
53
|
TextInputChangeEventData,
|
|
54
|
-
TextInputSubmitEditingEventData
|
|
54
|
+
TextInputSubmitEditingEventData,
|
|
55
|
+
NativeTouchEvent
|
|
55
56
|
} from 'react-native'
|
|
56
57
|
import { warn } from '@mpxjs/utils'
|
|
57
58
|
import { useUpdateEffect, useTransformStyle, useLayout, extendObject } from './utils'
|
|
@@ -292,6 +293,10 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
292
293
|
setKeyboardAvoidContext()
|
|
293
294
|
}
|
|
294
295
|
|
|
296
|
+
const onTouchEnd = (evt: NativeSyntheticEvent<NativeTouchEvent & { origin?: string }>) => {
|
|
297
|
+
evt.nativeEvent.origin = 'input'
|
|
298
|
+
}
|
|
299
|
+
|
|
295
300
|
const onFocus = (evt: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
296
301
|
setKeyboardAvoidContext()
|
|
297
302
|
bindfocus && bindfocus(
|
|
@@ -455,6 +460,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
455
460
|
layoutProps,
|
|
456
461
|
{
|
|
457
462
|
onTouchStart,
|
|
463
|
+
onTouchEnd,
|
|
458
464
|
onFocus,
|
|
459
465
|
onBlur,
|
|
460
466
|
onChange,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React, { ReactNode, useContext, useEffect
|
|
2
|
-
import { DimensionValue, EmitterSubscription, Keyboard, Platform,
|
|
3
|
-
import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing
|
|
4
|
-
import { GestureDetector, Gesture } from 'react-native-gesture-handler'
|
|
1
|
+
import React, { ReactNode, useContext, useEffect } from 'react'
|
|
2
|
+
import { DimensionValue, EmitterSubscription, Keyboard, View, ViewStyle, Platform, NativeSyntheticEvent, NativeTouchEvent } from 'react-native'
|
|
3
|
+
import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing } from 'react-native-reanimated'
|
|
5
4
|
import { KeyboardAvoidContext } from './context'
|
|
6
5
|
|
|
7
6
|
type KeyboardAvoidViewProps = {
|
|
@@ -19,25 +18,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
19
18
|
const basic = useSharedValue('auto')
|
|
20
19
|
const keyboardAvoid = useContext(KeyboardAvoidContext)
|
|
21
20
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const gesture = useMemo(() => {
|
|
27
|
-
return Gesture.Tap()
|
|
28
|
-
.onEnd(() => {
|
|
29
|
-
dismiss()
|
|
30
|
-
}).runOnJS(true)
|
|
31
|
-
}, [])
|
|
32
|
-
|
|
33
|
-
const animatedStyle = useAnimatedStyle(() => {
|
|
34
|
-
return Object.assign(
|
|
35
|
-
{
|
|
36
|
-
transform: [{ translateY: -offset.value }]
|
|
37
|
-
},
|
|
38
|
-
isIOS ? {} : { flexBasis: basic.value as DimensionValue }
|
|
39
|
-
)
|
|
40
|
-
})
|
|
21
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
22
|
+
transform: [{ translateY: -offset.value }],
|
|
23
|
+
flexBasis: basic.value as DimensionValue
|
|
24
|
+
}))
|
|
41
25
|
|
|
42
26
|
const resetKeyboard = () => {
|
|
43
27
|
if (keyboardAvoid?.current) {
|
|
@@ -47,6 +31,12 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
47
31
|
basic.value = 'auto'
|
|
48
32
|
}
|
|
49
33
|
|
|
34
|
+
const onTouchEnd = ({ nativeEvent }: NativeSyntheticEvent<NativeTouchEvent & { origin?: string }>) => {
|
|
35
|
+
if (nativeEvent.origin !== 'input') {
|
|
36
|
+
Keyboard.isVisible() && Keyboard.dismiss()
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
50
40
|
useEffect(() => {
|
|
51
41
|
let subscriptions: EmitterSubscription[] = []
|
|
52
42
|
|
|
@@ -62,7 +52,12 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
62
52
|
const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing
|
|
63
53
|
const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing)
|
|
64
54
|
const value = aboveOffset > 0 ? belowValue : aboveValue
|
|
65
|
-
offset.value = withTiming(value, { duration, easing })
|
|
55
|
+
offset.value = withTiming(value, { duration, easing }, (finished) => {
|
|
56
|
+
if (finished) {
|
|
57
|
+
// Set flexBasic after animation to trigger re-layout and reset layout information
|
|
58
|
+
basic.value = '99.99%'
|
|
59
|
+
}
|
|
60
|
+
})
|
|
66
61
|
})
|
|
67
62
|
})
|
|
68
63
|
}),
|
|
@@ -82,11 +77,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
82
77
|
const value = aboveOffset > 0 ? belowValue : aboveValue
|
|
83
78
|
offset.value = withTiming(value, { duration, easing }, (finished) => {
|
|
84
79
|
if (finished) {
|
|
85
|
-
|
|
86
|
-
* In the Android environment, the layout information is not synchronized after the animation,
|
|
87
|
-
* which results in the inability to correctly trigger element events.
|
|
88
|
-
* Here, we utilize flexBasic to proactively trigger a re-layout
|
|
89
|
-
*/
|
|
80
|
+
// Set flexBasic after animation to trigger re-layout and reset layout information
|
|
90
81
|
basic.value = '99.99%'
|
|
91
82
|
}
|
|
92
83
|
})
|
|
@@ -102,18 +93,16 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
102
93
|
}, [keyboardAvoid])
|
|
103
94
|
|
|
104
95
|
return (
|
|
105
|
-
<
|
|
106
|
-
<View
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
</View>
|
|
116
|
-
</GestureDetector>
|
|
96
|
+
<View style={style} onTouchEnd={onTouchEnd}>
|
|
97
|
+
<Animated.View
|
|
98
|
+
style={[
|
|
99
|
+
contentContainerStyle,
|
|
100
|
+
animatedStyle
|
|
101
|
+
]}
|
|
102
|
+
>
|
|
103
|
+
{children}
|
|
104
|
+
</Animated.View>
|
|
105
|
+
</View>
|
|
117
106
|
)
|
|
118
107
|
}
|
|
119
108
|
|
|
@@ -3,7 +3,7 @@ import Animated, { useAnimatedStyle, interpolate, SharedValue } from 'react-nati
|
|
|
3
3
|
import { ReactNode, forwardRef, useRef, useContext } from 'react'
|
|
4
4
|
import useInnerProps from './getInnerListeners'
|
|
5
5
|
import useNodesRef, { HandlerRef } from './useNodesRef' // 引入辅助函数
|
|
6
|
-
import { useTransformStyle, splitStyle, splitProps, wrapChildren, useLayout } from './utils'
|
|
6
|
+
import { useTransformStyle, splitStyle, splitProps, wrapChildren, useLayout, isHarmony } from './utils'
|
|
7
7
|
import { SwiperContext } from './context'
|
|
8
8
|
|
|
9
9
|
interface SwiperItemProps {
|
|
@@ -73,7 +73,7 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp
|
|
|
73
73
|
'style'
|
|
74
74
|
], { layoutRef })
|
|
75
75
|
const itemAnimatedStyle = useAnimatedStyle(() => {
|
|
76
|
-
if (!step.value) return {}
|
|
76
|
+
if (!step.value && !isHarmony) return {}
|
|
77
77
|
const inputRange = [step.value, 0]
|
|
78
78
|
const outputRange = [0.7, 1]
|
|
79
79
|
// 实现元素的宽度跟随step从0到真实宽度,且不能触发重新渲染整个组件,通过AnimatedStyle的方式实现
|