@mpxjs/webpack-plugin 2.9.62 → 2.9.65
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/config.js +38 -10
- package/lib/index.js +1 -3
- package/lib/platform/style/wx/index.js +115 -66
- package/lib/platform/template/wx/index.js +12 -8
- package/lib/react/processStyles.js +1 -0
- package/lib/react/processTemplate.js +2 -3
- package/lib/react/style-helper.js +9 -7
- package/lib/runtime/components/react/context.ts +9 -7
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/getInnerListeners.js +12 -1
- package/lib/runtime/components/react/dist/mpx-button.jsx +53 -74
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +20 -18
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +30 -42
- package/lib/runtime/components/react/dist/mpx-form.jsx +18 -15
- package/lib/runtime/components/react/dist/mpx-icon.jsx +15 -17
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +36 -34
- package/lib/runtime/components/react/dist/mpx-image/svg.jsx +3 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +36 -31
- package/lib/runtime/components/react/dist/mpx-label.jsx +30 -37
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +15 -19
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +10 -9
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +2 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +11 -10
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +9 -5
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +13 -8
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +22 -20
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +103 -10
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +149 -54
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +20 -18
- package/lib/runtime/components/react/dist/mpx-radio.jsx +29 -43
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +8 -4
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +36 -27
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +141 -75
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +16 -7
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +20 -11
- package/lib/runtime/components/react/dist/mpx-switch.jsx +18 -14
- package/lib/runtime/components/react/dist/mpx-text.jsx +20 -35
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-view.jsx +296 -210
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +11 -7
- package/lib/runtime/components/react/dist/parser.js +218 -0
- package/lib/runtime/components/react/dist/useNodesRef.js +1 -5
- package/lib/runtime/components/react/dist/utils.jsx +445 -0
- package/lib/runtime/components/react/getInnerListeners.ts +18 -8
- package/lib/runtime/components/react/mpx-button.tsx +83 -91
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +50 -43
- package/lib/runtime/components/react/mpx-checkbox.tsx +56 -64
- package/lib/runtime/components/react/mpx-form.tsx +51 -22
- package/lib/runtime/components/react/mpx-icon.tsx +31 -27
- package/lib/runtime/components/react/mpx-image/index.tsx +54 -47
- package/lib/runtime/components/react/mpx-image/svg.tsx +5 -3
- package/lib/runtime/components/react/mpx-input.tsx +59 -38
- package/lib/runtime/components/react/mpx-label.tsx +55 -59
- package/lib/runtime/components/react/mpx-movable-area.tsx +40 -25
- package/lib/runtime/components/react/mpx-movable-view.tsx +29 -29
- package/lib/runtime/components/react/mpx-navigator.tsx +2 -2
- package/lib/runtime/components/react/mpx-picker/date.tsx +4 -4
- package/lib/runtime/components/react/mpx-picker/index.tsx +12 -11
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +17 -13
- package/lib/runtime/components/react/mpx-picker/region.tsx +23 -19
- package/lib/runtime/components/react/mpx-picker/selector.tsx +7 -7
- package/lib/runtime/components/react/mpx-picker/time.tsx +29 -31
- package/lib/runtime/components/react/mpx-picker/type.ts +1 -1
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +149 -20
- package/lib/runtime/components/react/mpx-picker-view.tsx +180 -63
- package/lib/runtime/components/react/mpx-radio-group.tsx +51 -47
- package/lib/runtime/components/react/mpx-radio.tsx +57 -72
- package/lib/runtime/components/react/mpx-root-portal.tsx +10 -8
- package/lib/runtime/components/react/mpx-scroll-view.tsx +136 -104
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +175 -96
- package/lib/runtime/components/react/mpx-swiper/index.tsx +21 -9
- package/lib/runtime/components/react/mpx-swiper/type.ts +16 -5
- package/lib/runtime/components/react/mpx-swiper-item.tsx +48 -14
- package/lib/runtime/components/react/mpx-switch.tsx +46 -24
- package/lib/runtime/components/react/mpx-text.tsx +38 -45
- package/lib/runtime/components/react/mpx-textarea.tsx +1 -1
- package/lib/runtime/components/react/mpx-view.tsx +401 -241
- package/lib/runtime/components/react/mpx-web-view.tsx +22 -22
- package/lib/runtime/components/react/parser.ts +245 -0
- package/lib/runtime/components/react/types/common.ts +4 -4
- package/lib/runtime/components/react/types/global.d.ts +24 -2
- package/lib/runtime/components/react/useNodesRef.ts +1 -7
- package/lib/runtime/components/react/utils.tsx +524 -0
- package/lib/runtime/components/web/mpx-scroll-view.vue +25 -5
- package/lib/style-compiler/index.js +5 -4
- package/lib/template-compiler/compiler.js +133 -161
- package/lib/template-compiler/gen-node-react.js +1 -3
- package/lib/utils/const.js +2 -1
- package/lib/web/processStyles.js +2 -1
- package/lib/web/processTemplate.js +2 -3
- package/lib/wxml/loader.js +1 -1
- package/package.json +7 -4
- package/lib/runtime/components/react/dist/utils.js +0 -148
- package/lib/runtime/components/react/utils.ts +0 -170
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useRef, forwardRef, useContext } from 'react';
|
|
5
5
|
import { View } from 'react-native';
|
|
6
|
+
import { warn } from '@mpxjs/utils';
|
|
6
7
|
import { FormContext, RadioGroupContext } from './context';
|
|
7
8
|
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
8
9
|
import useNodesRef from './useNodesRef';
|
|
9
|
-
import {
|
|
10
|
+
import { useLayout, useTransformStyle, wrapChildren } from './utils';
|
|
10
11
|
const radioGroup = forwardRef((props, ref) => {
|
|
11
|
-
const { style = {}, 'enable-
|
|
12
|
-
const layoutRef = useRef({});
|
|
12
|
+
const { style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, bindchange } = props;
|
|
13
13
|
const formContext = useContext(FormContext);
|
|
14
14
|
let formValuesMap;
|
|
15
15
|
if (formContext) {
|
|
@@ -18,19 +18,18 @@ const radioGroup = forwardRef((props, ref) => {
|
|
|
18
18
|
const groupValue = useRef({}).current;
|
|
19
19
|
const defaultStyle = {
|
|
20
20
|
flexDirection: 'row',
|
|
21
|
-
flexWrap: 'wrap'
|
|
22
|
-
...style
|
|
21
|
+
flexWrap: 'wrap'
|
|
23
22
|
};
|
|
24
|
-
const
|
|
25
|
-
defaultStyle
|
|
26
|
-
|
|
27
|
-
const onLayout = () => {
|
|
28
|
-
nodeRef.current?.measure((x, y, width, height, offsetLeft, offsetTop) => {
|
|
29
|
-
layoutRef.current = { x, y, width, height, offsetLeft, offsetTop };
|
|
30
|
-
});
|
|
23
|
+
const styleObj = {
|
|
24
|
+
...defaultStyle,
|
|
25
|
+
...style
|
|
31
26
|
};
|
|
27
|
+
const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
|
|
28
|
+
const nodeRef = useRef(null);
|
|
29
|
+
useNodesRef(props, ref, nodeRef, { defaultStyle });
|
|
30
|
+
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
|
|
32
31
|
const getSelectionValue = () => {
|
|
33
|
-
for (
|
|
32
|
+
for (const key in groupValue) {
|
|
34
33
|
if (groupValue[key].checked) {
|
|
35
34
|
return key;
|
|
36
35
|
}
|
|
@@ -47,7 +46,7 @@ const radioGroup = forwardRef((props, ref) => {
|
|
|
47
46
|
};
|
|
48
47
|
if (formValuesMap) {
|
|
49
48
|
if (!props.name) {
|
|
50
|
-
|
|
49
|
+
warn('If a form component is used, the name attribute is required.');
|
|
51
50
|
}
|
|
52
51
|
else {
|
|
53
52
|
formValuesMap.set(props.name, { getValue, resetValue });
|
|
@@ -64,14 +63,17 @@ const radioGroup = forwardRef((props, ref) => {
|
|
|
64
63
|
};
|
|
65
64
|
const innerProps = useInnerProps(props, {
|
|
66
65
|
ref: nodeRef,
|
|
67
|
-
style:
|
|
68
|
-
...
|
|
69
|
-
}, [
|
|
66
|
+
style: { ...normalStyle, ...layoutStyle },
|
|
67
|
+
...layoutProps
|
|
68
|
+
}, [], {
|
|
70
69
|
layoutRef
|
|
71
70
|
});
|
|
72
71
|
return (<View {...innerProps}>
|
|
73
72
|
<RadioGroupContext.Provider value={{ groupValue, notifyChange }}>
|
|
74
|
-
{
|
|
73
|
+
{wrapChildren(props, {
|
|
74
|
+
hasVarDec,
|
|
75
|
+
varContext: varContextRef.current
|
|
76
|
+
})}
|
|
75
77
|
</RadioGroupContext.Provider>
|
|
76
78
|
</View>);
|
|
77
79
|
});
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
* ✔ color
|
|
6
6
|
*/
|
|
7
7
|
import { useRef, useState, forwardRef, useEffect, useContext } from 'react';
|
|
8
|
-
import { View,
|
|
8
|
+
import { View, StyleSheet } from 'react-native';
|
|
9
|
+
import { warn } from '@mpxjs/utils';
|
|
9
10
|
import { LabelContext, RadioGroupContext } from './context';
|
|
10
11
|
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
11
12
|
import useNodesRef from './useNodesRef';
|
|
12
|
-
import {
|
|
13
|
+
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren } from './utils';
|
|
13
14
|
import Icon from './mpx-icon';
|
|
14
15
|
const styles = StyleSheet.create({
|
|
15
16
|
container: {
|
|
@@ -44,26 +45,22 @@ const styles = StyleSheet.create({
|
|
|
44
45
|
opacity: 1
|
|
45
46
|
}
|
|
46
47
|
});
|
|
47
|
-
const Radio = forwardRef((
|
|
48
|
-
const {
|
|
49
|
-
const
|
|
48
|
+
const Radio = forwardRef((radioProps, ref) => {
|
|
49
|
+
const { textProps, innerProps: props = {} } = splitProps(radioProps);
|
|
50
|
+
const { value = '', disabled = false, checked = false, color = '#09BB07', style = [], 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, bindtap, catchtap } = props;
|
|
50
51
|
const [isChecked, setIsChecked] = useState(!!checked);
|
|
51
52
|
const groupContext = useContext(RadioGroupContext);
|
|
52
53
|
let groupValue;
|
|
53
54
|
let notifyChange;
|
|
54
55
|
const labelContext = useContext(LabelContext);
|
|
55
|
-
const { textStyle, imageStyle, innerStyle } = splitStyle(style);
|
|
56
|
-
if (imageStyle) {
|
|
57
|
-
throwReactWarning('[Mpx runtime warn]: Radio does not support background image-related styles!');
|
|
58
|
-
}
|
|
59
56
|
const defaultStyle = {
|
|
60
57
|
...styles.wrapper,
|
|
61
58
|
...(isChecked && styles.wrapperChecked),
|
|
62
|
-
...(disabled && styles.wrapperDisabled)
|
|
59
|
+
...(disabled && styles.wrapperDisabled)
|
|
63
60
|
};
|
|
64
|
-
const
|
|
65
|
-
...
|
|
66
|
-
...
|
|
61
|
+
const styleObj = {
|
|
62
|
+
...styles.container,
|
|
63
|
+
...style
|
|
67
64
|
};
|
|
68
65
|
const onChange = (evt) => {
|
|
69
66
|
if (disabled || isChecked)
|
|
@@ -90,33 +87,17 @@ const Radio = forwardRef((props, ref) => {
|
|
|
90
87
|
return;
|
|
91
88
|
catchtap && catchtap(getCustomEvent('tap', evt, { layoutRef }, props));
|
|
92
89
|
};
|
|
93
|
-
const {
|
|
90
|
+
const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
|
|
91
|
+
const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle);
|
|
92
|
+
if (backgroundStyle) {
|
|
93
|
+
warn('Radio does not support background image-related styles!');
|
|
94
|
+
}
|
|
95
|
+
const nodeRef = useRef(null);
|
|
96
|
+
useNodesRef(props, ref, nodeRef, {
|
|
94
97
|
defaultStyle,
|
|
95
98
|
change: onChange
|
|
96
99
|
});
|
|
97
|
-
const
|
|
98
|
-
nodeRef.current?.measure((x, y, width, height, offsetLeft, offsetTop) => {
|
|
99
|
-
layoutRef.current = { x, y, width, height, offsetLeft, offsetTop };
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
const wrapChildren = (children, textStyle) => {
|
|
103
|
-
if (!children)
|
|
104
|
-
return children;
|
|
105
|
-
const { textProps } = splitProps(props);
|
|
106
|
-
if (every(children, (child) => isText(child))) {
|
|
107
|
-
if (textStyle || textProps) {
|
|
108
|
-
children = <Text key='radioTextWrap' style={textStyle || {}} {...(textProps || {})}>
|
|
109
|
-
{children}
|
|
110
|
-
</Text>;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
if (textStyle) {
|
|
115
|
-
throwReactWarning('[Mpx runtime warn]: Text style will be ignored unless every child of the Radio is Text node!');
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return children;
|
|
119
|
-
};
|
|
100
|
+
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
|
|
120
101
|
if (groupContext) {
|
|
121
102
|
groupValue = groupContext.groupValue;
|
|
122
103
|
notifyChange = groupContext.notifyChange;
|
|
@@ -126,11 +107,11 @@ const Radio = forwardRef((props, ref) => {
|
|
|
126
107
|
}
|
|
127
108
|
const innerProps = useInnerProps(props, {
|
|
128
109
|
ref: nodeRef,
|
|
129
|
-
style:
|
|
110
|
+
style: { ...innerStyle, ...layoutStyle },
|
|
111
|
+
...layoutProps,
|
|
130
112
|
bindtap: onTap,
|
|
131
|
-
catchtap: catchTap
|
|
132
|
-
|
|
133
|
-
}, ['enable-offset'], {
|
|
113
|
+
catchtap: catchTap
|
|
114
|
+
}, [], {
|
|
134
115
|
layoutRef
|
|
135
116
|
});
|
|
136
117
|
useEffect(() => {
|
|
@@ -155,14 +136,19 @@ const Radio = forwardRef((props, ref) => {
|
|
|
155
136
|
}
|
|
156
137
|
}, [checked]);
|
|
157
138
|
return (<View {...innerProps}>
|
|
158
|
-
<View style={
|
|
139
|
+
<View style={defaultStyle}>
|
|
159
140
|
<Icon type='success' size={24} color={disabled ? '#E1E1E1' : color} style={{
|
|
160
141
|
...styles.icon,
|
|
161
142
|
...(isChecked && styles.iconChecked),
|
|
162
143
|
...(disabled && styles.iconDisabled)
|
|
163
144
|
}}/>
|
|
164
145
|
</View>
|
|
165
|
-
{wrapChildren(
|
|
146
|
+
{wrapChildren(props, {
|
|
147
|
+
hasVarDec,
|
|
148
|
+
varContext: varContextRef.current,
|
|
149
|
+
textStyle,
|
|
150
|
+
textProps
|
|
151
|
+
})}
|
|
166
152
|
</View>);
|
|
167
153
|
});
|
|
168
154
|
Radio.displayName = 'mpx-radio';
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Portal } from '@ant-design/react-native';
|
|
2
|
+
import { warn } from '@mpxjs/utils';
|
|
2
3
|
const _RootPortal = (props) => {
|
|
3
4
|
const { children, enable = true } = props;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
if (props.style) {
|
|
6
|
+
warn('The root-portal component does not support the style prop.');
|
|
7
|
+
}
|
|
8
|
+
return enable
|
|
9
|
+
? <Portal>
|
|
7
10
|
{children}
|
|
8
|
-
</Portal>
|
|
11
|
+
</Portal>
|
|
12
|
+
: <>{children}</>;
|
|
9
13
|
};
|
|
10
14
|
_RootPortal.displayName = 'mpx-root-portal';
|
|
11
15
|
export default _RootPortal;
|
|
@@ -34,27 +34,32 @@
|
|
|
34
34
|
import { ScrollView } from 'react-native-gesture-handler';
|
|
35
35
|
import { RefreshControl } from 'react-native';
|
|
36
36
|
import { useRef, useState, useEffect, forwardRef } from 'react';
|
|
37
|
+
import { useAnimatedRef } from 'react-native-reanimated';
|
|
38
|
+
import { warn } from '@mpxjs/utils';
|
|
37
39
|
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
38
40
|
import useNodesRef from './useNodesRef';
|
|
39
|
-
import {
|
|
40
|
-
const _ScrollView = forwardRef((
|
|
41
|
-
const {
|
|
41
|
+
import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren } from './utils';
|
|
42
|
+
const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
43
|
+
const { textProps, innerProps: props = {} } = splitProps(scrollViewProps);
|
|
44
|
+
const { enhanced = false, bounces = true, style = {}, 'scroll-x': scrollX = false, 'scroll-y': scrollY = false, 'enable-back-to-top': enableBackToTop = false, 'paging-enabled': pagingEnabled = false, 'upper-threshold': upperThreshold = 50, 'lower-threshold': lowerThreshold = 50, 'scroll-with-animation': scrollWithAnimation, 'refresher-enabled': refresherEnabled, 'refresher-default-style': refresherDefaultStyle, 'refresher-background': refresherBackground, 'show-scrollbar': showScrollbar = true, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
42
45
|
const [refreshing, setRefreshing] = useState(true);
|
|
43
46
|
const snapScrollTop = useRef(0);
|
|
44
47
|
const snapScrollLeft = useRef(0);
|
|
45
|
-
const layoutRef = useRef({});
|
|
46
48
|
const scrollOptions = useRef({
|
|
47
49
|
contentLength: 0,
|
|
48
50
|
offset: 0,
|
|
49
51
|
scrollLeft: 0,
|
|
50
52
|
scrollTop: 0,
|
|
51
|
-
visibleLength: 0
|
|
53
|
+
visibleLength: 0
|
|
52
54
|
});
|
|
53
55
|
const scrollEventThrottle = 50;
|
|
54
56
|
const hasCallScrollToUpper = useRef(true);
|
|
55
57
|
const hasCallScrollToLower = useRef(false);
|
|
56
58
|
const initialTimeout = useRef(null);
|
|
57
|
-
const {
|
|
59
|
+
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
|
|
60
|
+
const { textStyle, innerStyle } = splitStyle(normalStyle);
|
|
61
|
+
const scrollViewRef = useAnimatedRef();
|
|
62
|
+
useNodesRef(props, ref, scrollViewRef, {
|
|
58
63
|
scrollOffset: scrollOptions,
|
|
59
64
|
node: {
|
|
60
65
|
scrollEnabled: scrollX || scrollY,
|
|
@@ -66,8 +71,9 @@ const _ScrollView = forwardRef((props = {}, ref) => {
|
|
|
66
71
|
scrollTo: scrollToOffset
|
|
67
72
|
}
|
|
68
73
|
});
|
|
74
|
+
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: scrollViewRef, onLayout });
|
|
69
75
|
if (scrollX && scrollY) {
|
|
70
|
-
|
|
76
|
+
warn('scroll-x and scroll-y cannot be set to true at the same time, Mpx will use the value of scroll-y as the criterion');
|
|
71
77
|
}
|
|
72
78
|
useEffect(() => {
|
|
73
79
|
if (snapScrollTop.current !== props['scroll-top'] ||
|
|
@@ -100,7 +106,7 @@ const _ScrollView = forwardRef((props = {}, ref) => {
|
|
|
100
106
|
if (!hasCallScrollToUpper.current) {
|
|
101
107
|
bindscrolltoupper(getCustomEvent('scrolltoupper', e, {
|
|
102
108
|
detail: {
|
|
103
|
-
direction: scrollX ? 'left' : 'top'
|
|
109
|
+
direction: scrollX ? 'left' : 'top'
|
|
104
110
|
},
|
|
105
111
|
layoutRef
|
|
106
112
|
}, props));
|
|
@@ -120,7 +126,7 @@ const _ScrollView = forwardRef((props = {}, ref) => {
|
|
|
120
126
|
hasCallScrollToLower.current = true;
|
|
121
127
|
bindscrolltolower(getCustomEvent('scrolltolower', e, {
|
|
122
128
|
detail: {
|
|
123
|
-
direction: scrollX ? 'right' : 'botttom'
|
|
129
|
+
direction: scrollX ? 'right' : 'botttom'
|
|
124
130
|
},
|
|
125
131
|
layoutRef
|
|
126
132
|
}, props));
|
|
@@ -134,12 +140,8 @@ const _ScrollView = forwardRef((props = {}, ref) => {
|
|
|
134
140
|
scrollOptions.current.contentLength = selectLength({ height, width });
|
|
135
141
|
}
|
|
136
142
|
function onLayout(e) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
scrollViewRef.current?.measure((x, y, width, height, offsetLeft, offsetTop) => {
|
|
140
|
-
layoutRef.current = { x, y, width, height, offsetLeft, offsetTop };
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
+
const layout = e.nativeEvent.layout || {};
|
|
144
|
+
scrollOptions.current.visibleLength = selectLength(layout);
|
|
143
145
|
}
|
|
144
146
|
function updateScrollOptions(e, position) {
|
|
145
147
|
const visibleLength = selectLength(e.nativeEvent.layoutMeasurement);
|
|
@@ -151,7 +153,7 @@ const _ScrollView = forwardRef((props = {}, ref) => {
|
|
|
151
153
|
offset,
|
|
152
154
|
scrollLeft: position.scrollLeft,
|
|
153
155
|
scrollTop: position.scrollTop,
|
|
154
|
-
visibleLength
|
|
156
|
+
visibleLength
|
|
155
157
|
};
|
|
156
158
|
}
|
|
157
159
|
function onScroll(e) {
|
|
@@ -166,7 +168,7 @@ const _ScrollView = forwardRef((props = {}, ref) => {
|
|
|
166
168
|
scrollHeight,
|
|
167
169
|
scrollWidth,
|
|
168
170
|
deltaX: scrollLeft - scrollOptions.current.scrollLeft,
|
|
169
|
-
deltaY: scrollTop - scrollOptions.current.scrollTop
|
|
171
|
+
deltaY: scrollTop - scrollOptions.current.scrollTop
|
|
170
172
|
},
|
|
171
173
|
layoutRef
|
|
172
174
|
}, props));
|
|
@@ -210,7 +212,7 @@ const _ScrollView = forwardRef((props = {}, ref) => {
|
|
|
210
212
|
binddragstart(getCustomEvent('dragstart', e, {
|
|
211
213
|
detail: {
|
|
212
214
|
scrollLeft: scrollOptions.current.scrollLeft,
|
|
213
|
-
scrollTop: scrollOptions.current.scrollTop
|
|
215
|
+
scrollTop: scrollOptions.current.scrollTop
|
|
214
216
|
},
|
|
215
217
|
layoutRef
|
|
216
218
|
}, props));
|
|
@@ -224,7 +226,7 @@ const _ScrollView = forwardRef((props = {}, ref) => {
|
|
|
224
226
|
binddragging(getCustomEvent('dragging', e, {
|
|
225
227
|
detail: {
|
|
226
228
|
scrollLeft: scrollOptions.current.scrollLeft || 0,
|
|
227
|
-
scrollTop: scrollOptions.current.scrollTop || 0
|
|
229
|
+
scrollTop: scrollOptions.current.scrollTop || 0
|
|
228
230
|
},
|
|
229
231
|
layoutRef
|
|
230
232
|
}, props));
|
|
@@ -249,6 +251,7 @@ const _ScrollView = forwardRef((props = {}, ref) => {
|
|
|
249
251
|
}
|
|
250
252
|
}
|
|
251
253
|
let scrollAdditionalProps = {
|
|
254
|
+
style: { ...innerStyle, ...layoutStyle },
|
|
252
255
|
pinchGestureEnabled: false,
|
|
253
256
|
horizontal: scrollX && !scrollY,
|
|
254
257
|
scrollEventThrottle: scrollEventThrottle,
|
|
@@ -261,19 +264,18 @@ const _ScrollView = forwardRef((props = {}, ref) => {
|
|
|
261
264
|
onContentSizeChange: onContentSizeChange,
|
|
262
265
|
bindtouchstart: onScrollTouchStart,
|
|
263
266
|
bindtouchmove: onScrollTouchMove,
|
|
264
|
-
onLayout,
|
|
265
267
|
onScrollEndDrag,
|
|
266
|
-
onMomentumScrollEnd: onScrollEnd
|
|
268
|
+
onMomentumScrollEnd: onScrollEnd,
|
|
269
|
+
...layoutProps
|
|
267
270
|
};
|
|
268
271
|
if (enhanced) {
|
|
269
272
|
scrollAdditionalProps = {
|
|
270
273
|
...scrollAdditionalProps,
|
|
271
274
|
bounces,
|
|
272
|
-
pagingEnabled
|
|
275
|
+
pagingEnabled
|
|
273
276
|
};
|
|
274
277
|
}
|
|
275
278
|
const innerProps = useInnerProps(props, scrollAdditionalProps, [
|
|
276
|
-
'enable-offset',
|
|
277
279
|
'scroll-x',
|
|
278
280
|
'scroll-y',
|
|
279
281
|
'enable-back-to-top',
|
|
@@ -299,11 +301,18 @@ const _ScrollView = forwardRef((props = {}, ref) => {
|
|
|
299
301
|
'bindrefresherrefresh'
|
|
300
302
|
], { layoutRef });
|
|
301
303
|
const refreshColor = {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
+
black: ['#000'],
|
|
305
|
+
white: ['#fff']
|
|
304
306
|
};
|
|
305
|
-
return (<ScrollView {...innerProps} refreshControl={refresherEnabled
|
|
306
|
-
|
|
307
|
+
return (<ScrollView {...innerProps} refreshControl={refresherEnabled
|
|
308
|
+
? (<RefreshControl progressBackgroundColor={refresherBackground} refreshing={refreshing} onRefresh={onRefresh} {...(refresherDefaultStyle && refresherDefaultStyle !== 'none' ? { colors: refreshColor[refresherDefaultStyle] } : {})}/>)
|
|
309
|
+
: undefined}>
|
|
310
|
+
{wrapChildren(props, {
|
|
311
|
+
hasVarDec,
|
|
312
|
+
varContext: varContextRef.current,
|
|
313
|
+
textStyle,
|
|
314
|
+
textProps
|
|
315
|
+
})}
|
|
307
316
|
</ScrollView>);
|
|
308
317
|
});
|
|
309
318
|
_ScrollView.displayName = 'mpx-scroll-view';
|