@mpxjs/webpack-plugin 2.9.62 → 2.9.64

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.
Files changed (86) hide show
  1. package/lib/index.js +1 -3
  2. package/lib/platform/style/wx/index.js +67 -53
  3. package/lib/react/processStyles.js +1 -0
  4. package/lib/react/processTemplate.js +2 -3
  5. package/lib/react/style-helper.js +12 -7
  6. package/lib/runtime/components/react/context.ts +9 -7
  7. package/lib/runtime/components/react/dist/context.js +1 -0
  8. package/lib/runtime/components/react/dist/getInnerListeners.js +12 -1
  9. package/lib/runtime/components/react/dist/mpx-button.jsx +52 -74
  10. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +19 -18
  11. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +28 -41
  12. package/lib/runtime/components/react/dist/mpx-form.jsx +16 -14
  13. package/lib/runtime/components/react/dist/mpx-icon.jsx +14 -17
  14. package/lib/runtime/components/react/dist/mpx-image/index.jsx +34 -33
  15. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +3 -1
  16. package/lib/runtime/components/react/dist/mpx-input.jsx +35 -31
  17. package/lib/runtime/components/react/dist/mpx-label.jsx +29 -37
  18. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -18
  19. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +8 -8
  20. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +9 -9
  21. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +7 -4
  22. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +11 -7
  23. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +1 -1
  24. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +18 -18
  25. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +102 -10
  26. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +147 -53
  27. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +19 -18
  28. package/lib/runtime/components/react/dist/mpx-radio.jsx +28 -43
  29. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +8 -4
  30. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +33 -26
  31. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +139 -74
  32. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +14 -6
  33. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +19 -11
  34. package/lib/runtime/components/react/dist/mpx-switch.jsx +17 -14
  35. package/lib/runtime/components/react/dist/mpx-text.jsx +19 -35
  36. package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -1
  37. package/lib/runtime/components/react/dist/mpx-view.jsx +284 -209
  38. package/lib/runtime/components/react/dist/mpx-web-view.jsx +8 -5
  39. package/lib/runtime/components/react/dist/parser.js +218 -0
  40. package/lib/runtime/components/react/dist/utils.jsx +433 -0
  41. package/lib/runtime/components/react/getInnerListeners.ts +18 -8
  42. package/lib/runtime/components/react/mpx-button.tsx +81 -91
  43. package/lib/runtime/components/react/mpx-checkbox-group.tsx +48 -43
  44. package/lib/runtime/components/react/mpx-checkbox.tsx +52 -63
  45. package/lib/runtime/components/react/mpx-form.tsx +49 -21
  46. package/lib/runtime/components/react/mpx-icon.tsx +30 -27
  47. package/lib/runtime/components/react/mpx-image/index.tsx +52 -46
  48. package/lib/runtime/components/react/mpx-image/svg.tsx +5 -3
  49. package/lib/runtime/components/react/mpx-input.tsx +58 -38
  50. package/lib/runtime/components/react/mpx-label.tsx +54 -59
  51. package/lib/runtime/components/react/mpx-movable-area.tsx +38 -24
  52. package/lib/runtime/components/react/mpx-movable-view.tsx +27 -28
  53. package/lib/runtime/components/react/mpx-navigator.tsx +2 -2
  54. package/lib/runtime/components/react/mpx-picker/date.tsx +2 -3
  55. package/lib/runtime/components/react/mpx-picker/index.tsx +10 -10
  56. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +15 -12
  57. package/lib/runtime/components/react/mpx-picker/region.tsx +21 -18
  58. package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -6
  59. package/lib/runtime/components/react/mpx-picker/time.tsx +25 -29
  60. package/lib/runtime/components/react/mpx-picker/type.ts +1 -1
  61. package/lib/runtime/components/react/mpx-picker-view-column.tsx +148 -20
  62. package/lib/runtime/components/react/mpx-picker-view.tsx +179 -63
  63. package/lib/runtime/components/react/mpx-radio-group.tsx +50 -47
  64. package/lib/runtime/components/react/mpx-radio.tsx +56 -72
  65. package/lib/runtime/components/react/mpx-root-portal.tsx +10 -8
  66. package/lib/runtime/components/react/mpx-scroll-view.tsx +133 -103
  67. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +174 -96
  68. package/lib/runtime/components/react/mpx-swiper/index.tsx +18 -9
  69. package/lib/runtime/components/react/mpx-swiper/type.ts +16 -5
  70. package/lib/runtime/components/react/mpx-swiper-item.tsx +46 -13
  71. package/lib/runtime/components/react/mpx-switch.tsx +44 -23
  72. package/lib/runtime/components/react/mpx-text.tsx +37 -45
  73. package/lib/runtime/components/react/mpx-textarea.tsx +1 -1
  74. package/lib/runtime/components/react/mpx-view.tsx +388 -240
  75. package/lib/runtime/components/react/mpx-web-view.tsx +19 -20
  76. package/lib/runtime/components/react/parser.ts +245 -0
  77. package/lib/runtime/components/react/types/common.ts +4 -4
  78. package/lib/runtime/components/react/types/global.d.ts +14 -2
  79. package/lib/runtime/components/react/useNodesRef.ts +1 -2
  80. package/lib/runtime/components/react/utils.tsx +505 -0
  81. package/lib/template-compiler/compiler.js +28 -20
  82. package/lib/template-compiler/gen-node-react.js +1 -3
  83. package/lib/web/processStyles.js +2 -5
  84. package/package.json +6 -4
  85. package/lib/runtime/components/react/dist/utils.js +0 -148
  86. package/lib/runtime/components/react/utils.ts +0 -170
@@ -32,11 +32,12 @@
32
32
  * ✔ bindscroll
33
33
  */
34
34
  import { ScrollView } from 'react-native-gesture-handler'
35
- import { View, RefreshControl, NativeSyntheticEvent, NativeScrollEvent, LayoutChangeEvent, ViewStyle } from 'react-native';
36
- import { JSX, ReactNode, RefObject, useRef, useState, useEffect, forwardRef } from 'react';
37
- import useInnerProps, { getCustomEvent } from './getInnerListeners';
35
+ import { View, RefreshControl, NativeSyntheticEvent, NativeScrollEvent, LayoutChangeEvent, ViewStyle } from 'react-native'
36
+ import { JSX, ReactNode, RefObject, useRef, useState, useEffect, forwardRef } from 'react'
37
+ import { warn } from '@mpxjs/utils'
38
+ import useInnerProps, { getCustomEvent } from './getInnerListeners'
38
39
  import useNodesRef, { HandlerRef } from './useNodesRef'
39
- import { throwReactWarning } from './utils'
40
+ import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren } from './utils'
40
41
 
41
42
  interface ScrollViewProps {
42
43
  children?: ReactNode;
@@ -58,6 +59,11 @@ interface ScrollViewProps {
58
59
  'scroll-top'?: number;
59
60
  'scroll-left'?: number;
60
61
  'enable-offset'?: boolean;
62
+ 'enable-var'?: boolean;
63
+ 'external-var-context'?: Record<string, any>;
64
+ 'parent-font-size'?: number;
65
+ 'parent-width'?: number;
66
+ 'parent-height'?: number;
61
67
  bindscrolltoupper?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
62
68
  bindscrolltolower?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
63
69
  bindscroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
@@ -91,11 +97,12 @@ type ScrollAdditionalProps = {
91
97
  onScrollEndDrag?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
92
98
  onMomentumScrollEnd?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
93
99
  };
94
- const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, ScrollViewProps>((props: ScrollViewProps = {}, ref): JSX.Element => {
100
+ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, ScrollViewProps>((scrollViewProps: ScrollViewProps = {}, ref): JSX.Element => {
101
+ const { textProps, innerProps: props = {} } = splitProps(scrollViewProps)
95
102
  const {
96
- children,
97
103
  enhanced = false,
98
104
  bounces = true,
105
+ style = {},
99
106
  'scroll-x': scrollX = false,
100
107
  'scroll-y': scrollY = false,
101
108
  'enable-back-to-top': enableBackToTop = false,
@@ -106,29 +113,43 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
106
113
  'refresher-enabled': refresherEnabled,
107
114
  'refresher-default-style': refresherDefaultStyle,
108
115
  'refresher-background': refresherBackground,
109
- 'enable-offset': enableOffset,
110
- 'show-scrollbar': showScrollbar = true
111
- } = props;
116
+ 'show-scrollbar': showScrollbar = true,
117
+ 'enable-var': enableVar,
118
+ 'external-var-context': externalVarContext,
119
+ 'parent-font-size': parentFontSize,
120
+ 'parent-width': parentWidth,
121
+ 'parent-height': parentHeight
122
+ } = props
112
123
 
113
- const [refreshing, setRefreshing] = useState(true);
124
+ const [refreshing, setRefreshing] = useState(true)
114
125
 
115
- const snapScrollTop = useRef(0);
116
- const snapScrollLeft = useRef(0);
126
+ const snapScrollTop = useRef(0)
127
+ const snapScrollLeft = useRef(0)
117
128
 
118
- const layoutRef = useRef({})
119
129
  const scrollOptions = useRef({
120
130
  contentLength: 0,
121
131
  offset: 0,
122
132
  scrollLeft: 0,
123
133
  scrollTop: 0,
124
- visibleLength: 0,
125
- });
134
+ visibleLength: 0
135
+ })
126
136
 
127
- const scrollEventThrottle = 50;
128
- const hasCallScrollToUpper = useRef(true);
129
- const hasCallScrollToLower = useRef(false);
137
+ const scrollEventThrottle = 50
138
+ const hasCallScrollToUpper = useRef(true)
139
+ const hasCallScrollToLower = useRef(false)
130
140
  const initialTimeout = useRef<ReturnType<typeof setTimeout> | null>(null)
131
141
 
142
+ const {
143
+ normalStyle,
144
+ hasVarDec,
145
+ varContextRef,
146
+ hasSelfPercent,
147
+ setWidth,
148
+ setHeight
149
+ } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
150
+
151
+ const { textStyle, innerStyle } = splitStyle(normalStyle)
152
+
132
153
  const { nodeRef: scrollViewRef } = useNodesRef(props, ref, {
133
154
  scrollOffset: scrollOptions,
134
155
  node: {
@@ -141,113 +162,111 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
141
162
  scrollTo: scrollToOffset
142
163
  }
143
164
  })
165
+
166
+ const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: scrollViewRef, onLayout })
167
+
144
168
  if (scrollX && scrollY) {
145
- throwReactWarning('[Mpx runtime 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')
169
+ 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')
146
170
  }
147
171
  useEffect(() => {
148
172
  if (
149
173
  snapScrollTop.current !== props['scroll-top'] ||
150
174
  snapScrollLeft.current !== props['scroll-left']
151
175
  ) {
152
-
153
176
  snapScrollTop.current = props['scroll-top'] || 0
154
177
  snapScrollLeft.current = props['scroll-left'] || 0
155
178
 
156
179
  initialTimeout.current = setTimeout(() => {
157
- scrollToOffset(snapScrollLeft.current, snapScrollTop.current);
158
- }, 0);
180
+ scrollToOffset(snapScrollLeft.current, snapScrollTop.current)
181
+ }, 0)
159
182
 
160
183
  return () => {
161
- initialTimeout.current && clearTimeout(initialTimeout.current);
162
- };
184
+ initialTimeout.current && clearTimeout(initialTimeout.current)
185
+ }
163
186
  }
164
- }, [props['scroll-top'], props['scroll-left']]);
187
+ }, [props['scroll-top'], props['scroll-left']])
165
188
 
166
189
  useEffect(() => {
167
190
  if (refreshing !== props['refresher-triggered']) {
168
- setRefreshing(!!props['refresher-triggered']);
191
+ setRefreshing(!!props['refresher-triggered'])
169
192
  }
170
- }, [props['refresher-triggered']]);
193
+ }, [props['refresher-triggered']])
171
194
 
172
- function selectLength(size: { height: number; width: number }) {
173
- return !scrollX ? size.height : size.width;
195
+ function selectLength (size: { height: number; width: number }) {
196
+ return !scrollX ? size.height : size.width
174
197
  }
175
198
 
176
- function selectOffset(position: { x: number; y: number }) {
177
- return !scrollX ? position.y : position.x;
199
+ function selectOffset (position: { x: number; y: number }) {
200
+ return !scrollX ? position.y : position.x
178
201
  }
179
202
 
180
- function onStartReached(e: NativeSyntheticEvent<NativeScrollEvent>) {
181
- const { bindscrolltoupper } = props;
182
- const { offset } = scrollOptions.current;
203
+ function onStartReached (e: NativeSyntheticEvent<NativeScrollEvent>) {
204
+ const { bindscrolltoupper } = props
205
+ const { offset } = scrollOptions.current
183
206
  if (bindscrolltoupper && (offset <= upperThreshold)) {
184
207
  if (!hasCallScrollToUpper.current) {
185
208
  bindscrolltoupper(
186
209
  getCustomEvent('scrolltoupper', e, {
187
210
  detail: {
188
- direction: scrollX ? 'left' : 'top',
211
+ direction: scrollX ? 'left' : 'top'
189
212
  },
190
213
  layoutRef
191
- }, props),
192
- );
193
- hasCallScrollToUpper.current = true;
214
+ }, props)
215
+ )
216
+ hasCallScrollToUpper.current = true
194
217
  }
195
218
  } else {
196
- hasCallScrollToUpper.current = false;
219
+ hasCallScrollToUpper.current = false
197
220
  }
198
221
  }
199
222
 
200
- function onEndReached(e: NativeSyntheticEvent<NativeScrollEvent>) {
201
- const { bindscrolltolower } = props;
202
- const { contentLength, visibleLength, offset } = scrollOptions.current;
203
- const distanceFromEnd = contentLength - visibleLength - offset;
223
+ function onEndReached (e: NativeSyntheticEvent<NativeScrollEvent>) {
224
+ const { bindscrolltolower } = props
225
+ const { contentLength, visibleLength, offset } = scrollOptions.current
226
+ const distanceFromEnd = contentLength - visibleLength - offset
204
227
  if (bindscrolltolower && (distanceFromEnd < lowerThreshold)) {
205
228
  if (!hasCallScrollToLower.current) {
206
- hasCallScrollToLower.current = true;
229
+ hasCallScrollToLower.current = true
207
230
  bindscrolltolower(
208
231
  getCustomEvent('scrolltolower', e, {
209
232
  detail: {
210
- direction: scrollX ? 'right' : 'botttom',
233
+ direction: scrollX ? 'right' : 'botttom'
211
234
  },
212
235
  layoutRef
213
- }, props),
214
- );
236
+ }, props)
237
+ )
215
238
  }
216
239
  } else {
217
- hasCallScrollToLower.current = false;
240
+ hasCallScrollToLower.current = false
218
241
  }
219
242
  }
220
243
 
221
- function onContentSizeChange(width: number, height: number) {
222
- scrollOptions.current.contentLength = selectLength({ height, width });
244
+ function onContentSizeChange (width: number, height: number) {
245
+ scrollOptions.current.contentLength = selectLength({ height, width })
223
246
  }
224
247
 
225
- function onLayout(e: LayoutChangeEvent) {
226
- scrollOptions.current.visibleLength = selectLength(e.nativeEvent.layout);
227
- if (enableOffset) {
228
- scrollViewRef.current?.measure((x: number, y: number, width: number, height: number, offsetLeft: number, offsetTop: number) => {
229
- layoutRef.current = { x, y, width, height, offsetLeft, offsetTop }
230
- })
231
- }
248
+ function onLayout (e: LayoutChangeEvent) {
249
+ const layout = e.nativeEvent.layout || {}
250
+ scrollOptions.current.visibleLength = selectLength(layout)
232
251
  }
233
252
 
234
- function updateScrollOptions(e: NativeSyntheticEvent<NativeScrollEvent>, position: Record<string, any>) {
235
- const visibleLength = selectLength(e.nativeEvent.layoutMeasurement);
236
- const contentLength = selectLength(e.nativeEvent.contentSize);
237
- const offset = selectOffset(e.nativeEvent.contentOffset);
253
+ function updateScrollOptions (e: NativeSyntheticEvent<NativeScrollEvent>, position: Record<string, any>) {
254
+ const visibleLength = selectLength(e.nativeEvent.layoutMeasurement)
255
+ const contentLength = selectLength(e.nativeEvent.contentSize)
256
+ const offset = selectOffset(e.nativeEvent.contentOffset)
238
257
  scrollOptions.current = {
239
258
  ...scrollOptions.current,
240
259
  contentLength,
241
260
  offset,
242
261
  scrollLeft: position.scrollLeft,
243
262
  scrollTop: position.scrollTop,
244
- visibleLength,
263
+ visibleLength
245
264
  }
246
265
  }
247
266
 
248
- function onScroll(e: NativeSyntheticEvent<NativeScrollEvent>) {
249
- const { bindscroll } = props;
250
- const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset;
267
+ function onScroll (e: NativeSyntheticEvent<NativeScrollEvent>) {
268
+ const { bindscroll } = props
269
+ const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset
251
270
  const { width: scrollWidth, height: scrollHeight } = e.nativeEvent.contentSize
252
271
  bindscroll &&
253
272
  bindscroll(
@@ -258,18 +277,17 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
258
277
  scrollHeight,
259
278
  scrollWidth,
260
279
  deltaX: scrollLeft - scrollOptions.current.scrollLeft,
261
- deltaY: scrollTop - scrollOptions.current.scrollTop,
280
+ deltaY: scrollTop - scrollOptions.current.scrollTop
262
281
  },
263
282
  layoutRef
264
283
  }, props)
265
- );
284
+ )
266
285
  updateScrollOptions(e, { scrollLeft, scrollTop })
267
-
268
286
  }
269
287
 
270
- function onScrollEnd(e: NativeSyntheticEvent<NativeScrollEvent>) {
271
- const { bindscrollend } = props;
272
- const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset;
288
+ function onScrollEnd (e: NativeSyntheticEvent<NativeScrollEvent>) {
289
+ const { bindscrollend } = props
290
+ const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset
273
291
  const { width: scrollWidth, height: scrollHeight } = e.nativeEvent.contentSize
274
292
  bindscrollend &&
275
293
  bindscrollend(
@@ -282,30 +300,30 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
282
300
  },
283
301
  layoutRef
284
302
  }, props)
285
- );
303
+ )
286
304
  updateScrollOptions(e, { scrollLeft, scrollTop })
287
- onStartReached(e);
288
- onEndReached(e);
305
+ onStartReached(e)
306
+ onEndReached(e)
289
307
  }
290
308
 
291
- function scrollToOffset(x = 0, y = 0) {
309
+ function scrollToOffset (x = 0, y = 0) {
292
310
  if (scrollViewRef.current) {
293
- scrollViewRef.current.scrollTo({ x, y, animated: !!scrollWithAnimation });
311
+ scrollViewRef.current.scrollTo({ x, y, animated: !!scrollWithAnimation })
294
312
  scrollOptions.current.scrollLeft = x
295
313
  scrollOptions.current.scrollTop = y
296
314
  }
297
315
  }
298
316
 
299
- function onRefresh() {
300
- const { bindrefresherrefresh } = props;
317
+ function onRefresh () {
318
+ const { bindrefresherrefresh } = props
301
319
  bindrefresherrefresh &&
302
320
  bindrefresherrefresh(
303
- getCustomEvent('refresherrefresh', {}, { layoutRef }, props),
304
- );
321
+ getCustomEvent('refresherrefresh', {}, { layoutRef }, props)
322
+ )
305
323
  }
306
324
 
307
- function onScrollTouchStart(e: NativeSyntheticEvent<TouchEvent>) {
308
- const { binddragstart, bindtouchstart, enhanced } = props;
325
+ function onScrollTouchStart (e: NativeSyntheticEvent<TouchEvent>) {
326
+ const { binddragstart, bindtouchstart, enhanced } = props
309
327
  bindtouchstart && bindtouchstart(e)
310
328
  if (enhanced) {
311
329
  binddragstart &&
@@ -313,15 +331,15 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
313
331
  getCustomEvent('dragstart', e, {
314
332
  detail: {
315
333
  scrollLeft: scrollOptions.current.scrollLeft,
316
- scrollTop: scrollOptions.current.scrollTop,
334
+ scrollTop: scrollOptions.current.scrollTop
317
335
  },
318
336
  layoutRef
319
337
  }, props)
320
338
  )
321
339
  }
322
340
  }
323
- function onScrollTouchMove(e: NativeSyntheticEvent<TouchEvent>) {
324
- const { binddragging, bindtouchmove, enhanced } = props;
341
+ function onScrollTouchMove (e: NativeSyntheticEvent<TouchEvent>) {
342
+ const { binddragging, bindtouchmove, enhanced } = props
325
343
  bindtouchmove && bindtouchmove(e)
326
344
  if (enhanced) {
327
345
  binddragging &&
@@ -329,7 +347,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
329
347
  getCustomEvent('dragging', e, {
330
348
  detail: {
331
349
  scrollLeft: scrollOptions.current.scrollLeft || 0,
332
- scrollTop: scrollOptions.current.scrollTop || 0,
350
+ scrollTop: scrollOptions.current.scrollTop || 0
333
351
  },
334
352
  layoutRef
335
353
  }, props)
@@ -337,10 +355,10 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
337
355
  }
338
356
  }
339
357
 
340
- function onScrollEndDrag(e: NativeSyntheticEvent<NativeScrollEvent>) {
341
- const { binddragend, enhanced } = props;
358
+ function onScrollEndDrag (e: NativeSyntheticEvent<NativeScrollEvent>) {
359
+ const { binddragend, enhanced } = props
342
360
  if (enhanced) {
343
- const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset;
361
+ const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset
344
362
  const { width: scrollWidth, height: scrollHeight } = e.nativeEvent.contentSize
345
363
  binddragend &&
346
364
  binddragend(
@@ -359,6 +377,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
359
377
  }
360
378
 
361
379
  let scrollAdditionalProps: ScrollAdditionalProps = {
380
+ style: { ...innerStyle, ...layoutStyle },
362
381
  pinchGestureEnabled: false,
363
382
  horizontal: scrollX && !scrollY,
364
383
  scrollEventThrottle: scrollEventThrottle,
@@ -371,19 +390,18 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
371
390
  onContentSizeChange: onContentSizeChange,
372
391
  bindtouchstart: onScrollTouchStart,
373
392
  bindtouchmove: onScrollTouchMove,
374
- onLayout,
375
393
  onScrollEndDrag,
376
- onMomentumScrollEnd: onScrollEnd
377
- };
394
+ onMomentumScrollEnd: onScrollEnd,
395
+ ...layoutProps
396
+ }
378
397
  if (enhanced) {
379
398
  scrollAdditionalProps = {
380
399
  ...scrollAdditionalProps,
381
400
  bounces,
382
- pagingEnabled,
383
- };
401
+ pagingEnabled
402
+ }
384
403
  }
385
404
  const innerProps = useInnerProps(props, scrollAdditionalProps, [
386
- 'enable-offset',
387
405
  'scroll-x',
388
406
  'scroll-y',
389
407
  'enable-back-to-top',
@@ -407,30 +425,42 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
407
425
  'bindscrolltoupper',
408
426
  'bindscrolltolower',
409
427
  'bindrefresherrefresh'
410
- ], { layoutRef });
428
+ ], { layoutRef })
411
429
 
412
430
  const refreshColor = {
413
- 'black': ['#000'],
414
- 'white': ['#fff']
431
+ black: ['#000'],
432
+ white: ['#fff']
415
433
  }
416
434
 
417
435
  return (
418
436
  <ScrollView
419
437
  {...innerProps}
420
- refreshControl={refresherEnabled ? (
438
+ refreshControl={refresherEnabled
439
+ ? (
421
440
  <RefreshControl
422
441
  progressBackgroundColor={refresherBackground}
423
442
  refreshing={refreshing}
424
443
  onRefresh={onRefresh}
425
444
  {...(refresherDefaultStyle && refresherDefaultStyle !== 'none' ? { colors: refreshColor[refresherDefaultStyle] } : {})}
426
445
  />
427
- ) : undefined}
446
+ )
447
+ : undefined}
428
448
  >
429
- {children}
449
+ {
450
+ wrapChildren(
451
+ props,
452
+ {
453
+ hasVarDec,
454
+ varContext: varContextRef.current,
455
+ textStyle,
456
+ textProps
457
+ }
458
+ )
459
+ }
430
460
  </ScrollView>
431
- );
461
+ )
432
462
  })
433
463
 
434
- _ScrollView.displayName = 'mpx-scroll-view';
464
+ _ScrollView.displayName = 'mpx-scroll-view'
435
465
 
436
466
  export default _ScrollView