@mpxjs/webpack-plugin 2.8.25-alpha.22 → 2.8.25-alpha.23
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/template-compiler/compiler.js +9 -4
- package/package.json +1 -1
- package/lib/runtime/components/react/dist/KeyboardAvoidingView.jsx +0 -89
- package/lib/runtime/components/react/dist/context.js +0 -14
- package/lib/runtime/components/react/dist/event.config.js +0 -27
- package/lib/runtime/components/react/dist/getInnerListeners.js +0 -262
- package/lib/runtime/components/react/dist/mpx-button.jsx +0 -271
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.js +0 -60
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.js +0 -15
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.js +0 -84
- package/lib/runtime/components/react/dist/mpx-canvas/Image.js +0 -87
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.js +0 -15
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.js +0 -28
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +0 -341
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +0 -236
- package/lib/runtime/components/react/dist/mpx-canvas/utils.jsx +0 -89
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +0 -90
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +0 -131
- package/lib/runtime/components/react/dist/mpx-form.jsx +0 -68
- package/lib/runtime/components/react/dist/mpx-icon/icons/cancel.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/clear.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/download.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/info.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/search.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/success.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/success_no_circle.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/waiting.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/icons/warn.png +0 -0
- package/lib/runtime/components/react/dist/mpx-icon/index.jsx +0 -50
- package/lib/runtime/components/react/dist/mpx-image.jsx +0 -292
- package/lib/runtime/components/react/dist/mpx-input.jsx +0 -292
- package/lib/runtime/components/react/dist/mpx-label.jsx +0 -52
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +0 -32
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +0 -468
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +0 -33
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +0 -74
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +0 -141
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +0 -147
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +0 -99
- package/lib/runtime/components/react/dist/mpx-picker/regionData.js +0 -6099
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +0 -81
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +0 -242
- package/lib/runtime/components/react/dist/mpx-picker/type.js +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +0 -35
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +0 -193
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +0 -125
- package/lib/runtime/components/react/dist/mpx-portal/index.jsx +0 -30
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.jsx +0 -112
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +0 -41
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +0 -86
- package/lib/runtime/components/react/dist/mpx-radio.jsx +0 -140
- package/lib/runtime/components/react/dist/mpx-rich-text/html.js +0 -39
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +0 -62
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +0 -17
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +0 -372
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +0 -11
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +0 -59
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +0 -671
- package/lib/runtime/components/react/dist/mpx-switch.jsx +0 -97
- package/lib/runtime/components/react/dist/mpx-text.jsx +0 -41
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +0 -40
- package/lib/runtime/components/react/dist/mpx-video.jsx +0 -248
- package/lib/runtime/components/react/dist/mpx-view.jsx +0 -611
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +0 -289
- package/lib/runtime/components/react/dist/parser.js +0 -218
- package/lib/runtime/components/react/dist/pickerFaces.js +0 -76
- package/lib/runtime/components/react/dist/pickerVIewContext.js +0 -14
- package/lib/runtime/components/react/dist/pickerViewIndicator.jsx +0 -23
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +0 -18
- package/lib/runtime/components/react/dist/useAnimationHooks.js +0 -346
- package/lib/runtime/components/react/dist/useNodesRef.js +0 -16
- package/lib/runtime/components/react/dist/utils.jsx +0 -599
|
@@ -1975,8 +1975,13 @@ function processAtMode (el) {
|
|
|
1975
1975
|
el._atModeStatus = 'match'
|
|
1976
1976
|
}
|
|
1977
1977
|
} else {
|
|
1978
|
-
|
|
1979
|
-
|
|
1978
|
+
if (replacedAttrName === 'mpxTagName') {
|
|
1979
|
+
// mpxTagName 特殊标签,需要做转换保留处理
|
|
1980
|
+
addAttrs(el, [processedAttr])
|
|
1981
|
+
} else {
|
|
1982
|
+
// 如果命中了指定的mode,则先存在el上,等跑完转换后再挂回去
|
|
1983
|
+
el.noTransAttrs ? el.noTransAttrs.push(processedAttr) : el.noTransAttrs = [processedAttr]
|
|
1984
|
+
}
|
|
1980
1985
|
}
|
|
1981
1986
|
// 命中mode,命中env,完成匹配,直接退出
|
|
1982
1987
|
break
|
|
@@ -2041,6 +2046,8 @@ function processElement (el, root, options, meta) {
|
|
|
2041
2046
|
return
|
|
2042
2047
|
}
|
|
2043
2048
|
|
|
2049
|
+
processMpxTagName(el)
|
|
2050
|
+
|
|
2044
2051
|
if (rulesRunner && el._atModeStatus !== 'match') {
|
|
2045
2052
|
currentEl = el
|
|
2046
2053
|
rulesRunner(el)
|
|
@@ -2050,8 +2057,6 @@ function processElement (el, root, options, meta) {
|
|
|
2050
2057
|
|
|
2051
2058
|
processDuplicateAttrsList(el)
|
|
2052
2059
|
|
|
2053
|
-
processMpxTagName(el)
|
|
2054
|
-
|
|
2055
2060
|
processInjectWxs(el, meta)
|
|
2056
2061
|
|
|
2057
2062
|
const transAli = mode === 'ali' && srcMode === 'wx'
|
package/package.json
CHANGED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useEffect } from 'react';
|
|
2
|
-
import { Keyboard, Platform, View } from 'react-native';
|
|
3
|
-
import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing } from 'react-native-reanimated';
|
|
4
|
-
import { KeyboardAvoidContext } from './context';
|
|
5
|
-
import { extendObject } from './utils';
|
|
6
|
-
const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
7
|
-
const isIOS = Platform.OS === 'ios';
|
|
8
|
-
const duration = isIOS ? 250 : 300;
|
|
9
|
-
const easing = isIOS ? Easing.inOut(Easing.ease) : Easing.out(Easing.quad);
|
|
10
|
-
const offset = useSharedValue(0);
|
|
11
|
-
const basic = useSharedValue('auto');
|
|
12
|
-
const keyboardAvoid = useContext(KeyboardAvoidContext);
|
|
13
|
-
const animatedStyle = useAnimatedStyle(() => {
|
|
14
|
-
return Object.assign({
|
|
15
|
-
transform: [{ translateY: -offset.value }]
|
|
16
|
-
}, isIOS ? {} : { flexBasis: basic.value });
|
|
17
|
-
});
|
|
18
|
-
const resetKeyboard = () => {
|
|
19
|
-
keyboardAvoid?.current && extendObject(keyboardAvoid.current, {
|
|
20
|
-
cursorSpacing: 0,
|
|
21
|
-
ref: null
|
|
22
|
-
});
|
|
23
|
-
offset.value = withTiming(0, { duration, easing });
|
|
24
|
-
basic.value = 'auto';
|
|
25
|
-
};
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
let subscriptions = [];
|
|
28
|
-
if (isIOS) {
|
|
29
|
-
subscriptions = [
|
|
30
|
-
Keyboard.addListener('keyboardWillShow', (evt) => {
|
|
31
|
-
if (!keyboardAvoid?.current)
|
|
32
|
-
return;
|
|
33
|
-
const { endCoordinates } = evt;
|
|
34
|
-
const { ref, cursorSpacing = 0 } = keyboardAvoid.current;
|
|
35
|
-
setTimeout(() => {
|
|
36
|
-
ref?.current?.measure((x, y, width, height, pageX, pageY) => {
|
|
37
|
-
const aboveOffset = offset.value + pageY + height - endCoordinates.screenY;
|
|
38
|
-
const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
|
|
39
|
-
const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing);
|
|
40
|
-
const value = aboveOffset > 0 ? belowValue : aboveValue;
|
|
41
|
-
offset.value = withTiming(value, { duration, easing });
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
}),
|
|
45
|
-
Keyboard.addListener('keyboardWillHide', resetKeyboard)
|
|
46
|
-
];
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
subscriptions = [
|
|
50
|
-
Keyboard.addListener('keyboardDidShow', (evt) => {
|
|
51
|
-
if (!keyboardAvoid?.current)
|
|
52
|
-
return;
|
|
53
|
-
const { endCoordinates } = evt;
|
|
54
|
-
const { ref, cursorSpacing = 0 } = keyboardAvoid.current;
|
|
55
|
-
ref?.current?.measure((x, y, width, height, pageX, pageY) => {
|
|
56
|
-
const aboveOffset = pageY + height - endCoordinates.screenY;
|
|
57
|
-
const belowOffset = endCoordinates.height - aboveOffset;
|
|
58
|
-
const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
|
|
59
|
-
const belowValue = Math.min(belowOffset, cursorSpacing);
|
|
60
|
-
const value = aboveOffset > 0 ? belowValue : aboveValue;
|
|
61
|
-
offset.value = withTiming(value, { duration, easing }, (finished) => {
|
|
62
|
-
if (finished) {
|
|
63
|
-
/**
|
|
64
|
-
* In the Android environment, the layout information is not synchronized after the animation,
|
|
65
|
-
* which results in the inability to correctly trigger element events.
|
|
66
|
-
* Here, we utilize flexBasic to proactively trigger a re-layout
|
|
67
|
-
*/
|
|
68
|
-
basic.value = '99.99%';
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
}),
|
|
73
|
-
Keyboard.addListener('keyboardDidHide', resetKeyboard)
|
|
74
|
-
];
|
|
75
|
-
}
|
|
76
|
-
return () => {
|
|
77
|
-
subscriptions.forEach(subscription => subscription.remove());
|
|
78
|
-
};
|
|
79
|
-
}, [keyboardAvoid]);
|
|
80
|
-
return (<View style={style}>
|
|
81
|
-
<Animated.View style={[
|
|
82
|
-
contentContainerStyle,
|
|
83
|
-
animatedStyle
|
|
84
|
-
]}>
|
|
85
|
-
{children}
|
|
86
|
-
</Animated.View>
|
|
87
|
-
</View>);
|
|
88
|
-
};
|
|
89
|
-
export default KeyboardAvoidingView;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createContext } from 'react';
|
|
2
|
-
export const MovableAreaContext = createContext({ width: 0, height: 0 });
|
|
3
|
-
export const FormContext = createContext(null);
|
|
4
|
-
export const CheckboxGroupContext = createContext(null);
|
|
5
|
-
export const RadioGroupContext = createContext(null);
|
|
6
|
-
export const LabelContext = createContext(null);
|
|
7
|
-
export const PickerContext = createContext(null);
|
|
8
|
-
export const VarContext = createContext({});
|
|
9
|
-
export const IntersectionObserverContext = createContext(null);
|
|
10
|
-
export const RouteContext = createContext(null);
|
|
11
|
-
export const SwiperContext = createContext({});
|
|
12
|
-
export const KeyboardAvoidContext = createContext(null);
|
|
13
|
-
export const ScrollViewContext = createContext({ gestureRef: null });
|
|
14
|
-
export const PortalContext = createContext(null);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const eventConfigMap = {
|
|
2
|
-
bindtap: { bitFlag: '0', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd'] },
|
|
3
|
-
bindlongpress: { bitFlag: '1', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'] },
|
|
4
|
-
bindtouchstart: { bitFlag: '2', events: ['onTouchStart'] },
|
|
5
|
-
bindtouchmove: { bitFlag: '3', events: ['onTouchMove'] },
|
|
6
|
-
bindtouchend: { bitFlag: '4', events: ['onTouchEnd'] },
|
|
7
|
-
bindtouchcancel: { bitFlag: '5', events: ['onTouchCancel'] },
|
|
8
|
-
catchtap: { bitFlag: '6', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd'] },
|
|
9
|
-
catchlongpress: { bitFlag: '7', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'] },
|
|
10
|
-
catchtouchstart: { bitFlag: '8', events: ['onTouchStart'] },
|
|
11
|
-
catchtouchmove: { bitFlag: '9', events: ['onTouchMove'] },
|
|
12
|
-
catchtouchend: { bitFlag: 'a', events: ['onTouchEnd'] },
|
|
13
|
-
catchtouchcancel: { bitFlag: 'b', events: ['onTouchCancel'] },
|
|
14
|
-
'capture-bindtap': { bitFlag: 'c', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'] },
|
|
15
|
-
'capture-bindlongpress': { bitFlag: 'd', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'] },
|
|
16
|
-
'capture-bindtouchstart': { bitFlag: 'e', events: ['onTouchStartCapture'] },
|
|
17
|
-
'capture-bindtouchmove': { bitFlag: 'f', events: ['onTouchMoveCapture'] },
|
|
18
|
-
'capture-bindtouchend': { bitFlag: 'g', events: ['onTouchEndCapture'] },
|
|
19
|
-
'capture-bindtouchcancel': { bitFlag: 'h', events: ['onTouchCancelCapture'] },
|
|
20
|
-
'capture-catchtap': { bitFlag: 'i', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'] },
|
|
21
|
-
'capture-catchlongpress': { bitFlag: 'j', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'] },
|
|
22
|
-
'capture-catchtouchstart': { bitFlag: 'k', events: ['onTouchStartCapture'] },
|
|
23
|
-
'capture-catchtouchmove': { bitFlag: 'l', events: ['onTouchMoveCapture'] },
|
|
24
|
-
'capture-catchtouchend': { bitFlag: 'm', events: ['onTouchEndCapture'] },
|
|
25
|
-
'capture-catchtouchcancel': { bitFlag: 'n', events: ['onTouchCancelCapture'] }
|
|
26
|
-
};
|
|
27
|
-
export default eventConfigMap;
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import { useRef, useMemo } from 'react';
|
|
2
|
-
import { hasOwn, collectDataset } from '@mpxjs/utils';
|
|
3
|
-
import { omit, extendObject, useNavigation } from './utils';
|
|
4
|
-
import eventConfigMap from './event.config';
|
|
5
|
-
const globalEventState = {
|
|
6
|
-
needPress: true
|
|
7
|
-
};
|
|
8
|
-
const getTouchEvent = (type, event, props, config, navigation) => {
|
|
9
|
-
const { y: navigationY = 0 } = navigation?.layout || {};
|
|
10
|
-
const nativeEvent = event.nativeEvent;
|
|
11
|
-
const { timestamp, pageX, pageY, touches, changedTouches } = nativeEvent;
|
|
12
|
-
const { id } = props;
|
|
13
|
-
const { layoutRef } = config;
|
|
14
|
-
const currentTarget = extendObject({}, event.currentTarget, {
|
|
15
|
-
id: id || '',
|
|
16
|
-
dataset: collectDataset(props),
|
|
17
|
-
offsetLeft: layoutRef?.current?.offsetLeft || 0,
|
|
18
|
-
offsetTop: layoutRef?.current?.offsetTop || 0
|
|
19
|
-
});
|
|
20
|
-
const pendingProps = event._targetInst?.pendingProps || {};
|
|
21
|
-
const target = extendObject({}, event.target, {
|
|
22
|
-
id: pendingProps.parentId || pendingProps.nativeID || '',
|
|
23
|
-
dataset: collectDataset(pendingProps)
|
|
24
|
-
});
|
|
25
|
-
return extendObject({}, event, {
|
|
26
|
-
type,
|
|
27
|
-
timeStamp: timestamp,
|
|
28
|
-
currentTarget,
|
|
29
|
-
target,
|
|
30
|
-
detail: {
|
|
31
|
-
x: pageX,
|
|
32
|
-
y: pageY - navigationY
|
|
33
|
-
},
|
|
34
|
-
touches: touches.map((item) => {
|
|
35
|
-
return {
|
|
36
|
-
identifier: item.identifier,
|
|
37
|
-
pageX: item.pageX,
|
|
38
|
-
pageY: item.pageY - navigationY,
|
|
39
|
-
clientX: item.pageX,
|
|
40
|
-
clientY: item.pageY - navigationY
|
|
41
|
-
};
|
|
42
|
-
}),
|
|
43
|
-
changedTouches: changedTouches.map((item) => {
|
|
44
|
-
return {
|
|
45
|
-
identifier: item.identifier,
|
|
46
|
-
pageX: item.pageX,
|
|
47
|
-
pageY: item.pageY - navigationY,
|
|
48
|
-
clientX: item.pageX,
|
|
49
|
-
clientY: item.pageY - navigationY
|
|
50
|
-
};
|
|
51
|
-
}),
|
|
52
|
-
persist: event.persist,
|
|
53
|
-
stopPropagation: event.stopPropagation,
|
|
54
|
-
preventDefault: event.preventDefault
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
export const getCustomEvent = (type = '', oe = {}, { detail = {}, layoutRef }, props = {}) => {
|
|
58
|
-
const targetInfo = extendObject({}, oe.target, {
|
|
59
|
-
id: props.id || '',
|
|
60
|
-
dataset: collectDataset(props),
|
|
61
|
-
offsetLeft: layoutRef?.current?.offsetLeft || 0,
|
|
62
|
-
offsetTop: layoutRef?.current?.offsetTop || 0
|
|
63
|
-
});
|
|
64
|
-
return extendObject({}, oe, {
|
|
65
|
-
type,
|
|
66
|
-
detail,
|
|
67
|
-
target: targetInfo,
|
|
68
|
-
persist: oe.persist,
|
|
69
|
-
stopPropagation: oe.stopPropagation,
|
|
70
|
-
preventDefault: oe.preventDefault
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
function handleEmitEvent(events, type, oe, propsRef, config, navigation) {
|
|
74
|
-
events.forEach((event) => {
|
|
75
|
-
if (propsRef.current[event]) {
|
|
76
|
-
const match = /^(catch|capture-catch):?(.*?)(?:\.(.*))?$/.exec(event);
|
|
77
|
-
if (match) {
|
|
78
|
-
oe.stopPropagation();
|
|
79
|
-
}
|
|
80
|
-
propsRef.current[event](getTouchEvent(type, oe, propsRef.current, config, navigation));
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
function checkIsNeedPress(e, type, ref) {
|
|
85
|
-
const tapDetailInfo = ref.current.mpxPressInfo.detail || { x: 0, y: 0 };
|
|
86
|
-
const nativeEvent = e.nativeEvent;
|
|
87
|
-
const currentPageX = nativeEvent.changedTouches[0].pageX;
|
|
88
|
-
const currentPageY = nativeEvent.changedTouches[0].pageY;
|
|
89
|
-
if (Math.abs(currentPageX - tapDetailInfo.x) > 3 ||
|
|
90
|
-
Math.abs(currentPageY - tapDetailInfo.y) > 3) {
|
|
91
|
-
globalEventState.needPress = false;
|
|
92
|
-
ref.current.startTimer[type] &&
|
|
93
|
-
clearTimeout(ref.current.startTimer[type]);
|
|
94
|
-
ref.current.startTimer[type] = null;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function handleTouchstart(e, type, ref, propsRef, config, navigation) {
|
|
98
|
-
e.persist();
|
|
99
|
-
const bubbleTouchEvent = ['catchtouchstart', 'bindtouchstart'];
|
|
100
|
-
const bubblePressEvent = ['catchlongpress', 'bindlongpress'];
|
|
101
|
-
const captureTouchEvent = [
|
|
102
|
-
'capture-catchtouchstart',
|
|
103
|
-
'capture-bindtouchstart'
|
|
104
|
-
];
|
|
105
|
-
const capturePressEvent = [
|
|
106
|
-
'capture-catchlongpress',
|
|
107
|
-
'capture-bindlongpress'
|
|
108
|
-
];
|
|
109
|
-
ref.current.startTimer[type] = null;
|
|
110
|
-
globalEventState.needPress = true;
|
|
111
|
-
const nativeEvent = e.nativeEvent;
|
|
112
|
-
ref.current.mpxPressInfo.detail = {
|
|
113
|
-
x: nativeEvent.changedTouches[0].pageX,
|
|
114
|
-
y: nativeEvent.changedTouches[0].pageY
|
|
115
|
-
};
|
|
116
|
-
const currentTouchEvent = type === 'bubble' ? bubbleTouchEvent : captureTouchEvent;
|
|
117
|
-
const currentPressEvent = type === 'bubble' ? bubblePressEvent : capturePressEvent;
|
|
118
|
-
handleEmitEvent(currentTouchEvent, 'touchstart', e, propsRef, config, navigation);
|
|
119
|
-
const { catchlongpress, bindlongpress, 'capture-catchlongpress': captureCatchlongpress, 'capture-bindlongpress': captureBindlongpress } = propsRef.current;
|
|
120
|
-
if (catchlongpress ||
|
|
121
|
-
bindlongpress ||
|
|
122
|
-
captureCatchlongpress ||
|
|
123
|
-
captureBindlongpress) {
|
|
124
|
-
ref.current.startTimer[type] = setTimeout(() => {
|
|
125
|
-
// 只要触发过longpress, 全局就不再触发tap
|
|
126
|
-
globalEventState.needPress = false;
|
|
127
|
-
handleEmitEvent(currentPressEvent, 'longpress', e, propsRef, config, navigation);
|
|
128
|
-
}, 350);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
function handleTouchmove(e, type, ref, propsRef, config, navigation) {
|
|
132
|
-
const bubbleTouchEvent = ['catchtouchmove', 'bindtouchmove'];
|
|
133
|
-
const captureTouchEvent = [
|
|
134
|
-
'capture-catchtouchmove',
|
|
135
|
-
'capture-bindtouchmove'
|
|
136
|
-
];
|
|
137
|
-
const currentTouchEvent = type === 'bubble' ? bubbleTouchEvent : captureTouchEvent;
|
|
138
|
-
handleEmitEvent(currentTouchEvent, 'touchmove', e, propsRef, config, navigation);
|
|
139
|
-
checkIsNeedPress(e, type, ref);
|
|
140
|
-
}
|
|
141
|
-
function handleTouchend(e, type, ref, propsRef, config, navigation) {
|
|
142
|
-
// move event may not be triggered
|
|
143
|
-
checkIsNeedPress(e, type, ref);
|
|
144
|
-
const bubbleTouchEvent = ['catchtouchend', 'bindtouchend'];
|
|
145
|
-
const bubbleTapEvent = ['catchtap', 'bindtap'];
|
|
146
|
-
const captureTouchEvent = [
|
|
147
|
-
'capture-catchtouchend',
|
|
148
|
-
'capture-bindtouchend'
|
|
149
|
-
];
|
|
150
|
-
const captureTapEvent = ['capture-catchtap', 'capture-bindtap'];
|
|
151
|
-
const currentTouchEvent = type === 'bubble' ? bubbleTouchEvent : captureTouchEvent;
|
|
152
|
-
const currentTapEvent = type === 'bubble' ? bubbleTapEvent : captureTapEvent;
|
|
153
|
-
ref.current.startTimer[type] &&
|
|
154
|
-
clearTimeout(ref.current.startTimer[type]);
|
|
155
|
-
ref.current.startTimer[type] = null;
|
|
156
|
-
handleEmitEvent(currentTouchEvent, 'touchend', e, propsRef, config, navigation);
|
|
157
|
-
if (globalEventState.needPress) {
|
|
158
|
-
if (type === 'bubble' && config.disableTap) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
handleEmitEvent(currentTapEvent, 'tap', e, propsRef, config, navigation);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
function handleTouchcancel(e, type, ref, propsRef, config, navigation) {
|
|
165
|
-
const bubbleTouchEvent = ['catchtouchcancel', 'bindtouchcancel'];
|
|
166
|
-
const captureTouchEvent = [
|
|
167
|
-
'capture-catchtouchcancel',
|
|
168
|
-
'capture-bindtouchcancel'
|
|
169
|
-
];
|
|
170
|
-
const currentTouchEvent = type === 'bubble' ? bubbleTouchEvent : captureTouchEvent;
|
|
171
|
-
ref.current.startTimer[type] &&
|
|
172
|
-
clearTimeout(ref.current.startTimer[type]);
|
|
173
|
-
ref.current.startTimer[type] = null;
|
|
174
|
-
handleEmitEvent(currentTouchEvent, 'touchcancel', e, propsRef, config, navigation);
|
|
175
|
-
}
|
|
176
|
-
function createTouchEventHandler(eventName, type) {
|
|
177
|
-
return (e, ref, propsRef, config, navigation) => {
|
|
178
|
-
const handlerMap = {
|
|
179
|
-
onTouchStart: handleTouchstart,
|
|
180
|
-
onTouchMove: handleTouchmove,
|
|
181
|
-
onTouchEnd: handleTouchend,
|
|
182
|
-
onTouchCancel: handleTouchcancel
|
|
183
|
-
};
|
|
184
|
-
const handler = handlerMap[eventName];
|
|
185
|
-
if (handler) {
|
|
186
|
-
handler(e, type, ref, propsRef, config, navigation);
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
const touchEventList = [
|
|
191
|
-
{ eventName: 'onTouchStart', handler: createTouchEventHandler('onTouchStart', 'bubble') },
|
|
192
|
-
{ eventName: 'onTouchMove', handler: createTouchEventHandler('onTouchMove', 'bubble') },
|
|
193
|
-
{ eventName: 'onTouchEnd', handler: createTouchEventHandler('onTouchEnd', 'bubble') },
|
|
194
|
-
{ eventName: 'onTouchCancel', handler: createTouchEventHandler('onTouchCancel', 'bubble') },
|
|
195
|
-
{ eventName: 'onTouchStartCapture', handler: createTouchEventHandler('onTouchStart', 'capture') },
|
|
196
|
-
{ eventName: 'onTouchMoveCapture', handler: createTouchEventHandler('onTouchMove', 'capture') },
|
|
197
|
-
{ eventName: 'onTouchEndCapture', handler: createTouchEventHandler('onTouchEnd', 'capture') },
|
|
198
|
-
{ eventName: 'onTouchCancelCapture', handler: createTouchEventHandler('onTouchCancel', 'capture') }
|
|
199
|
-
];
|
|
200
|
-
const useInnerProps = (props = {}, additionalProps = {}, userRemoveProps = [], rawConfig) => {
|
|
201
|
-
const ref = useRef({
|
|
202
|
-
startTimer: {
|
|
203
|
-
bubble: null,
|
|
204
|
-
capture: null
|
|
205
|
-
},
|
|
206
|
-
mpxPressInfo: {
|
|
207
|
-
detail: {
|
|
208
|
-
x: 0,
|
|
209
|
-
y: 0
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
const propsRef = useRef({});
|
|
214
|
-
const eventConfig = {};
|
|
215
|
-
const config = rawConfig || {
|
|
216
|
-
layoutRef: { current: {} },
|
|
217
|
-
disableTap: false
|
|
218
|
-
};
|
|
219
|
-
const navigation = useNavigation();
|
|
220
|
-
const removeProps = [
|
|
221
|
-
'children',
|
|
222
|
-
'enable-background',
|
|
223
|
-
'enable-offset',
|
|
224
|
-
'enable-var',
|
|
225
|
-
'external-var-context',
|
|
226
|
-
'parent-font-size',
|
|
227
|
-
'parent-width',
|
|
228
|
-
'parent-height',
|
|
229
|
-
...userRemoveProps
|
|
230
|
-
];
|
|
231
|
-
propsRef.current = extendObject({}, props, additionalProps);
|
|
232
|
-
let hashEventKey = '';
|
|
233
|
-
const rawEventKeys = [];
|
|
234
|
-
for (const key in eventConfigMap) {
|
|
235
|
-
if (hasOwn(propsRef.current, key)) {
|
|
236
|
-
eventConfig[key] = eventConfigMap[key].events;
|
|
237
|
-
hashEventKey = hashEventKey + eventConfigMap[key].bitFlag;
|
|
238
|
-
rawEventKeys.push(key);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
const events = useMemo(() => {
|
|
242
|
-
if (!rawEventKeys.length) {
|
|
243
|
-
return {};
|
|
244
|
-
}
|
|
245
|
-
const transformedEventKeys = rawEventKeys.reduce((acc, key) => {
|
|
246
|
-
if (propsRef.current[key]) {
|
|
247
|
-
return acc.concat(eventConfig[key]);
|
|
248
|
-
}
|
|
249
|
-
return acc;
|
|
250
|
-
}, []);
|
|
251
|
-
const finalEventKeys = [...new Set(transformedEventKeys)];
|
|
252
|
-
const events = {};
|
|
253
|
-
touchEventList.forEach((item) => {
|
|
254
|
-
if (finalEventKeys.includes(item.eventName)) {
|
|
255
|
-
events[item.eventName] = (e) => item.handler(e, ref, propsRef, config, navigation);
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
return events;
|
|
259
|
-
}, [hashEventKey]);
|
|
260
|
-
return extendObject({}, events, omit(propsRef.current, [...rawEventKeys, ...removeProps]));
|
|
261
|
-
};
|
|
262
|
-
export default useInnerProps;
|