@mpxjs/webpack-plugin 2.9.66 → 2.9.69-beta.0
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/RecordGlobalComponentsDependency.js +11 -12
- package/lib/dependencies/RecordRuntimeInfoDependency.js +1 -1
- package/lib/index.js +29 -8
- package/lib/json-compiler/index.js +2 -11
- package/lib/loader.js +24 -45
- package/lib/native-loader.js +49 -64
- package/lib/platform/json/wx/index.js +24 -18
- package/lib/platform/style/wx/index.js +49 -47
- package/lib/platform/template/wx/component-config/canvas.js +8 -0
- package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
- package/lib/platform/template/wx/component-config/index.js +1 -1
- package/lib/platform/template/wx/component-config/input.js +1 -1
- package/lib/platform/template/wx/component-config/rich-text.js +8 -0
- package/lib/platform/template/wx/component-config/swiper.js +1 -1
- package/lib/platform/template/wx/component-config/textarea.js +1 -1
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/react/index.js +4 -3
- package/lib/react/processJSON.js +5 -13
- package/lib/react/processMainScript.js +7 -3
- package/lib/react/processScript.js +3 -4
- package/lib/react/processStyles.js +14 -4
- package/lib/react/processTemplate.js +5 -2
- package/lib/resolver/AddModePlugin.js +20 -7
- package/lib/runtime/components/react/context.ts +6 -0
- package/lib/runtime/components/react/dist/context.js +2 -0
- package/lib/runtime/components/react/dist/event.config.js +24 -24
- package/lib/runtime/components/react/dist/getInnerListeners.js +183 -174
- package/lib/runtime/components/react/dist/mpx-button.jsx +78 -50
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.js +60 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.js +84 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.js +87 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.js +28 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +343 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +232 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.jsx +89 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +41 -34
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +30 -39
- package/lib/runtime/components/react/dist/mpx-form.jsx +47 -41
- package/lib/runtime/components/react/dist/mpx-icon.jsx +9 -17
- package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +95 -62
- package/lib/runtime/components/react/dist/mpx-label.jsx +24 -28
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +20 -30
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +377 -293
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +3 -5
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +160 -88
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +80 -121
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +39 -34
- package/lib/runtime/components/react/dist/mpx-radio.jsx +28 -43
- package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +7 -5
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +77 -51
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
- package/lib/runtime/components/react/dist/mpx-switch.jsx +28 -11
- package/lib/runtime/components/react/dist/mpx-text.jsx +12 -11
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +9 -4
- package/lib/runtime/components/react/dist/mpx-view.jsx +66 -62
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +113 -36
- package/lib/runtime/components/react/dist/pickerFaces.js +81 -0
- package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
- package/lib/runtime/components/react/dist/pickerViewOverlay.jsx +23 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.js +126 -12
- package/lib/runtime/components/react/dist/utils.jsx +80 -24
- package/lib/runtime/components/react/event.config.ts +25 -26
- package/lib/runtime/components/react/getInnerListeners.ts +237 -198
- package/lib/runtime/components/react/mpx-button.tsx +105 -58
- package/lib/runtime/components/react/mpx-canvas/Bus.ts +70 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasGradient.ts +18 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasRenderingContext2D.ts +87 -0
- package/lib/runtime/components/react/mpx-canvas/Image.ts +102 -0
- package/lib/runtime/components/react/mpx-canvas/ImageData.ts +23 -0
- package/lib/runtime/components/react/mpx-canvas/constructorsRegistry.ts +38 -0
- package/lib/runtime/components/react/mpx-canvas/html.ts +343 -0
- package/lib/runtime/components/react/mpx-canvas/index.tsx +296 -0
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +150 -0
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +77 -51
- package/lib/runtime/components/react/mpx-checkbox.tsx +49 -50
- package/lib/runtime/components/react/mpx-form.tsx +62 -57
- package/lib/runtime/components/react/mpx-icon.tsx +13 -18
- package/lib/runtime/components/react/mpx-image.tsx +436 -0
- package/lib/runtime/components/react/mpx-input.tsx +139 -117
- package/lib/runtime/components/react/mpx-label.tsx +36 -34
- package/lib/runtime/components/react/mpx-movable-area.tsx +26 -39
- package/lib/runtime/components/react/mpx-movable-view.tsx +455 -337
- package/lib/runtime/components/react/mpx-navigator.tsx +3 -9
- package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
- package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +236 -104
- package/lib/runtime/components/react/mpx-picker-view.tsx +132 -122
- package/lib/runtime/components/react/mpx-radio-group.tsx +77 -54
- package/lib/runtime/components/react/mpx-radio.tsx +46 -55
- package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +121 -0
- package/lib/runtime/components/react/mpx-root-portal.tsx +4 -6
- package/lib/runtime/components/react/mpx-scroll-view.tsx +122 -76
- package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +6 -4
- package/lib/runtime/components/react/mpx-swiper/index.tsx +2 -1
- package/lib/runtime/components/react/mpx-swiper-item.tsx +4 -3
- package/lib/runtime/components/react/mpx-switch.tsx +39 -25
- package/lib/runtime/components/react/mpx-text.tsx +15 -19
- package/lib/runtime/components/react/mpx-textarea.tsx +12 -11
- package/lib/runtime/components/react/mpx-view.tsx +93 -77
- package/lib/runtime/components/react/mpx-web-view.tsx +117 -55
- package/lib/runtime/components/react/pickerFaces.ts +104 -0
- package/lib/runtime/components/react/pickerOverlay.tsx +32 -0
- package/lib/runtime/components/react/types/common.ts +2 -0
- package/lib/runtime/components/react/types/global.d.ts +5 -17
- package/lib/runtime/components/react/useAnimationHooks.ts +127 -18
- package/lib/runtime/components/react/useNodesRef.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +113 -27
- package/lib/runtime/components/web/getInnerListeners.js +6 -6
- package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
- package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
- package/lib/runtime/components/web/mpx-picker.vue +382 -385
- package/lib/runtime/components/web/mpx-web-view.vue +175 -161
- package/lib/runtime/optionProcessor.js +7 -38
- package/lib/runtime/optionProcessorReact.js +0 -15
- package/lib/runtime/swanHelper.wxs +1 -1
- package/lib/runtime/utils.js +2 -0
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/scope-id.js +31 -2
- package/lib/template-compiler/bind-this.js +7 -2
- package/lib/template-compiler/compiler.js +118 -56
- package/lib/template-compiler/gen-node-react.js +3 -3
- package/lib/template-compiler/index.js +4 -4
- package/lib/utils/pre-process-json.js +117 -0
- package/lib/web/index.js +5 -4
- package/lib/web/processJSON.js +5 -13
- package/lib/web/processTemplate.js +2 -2
- package/package.json +6 -4
- package/LICENSE +0 -433
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
- package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -478
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
- package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
- package/lib/runtime/components/react/mpx-image/index.tsx +0 -346
- package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
- package/lib/runtime/components/web/event.js +0 -105
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ✔ lower-threshold
|
|
6
6
|
* ✔ scroll-top
|
|
7
7
|
* ✔ scroll-left
|
|
8
|
-
*
|
|
8
|
+
* ✔ scroll-into-view
|
|
9
9
|
* ✔ scroll-with-animation
|
|
10
10
|
* ✔ enable-back-to-top
|
|
11
11
|
* ✘ enable-passive
|
|
@@ -33,16 +33,18 @@
|
|
|
33
33
|
*/
|
|
34
34
|
import { ScrollView } from 'react-native-gesture-handler';
|
|
35
35
|
import { RefreshControl } from 'react-native';
|
|
36
|
-
import { useRef, useState, useEffect, forwardRef, useContext } from 'react';
|
|
36
|
+
import { useRef, useState, useEffect, forwardRef, useContext, createElement } from 'react';
|
|
37
37
|
import { useAnimatedRef } from 'react-native-reanimated';
|
|
38
38
|
import { warn } from '@mpxjs/utils';
|
|
39
39
|
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
40
40
|
import useNodesRef from './useNodesRef';
|
|
41
|
-
import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren } from './utils';
|
|
41
|
+
import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, extendObject, flatGesture } from './utils';
|
|
42
42
|
import { IntersectionObserverContext } from './context';
|
|
43
43
|
const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
44
44
|
const { textProps, innerProps: props = {} } = splitProps(scrollViewProps);
|
|
45
|
-
const { enhanced = false, bounces = true, style = {}, 'scroll-x': scrollX = false, 'scroll-y': scrollY = false, 'enable-back-to-top': enableBackToTop = false, 'enable-trigger-intersection-observer': enableTriggerIntersectionObserver = 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;
|
|
45
|
+
const { enhanced = false, bounces = true, style = {}, binddragstart, binddragging, binddragend, bindtouchstart, bindtouchmove, bindtouchend, 'scroll-x': scrollX = false, 'scroll-y': scrollY = false, 'enable-back-to-top': enableBackToTop = false, 'enable-trigger-intersection-observer': enableTriggerIntersectionObserver = 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, 'scroll-into-view': scrollIntoView = '', 'scroll-top': scrollTop = 0, 'scroll-left': scrollLeft = 0, 'refresher-triggered': refresherTriggered, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'simultaneous-handlers': originSimultaneousHandlers, 'wait-for': waitFor, __selectRef } = props;
|
|
46
|
+
const simultaneousHandlers = flatGesture(originSimultaneousHandlers);
|
|
47
|
+
const waitForHandlers = flatGesture(waitFor);
|
|
46
48
|
const [refreshing, setRefreshing] = useState(true);
|
|
47
49
|
const snapScrollTop = useRef(0);
|
|
48
50
|
const snapScrollLeft = useRef(0);
|
|
@@ -58,10 +60,12 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
58
60
|
const hasCallScrollToLower = useRef(false);
|
|
59
61
|
const initialTimeout = useRef(null);
|
|
60
62
|
const intersectionObservers = useContext(IntersectionObserverContext);
|
|
63
|
+
const firstScrollIntoViewChange = useRef(false);
|
|
61
64
|
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
|
|
62
|
-
const { textStyle, innerStyle } = splitStyle(normalStyle);
|
|
65
|
+
const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
|
|
63
66
|
const scrollViewRef = useAnimatedRef();
|
|
64
67
|
useNodesRef(props, ref, scrollViewRef, {
|
|
68
|
+
style: normalStyle,
|
|
65
69
|
scrollOffset: scrollOptions,
|
|
66
70
|
node: {
|
|
67
71
|
scrollEnabled: scrollX || scrollY,
|
|
@@ -71,30 +75,48 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
71
75
|
fastDeceleration: false,
|
|
72
76
|
decelerationDisabled: false,
|
|
73
77
|
scrollTo: scrollToOffset
|
|
74
|
-
}
|
|
78
|
+
},
|
|
79
|
+
gestureRef: scrollViewRef
|
|
75
80
|
});
|
|
76
81
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: scrollViewRef, onLayout });
|
|
77
82
|
if (scrollX && scrollY) {
|
|
78
83
|
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');
|
|
79
84
|
}
|
|
80
85
|
useEffect(() => {
|
|
81
|
-
if (snapScrollTop.current !==
|
|
82
|
-
snapScrollLeft.current !== props['scroll-left']) {
|
|
83
|
-
snapScrollTop.current = props['scroll-top'] || 0;
|
|
84
|
-
snapScrollLeft.current = props['scroll-left'] || 0;
|
|
86
|
+
if (snapScrollTop.current !== scrollTop || snapScrollLeft.current !== scrollLeft) {
|
|
85
87
|
initialTimeout.current = setTimeout(() => {
|
|
86
|
-
scrollToOffset(
|
|
88
|
+
scrollToOffset(scrollLeft, scrollTop);
|
|
87
89
|
}, 0);
|
|
88
90
|
return () => {
|
|
89
91
|
initialTimeout.current && clearTimeout(initialTimeout.current);
|
|
90
92
|
};
|
|
91
93
|
}
|
|
92
|
-
}, [
|
|
94
|
+
}, [scrollTop, scrollLeft]);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (refreshing !== refresherTriggered) {
|
|
97
|
+
setRefreshing(!!refresherTriggered);
|
|
98
|
+
}
|
|
99
|
+
}, [refresherTriggered]);
|
|
93
100
|
useEffect(() => {
|
|
94
|
-
if (
|
|
95
|
-
|
|
101
|
+
if (scrollIntoView && __selectRef) {
|
|
102
|
+
if (!firstScrollIntoViewChange.current) {
|
|
103
|
+
setTimeout(handleScrollIntoView);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
handleScrollIntoView();
|
|
107
|
+
}
|
|
96
108
|
}
|
|
97
|
-
|
|
109
|
+
firstScrollIntoViewChange.current = true;
|
|
110
|
+
}, [scrollIntoView]);
|
|
111
|
+
function handleScrollIntoView() {
|
|
112
|
+
const refs = __selectRef(`#${scrollIntoView}`, 'node');
|
|
113
|
+
if (!refs)
|
|
114
|
+
return;
|
|
115
|
+
const { nodeRef } = refs.getNodeInstance();
|
|
116
|
+
nodeRef.current?.measureLayout(scrollViewRef.current, (left, top) => {
|
|
117
|
+
scrollToOffset(left, top);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
98
120
|
function selectLength(size) {
|
|
99
121
|
return !scrollX ? size.height : size.width;
|
|
100
122
|
}
|
|
@@ -149,14 +171,13 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
149
171
|
const visibleLength = selectLength(e.nativeEvent.layoutMeasurement);
|
|
150
172
|
const contentLength = selectLength(e.nativeEvent.contentSize);
|
|
151
173
|
const offset = selectOffset(e.nativeEvent.contentOffset);
|
|
152
|
-
scrollOptions.current
|
|
153
|
-
...scrollOptions.current,
|
|
174
|
+
extendObject(scrollOptions.current, {
|
|
154
175
|
contentLength,
|
|
155
176
|
offset,
|
|
156
177
|
scrollLeft: position.scrollLeft,
|
|
157
178
|
scrollTop: position.scrollTop,
|
|
158
179
|
visibleLength
|
|
159
|
-
};
|
|
180
|
+
});
|
|
160
181
|
}
|
|
161
182
|
function onScroll(e) {
|
|
162
183
|
const { bindscroll } = props;
|
|
@@ -204,6 +225,8 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
204
225
|
scrollViewRef.current.scrollTo({ x, y, animated: !!scrollWithAnimation });
|
|
205
226
|
scrollOptions.current.scrollLeft = x;
|
|
206
227
|
scrollOptions.current.scrollTop = y;
|
|
228
|
+
snapScrollLeft.current = x;
|
|
229
|
+
snapScrollTop.current = y;
|
|
207
230
|
}
|
|
208
231
|
}
|
|
209
232
|
function onRefresh() {
|
|
@@ -212,7 +235,7 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
212
235
|
bindrefresherrefresh(getCustomEvent('refresherrefresh', {}, { layoutRef }, props));
|
|
213
236
|
}
|
|
214
237
|
function onScrollTouchStart(e) {
|
|
215
|
-
const {
|
|
238
|
+
const { bindtouchstart } = props;
|
|
216
239
|
bindtouchstart && bindtouchstart(e);
|
|
217
240
|
if (enhanced) {
|
|
218
241
|
binddragstart &&
|
|
@@ -226,7 +249,6 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
226
249
|
}
|
|
227
250
|
}
|
|
228
251
|
function onScrollTouchMove(e) {
|
|
229
|
-
const { binddragging, bindtouchmove, enhanced } = props;
|
|
230
252
|
bindtouchmove && bindtouchmove(e);
|
|
231
253
|
if (enhanced) {
|
|
232
254
|
binddragging &&
|
|
@@ -239,26 +261,25 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
239
261
|
}, props));
|
|
240
262
|
}
|
|
241
263
|
}
|
|
242
|
-
function
|
|
243
|
-
|
|
264
|
+
function onScrollTouchEnd(e) {
|
|
265
|
+
bindtouchend && bindtouchend(e);
|
|
244
266
|
if (enhanced) {
|
|
245
|
-
const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset;
|
|
246
|
-
const { width: scrollWidth, height: scrollHeight } = e.nativeEvent.contentSize;
|
|
247
267
|
binddragend &&
|
|
248
268
|
binddragend(getCustomEvent('dragend', e, {
|
|
249
269
|
detail: {
|
|
250
|
-
scrollLeft: scrollLeft,
|
|
251
|
-
scrollTop: scrollTop
|
|
252
|
-
scrollHeight,
|
|
253
|
-
scrollWidth
|
|
270
|
+
scrollLeft: scrollOptions.current.scrollLeft || 0,
|
|
271
|
+
scrollTop: scrollOptions.current.scrollTop || 0
|
|
254
272
|
},
|
|
255
273
|
layoutRef
|
|
256
274
|
}, props));
|
|
257
|
-
updateScrollOptions(e, { scrollLeft, scrollTop });
|
|
258
275
|
}
|
|
259
276
|
}
|
|
260
|
-
|
|
261
|
-
|
|
277
|
+
function onScrollDrag(e) {
|
|
278
|
+
const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset;
|
|
279
|
+
updateScrollOptions(e, { scrollLeft, scrollTop });
|
|
280
|
+
}
|
|
281
|
+
const scrollAdditionalProps = extendObject({
|
|
282
|
+
style: extendObject({}, innerStyle, layoutStyle),
|
|
262
283
|
pinchGestureEnabled: false,
|
|
263
284
|
horizontal: scrollX && !scrollY,
|
|
264
285
|
scrollEventThrottle: scrollEventThrottle,
|
|
@@ -269,20 +290,21 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
269
290
|
ref: scrollViewRef,
|
|
270
291
|
onScroll: onScroll,
|
|
271
292
|
onContentSizeChange: onContentSizeChange,
|
|
272
|
-
bindtouchstart: onScrollTouchStart,
|
|
273
|
-
bindtouchmove: onScrollTouchMove,
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
293
|
+
bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) && onScrollTouchStart,
|
|
294
|
+
bindtouchmove: ((enhanced && binddragging) || bindtouchend) && onScrollTouchMove,
|
|
295
|
+
bindtouchend: ((enhanced && binddragend) || bindtouchend) && onScrollTouchEnd,
|
|
296
|
+
onScrollBeginDrag: onScrollDrag,
|
|
297
|
+
onScrollEndDrag: onScrollDrag,
|
|
298
|
+
onMomentumScrollEnd: onScrollEnd
|
|
299
|
+
}, (simultaneousHandlers ? { simultaneousHandlers } : {}), (waitForHandlers ? { waitFor: waitForHandlers } : {}), layoutProps);
|
|
278
300
|
if (enhanced) {
|
|
279
|
-
scrollAdditionalProps
|
|
280
|
-
...scrollAdditionalProps,
|
|
301
|
+
Object.assign(scrollAdditionalProps, {
|
|
281
302
|
bounces,
|
|
282
303
|
pagingEnabled
|
|
283
|
-
};
|
|
304
|
+
});
|
|
284
305
|
}
|
|
285
306
|
const innerProps = useInnerProps(props, scrollAdditionalProps, [
|
|
307
|
+
'id',
|
|
286
308
|
'scroll-x',
|
|
287
309
|
'scroll-y',
|
|
288
310
|
'enable-back-to-top',
|
|
@@ -312,16 +334,20 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
312
334
|
black: ['#000'],
|
|
313
335
|
white: ['#fff']
|
|
314
336
|
};
|
|
315
|
-
return (
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
337
|
+
return createElement(ScrollView, extendObject({}, innerProps, {
|
|
338
|
+
refreshControl: refresherEnabled
|
|
339
|
+
? createElement(RefreshControl, extendObject({
|
|
340
|
+
progressBackgroundColor: refresherBackground,
|
|
341
|
+
refreshing: refreshing,
|
|
342
|
+
onRefresh: onRefresh
|
|
343
|
+
}, (refresherDefaultStyle && refresherDefaultStyle !== 'none' ? { colors: refreshColor[refresherDefaultStyle] } : null)))
|
|
344
|
+
: undefined
|
|
345
|
+
}), wrapChildren(props, {
|
|
346
|
+
hasVarDec,
|
|
347
|
+
varContext: varContextRef.current,
|
|
348
|
+
textStyle,
|
|
349
|
+
textProps
|
|
350
|
+
}));
|
|
325
351
|
});
|
|
326
|
-
_ScrollView.displayName = '
|
|
352
|
+
_ScrollView.displayName = 'MpxScrollView';
|
|
327
353
|
export default _ScrollView;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Text } from 'react-native';
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import { extendObject } from './utils';
|
|
4
|
+
const _Text2 = (props) => {
|
|
5
|
+
const { allowFontScaling = false } = props;
|
|
6
|
+
return createElement(Text, extendObject({}, props, {
|
|
7
|
+
allowFontScaling
|
|
8
|
+
}));
|
|
9
|
+
};
|
|
10
|
+
_Text2.displayName = 'MpxSimpleText';
|
|
11
|
+
export default _Text2;
|
|
@@ -4,12 +4,14 @@ import useInnerProps from './getInnerListeners';
|
|
|
4
4
|
import useNodesRef from './useNodesRef'; // 引入辅助函数
|
|
5
5
|
import { useTransformStyle, splitStyle, splitProps, wrapChildren, useLayout } from './utils';
|
|
6
6
|
const _SwiperItem = forwardRef((props, ref) => {
|
|
7
|
-
const { 'enable-
|
|
7
|
+
const { 'enable-var': enableVar, 'external-var-context': externalVarContext, style } = props;
|
|
8
8
|
const { textProps } = splitProps(props);
|
|
9
9
|
const nodeRef = useRef(null);
|
|
10
|
-
useNodesRef(props, ref, nodeRef, {});
|
|
11
10
|
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext });
|
|
12
11
|
const { textStyle, innerStyle } = splitStyle(normalStyle);
|
|
12
|
+
useNodesRef(props, ref, nodeRef, {
|
|
13
|
+
style: normalStyle
|
|
14
|
+
});
|
|
13
15
|
const {
|
|
14
16
|
// 存储layout布局信息
|
|
15
17
|
layoutRef, layoutProps, layoutStyle } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: nodeRef });
|
|
@@ -30,5 +32,5 @@ const _SwiperItem = forwardRef((props, ref) => {
|
|
|
30
32
|
})}
|
|
31
33
|
</View>);
|
|
32
34
|
});
|
|
33
|
-
_SwiperItem.displayName = '
|
|
35
|
+
_SwiperItem.displayName = 'MpxSwiperItem';
|
|
34
36
|
export default _SwiperItem;
|