@mpxjs/webpack-plugin 2.10.5 → 2.10.6

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 (62) hide show
  1. package/lib/index.js +10 -1
  2. package/lib/json-compiler/helper.js +1 -4
  3. package/lib/platform/template/wx/index.js +21 -1
  4. package/lib/resolver/PackageEntryPlugin.js +3 -1
  5. package/lib/runtime/components/react/dist/mpx-button.jsx +7 -2
  6. package/lib/runtime/components/react/dist/mpx-canvas/Image.js +2 -4
  7. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +20 -17
  8. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +7 -2
  9. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +7 -2
  10. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +7 -2
  11. package/lib/runtime/components/react/dist/mpx-image.jsx +9 -2
  12. package/lib/runtime/components/react/dist/mpx-input.jsx +7 -2
  13. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +1 -1
  14. package/lib/runtime/components/react/dist/mpx-label.jsx +7 -2
  15. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +7 -2
  16. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +76 -42
  17. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +11 -13
  18. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +8 -7
  19. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +26 -8
  20. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +9 -2
  21. package/lib/runtime/components/react/dist/mpx-radio.jsx +7 -2
  22. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +7 -2
  23. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +13 -4
  24. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +11 -9
  25. package/lib/runtime/components/react/dist/mpx-swiper.jsx +82 -36
  26. package/lib/runtime/components/react/dist/mpx-switch.jsx +7 -2
  27. package/lib/runtime/components/react/dist/mpx-text.jsx +7 -2
  28. package/lib/runtime/components/react/dist/mpx-video.jsx +7 -2
  29. package/lib/runtime/components/react/dist/mpx-view.jsx +2 -4
  30. package/lib/runtime/components/react/dist/utils.jsx +2 -2
  31. package/lib/runtime/components/react/mpx-button.tsx +9 -1
  32. package/lib/runtime/components/react/mpx-canvas/Image.ts +4 -4
  33. package/lib/runtime/components/react/mpx-canvas/index.tsx +24 -17
  34. package/lib/runtime/components/react/mpx-checkbox-group.tsx +9 -1
  35. package/lib/runtime/components/react/mpx-checkbox.tsx +9 -1
  36. package/lib/runtime/components/react/mpx-icon/index.tsx +9 -1
  37. package/lib/runtime/components/react/mpx-image.tsx +38 -19
  38. package/lib/runtime/components/react/mpx-input.tsx +10 -1
  39. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +1 -1
  40. package/lib/runtime/components/react/mpx-label.tsx +9 -1
  41. package/lib/runtime/components/react/mpx-movable-area.tsx +7 -1
  42. package/lib/runtime/components/react/mpx-movable-view.tsx +75 -42
  43. package/lib/runtime/components/react/mpx-picker/index.tsx +18 -16
  44. package/lib/runtime/components/react/mpx-picker-view/index.tsx +22 -8
  45. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +34 -30
  46. package/lib/runtime/components/react/mpx-radio-group.tsx +20 -9
  47. package/lib/runtime/components/react/mpx-radio.tsx +9 -1
  48. package/lib/runtime/components/react/mpx-rich-text/index.tsx +10 -2
  49. package/lib/runtime/components/react/mpx-scroll-view.tsx +14 -3
  50. package/lib/runtime/components/react/mpx-swiper-item.tsx +11 -19
  51. package/lib/runtime/components/react/mpx-swiper.tsx +95 -38
  52. package/lib/runtime/components/react/mpx-switch.tsx +10 -2
  53. package/lib/runtime/components/react/mpx-text.tsx +10 -2
  54. package/lib/runtime/components/react/mpx-video.tsx +7 -2
  55. package/lib/runtime/components/react/mpx-view.tsx +8 -4
  56. package/lib/runtime/components/react/utils.tsx +4 -4
  57. package/lib/runtime/components/web/mpx-web-view.vue +1 -1
  58. package/lib/runtime/mpxGlobal.js +1 -0
  59. package/lib/runtime/optionProcessor.d.ts +5 -0
  60. package/lib/template-compiler/bind-this.js +8 -7
  61. package/lib/wxs/pre-loader.js +1 -0
  62. package/package.json +4 -4
@@ -24,7 +24,7 @@ import useNodesRef from './useNodesRef';
24
24
  import { MovableAreaContext } from './context';
25
25
  import { useTransformStyle, splitProps, splitStyle, HIDDEN_STYLE, wrapChildren, flatGesture, extendObject, omit, useNavigation } from './utils';
26
26
  import { GestureDetector, Gesture } from 'react-native-gesture-handler';
27
- import Animated, { useSharedValue, useAnimatedStyle, withDecay, runOnJS, runOnUI, useAnimatedReaction, withSpring } from 'react-native-reanimated';
27
+ import Animated, { useSharedValue, useAnimatedStyle, withDecay, runOnJS, runOnUI, withSpring } from 'react-native-reanimated';
28
28
  import { collectDataset, noop } from '@mpxjs/utils';
29
29
  const styles = StyleSheet.create({
30
30
  container: {
@@ -61,6 +61,7 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
61
61
  const yInertialMotion = useSharedValue(false);
62
62
  const isFirstTouch = useSharedValue(true);
63
63
  const touchEvent = useSharedValue('');
64
+ const initialViewPosition = useSharedValue({ x: x || 0, y: y || 0 });
64
65
  const MovableAreaLayout = useContext(MovableAreaContext);
65
66
  const simultaneousHandlers = flatGesture(originSimultaneousHandlers);
66
67
  const waitForHandlers = flatGesture(waitFor);
@@ -118,11 +119,13 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
118
119
  })
119
120
  : newY;
120
121
  }
121
- runOnJS(handleTriggerChange)({
122
- x: newX,
123
- y: newY,
124
- type: 'setData'
125
- });
122
+ if (propsRef.current.bindchange) {
123
+ runOnJS(handleTriggerChange)({
124
+ x: newX,
125
+ y: newY,
126
+ type: 'setData'
127
+ });
128
+ }
126
129
  }
127
130
  })();
128
131
  }, [x, y]);
@@ -132,16 +135,6 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
132
135
  resetBoundaryAndCheck({ width, height });
133
136
  }
134
137
  }, [MovableAreaLayout.height, MovableAreaLayout.width]);
135
- useAnimatedReaction(() => ({
136
- offsetX: offsetX.value,
137
- offsetY: offsetY.value
138
- }), (currentValue) => {
139
- const { offsetX, offsetY } = currentValue;
140
- runOnJS(handleTriggerChange)({
141
- x: offsetX,
142
- y: offsetY
143
- });
144
- });
145
138
  const getTouchSource = useCallback((offsetX, offsetY) => {
146
139
  const hasOverBoundary = offsetX < draggableXRange.value[0] || offsetX > draggableXRange.value[1] ||
147
140
  offsetY < draggableYRange.value[0] || offsetY > draggableYRange.value[1];
@@ -315,6 +308,13 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
315
308
  if (bindtouchstart || catchtouchstart) {
316
309
  runOnJS(triggerStartOnJS)({ e });
317
310
  }
311
+ })
312
+ .onStart(() => {
313
+ 'worklet';
314
+ initialViewPosition.value = {
315
+ x: offsetX.value,
316
+ y: offsetY.value
317
+ };
318
318
  })
319
319
  .onTouchesMove((e) => {
320
320
  'worklet';
@@ -325,12 +325,13 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
325
325
  isFirstTouch.value = false;
326
326
  }
327
327
  handleTriggerMove(e);
328
+ })
329
+ .onUpdate((e) => {
330
+ 'worklet';
328
331
  if (disabled)
329
332
  return;
330
- const changeX = changedTouches.x - startPosition.value.x;
331
- const changeY = changedTouches.y - startPosition.value.y;
332
333
  if (direction === 'horizontal' || direction === 'all') {
333
- const newX = offsetX.value + changeX;
334
+ const newX = initialViewPosition.value.x + e.translationX;
334
335
  if (!outOfBounds) {
335
336
  const { x } = checkBoundaryPosition({ positionX: newX, positionY: offsetY.value });
336
337
  offsetX.value = x;
@@ -340,7 +341,7 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
340
341
  }
341
342
  }
342
343
  if (direction === 'vertical' || direction === 'all') {
343
- const newY = offsetY.value + changeY;
344
+ const newY = initialViewPosition.value.y + e.translationY;
344
345
  if (!outOfBounds) {
345
346
  const { y } = checkBoundaryPosition({ positionX: offsetX.value, positionY: newY });
346
347
  offsetY.value = y;
@@ -349,6 +350,12 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
349
350
  offsetY.value = newY;
350
351
  }
351
352
  }
353
+ if (propsRef.current.bindchange) {
354
+ runOnJS(handleTriggerChange)({
355
+ x: offsetX.value,
356
+ y: offsetY.value
357
+ });
358
+ }
352
359
  })
353
360
  .onTouchesUp((e) => {
354
361
  'worklet';
@@ -357,33 +364,42 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
357
364
  if (bindtouchend || catchtouchend) {
358
365
  runOnJS(triggerEndOnJS)({ e });
359
366
  }
367
+ })
368
+ .onEnd((e) => {
369
+ 'worklet';
370
+ isMoving.value = false;
360
371
  if (disabled)
361
372
  return;
362
- if (!inertia) {
373
+ // 处理没有惯性且超出边界的回弹
374
+ if (!inertia && outOfBounds) {
363
375
  const { x, y } = checkBoundaryPosition({ positionX: offsetX.value, positionY: offsetY.value });
364
- if (x !== offsetX.value) {
365
- offsetX.value = animation
366
- ? withSpring(x, {
367
- duration: 1500,
368
- dampingRatio: 0.8
369
- })
370
- : x;
371
- }
372
- if (y !== offsetY.value) {
373
- offsetY.value = animation
374
- ? withSpring(y, {
375
- duration: 1500,
376
- dampingRatio: 0.8
377
- })
378
- : y;
376
+ if (x !== offsetX.value || y !== offsetY.value) {
377
+ if (x !== offsetX.value) {
378
+ offsetX.value = animation
379
+ ? withSpring(x, {
380
+ duration: 1500,
381
+ dampingRatio: 0.8
382
+ })
383
+ : x;
384
+ }
385
+ if (y !== offsetY.value) {
386
+ offsetY.value = animation
387
+ ? withSpring(y, {
388
+ duration: 1500,
389
+ dampingRatio: 0.8
390
+ })
391
+ : y;
392
+ }
393
+ if (propsRef.current.bindchange) {
394
+ runOnJS(handleTriggerChange)({
395
+ x,
396
+ y
397
+ });
398
+ }
379
399
  }
380
- }
381
- })
382
- .onFinalize((e) => {
383
- 'worklet';
384
- isMoving.value = false;
385
- if (!inertia || disabled || !animation)
386
400
  return;
401
+ }
402
+ // 惯性处理
387
403
  if (direction === 'horizontal' || direction === 'all') {
388
404
  xInertialMotion.value = true;
389
405
  offsetX.value = withDecay({
@@ -392,6 +408,12 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
392
408
  clamp: draggableXRange.value
393
409
  }, () => {
394
410
  xInertialMotion.value = false;
411
+ if (propsRef.current.bindchange) {
412
+ runOnJS(handleTriggerChange)({
413
+ x: offsetX.value,
414
+ y: offsetY.value
415
+ });
416
+ }
395
417
  });
396
418
  }
397
419
  if (direction === 'vertical' || direction === 'all') {
@@ -402,10 +424,22 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
402
424
  clamp: draggableYRange.value
403
425
  }, () => {
404
426
  yInertialMotion.value = false;
427
+ if (propsRef.current.bindchange) {
428
+ runOnJS(handleTriggerChange)({
429
+ x: offsetX.value,
430
+ y: offsetY.value
431
+ });
432
+ }
405
433
  });
406
434
  }
407
435
  })
408
436
  .withRef(movableGestureRef);
437
+ if (direction === 'horizontal') {
438
+ gesturePan.activeOffsetX([-5, 5]).failOffsetY([-5, 5]);
439
+ }
440
+ else if (direction === 'vertical') {
441
+ gesturePan.activeOffsetY([-5, 5]).failOffsetX([-5, 5]);
442
+ }
409
443
  if (simultaneousHandlers && simultaneousHandlers.length) {
410
444
  gesturePan.simultaneousWithExternalGesture(...simultaneousHandlers);
411
445
  }
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, useRef, useContext, useEffect } from 'react';
1
+ import React, { forwardRef, useRef, useContext, useEffect, createElement } from 'react';
2
2
  import { StyleSheet, Text, TouchableWithoutFeedback, View } from 'react-native';
3
3
  import { warn } from '@mpxjs/utils';
4
4
  import PickerSelector from './selector';
@@ -9,7 +9,7 @@ import PickerRegion from './region';
9
9
  import { FormContext, RouteContext } from '../context';
10
10
  import useNodesRef from '../useNodesRef';
11
11
  import useInnerProps, { getCustomEvent } from '../getInnerListeners';
12
- import { extendObject } from '../utils';
12
+ import { extendObject, useLayout } from '../utils';
13
13
  import { createPopupManager } from '../mpx-popup';
14
14
  /**
15
15
  * ✔ mode
@@ -109,17 +109,18 @@ const Picker = forwardRef((props, ref) => {
109
109
  const buttonText = buttonTextMap[global.__mpx?.i18n?.locale || 'zh-CN'];
110
110
  const pickerValue = useRef(value);
111
111
  pickerValue.current = Array.isArray(value) ? value.slice() : value;
112
- const innerLayout = useRef({});
113
112
  const nodeRef = useRef(null);
114
113
  const pickerRef = useRef(null);
115
114
  const { open, show, hide, remove } = useRef(createPopupManager()).current;
116
115
  useNodesRef(props, ref, nodeRef);
116
+ const { layoutRef, layoutProps } = useLayout({
117
+ props,
118
+ hasSelfPercent: false,
119
+ nodeRef
120
+ });
117
121
  const innerProps = useInnerProps(extendObject({}, props, {
118
122
  ref: nodeRef
119
- }), [], { layoutRef: innerLayout });
120
- const getInnerLayout = (layout) => {
121
- innerLayout.current = layout.current;
122
- };
123
+ }, layoutProps), [], { layoutRef });
123
124
  useEffect(() => {
124
125
  if (range && pickerRef.current && mode === "multiSelector" /* PickerMode.MULTI_SELECTOR */) {
125
126
  pickerRef.current.updateRange?.(range);
@@ -162,7 +163,7 @@ const Picker = forwardRef((props, ref) => {
162
163
  if (mode !== "multiSelector" /* PickerMode.MULTI_SELECTOR */) {
163
164
  return;
164
165
  }
165
- const eventData = getCustomEvent('columnchange', {}, { detail: { column: columnIndex, value }, layoutRef: innerLayout });
166
+ const eventData = getCustomEvent('columnchange', {}, { detail: { column: columnIndex, value }, layoutRef });
166
167
  props.bindcolumnchange?.(eventData);
167
168
  };
168
169
  const onCancel = () => {
@@ -170,7 +171,7 @@ const Picker = forwardRef((props, ref) => {
170
171
  hide();
171
172
  };
172
173
  const onConfirm = () => {
173
- const eventData = getCustomEvent('change', {}, { detail: { value: pickerValue.current }, layoutRef: innerLayout });
174
+ const eventData = getCustomEvent('change', {}, { detail: { value: pickerValue.current }, layoutRef });
174
175
  bindchange?.(eventData);
175
176
  hide();
176
177
  };
@@ -179,7 +180,6 @@ const Picker = forwardRef((props, ref) => {
179
180
  children,
180
181
  bindchange: onChange,
181
182
  bindcolumnchange: onColumnChange,
182
- getInnerLayout,
183
183
  getRange: () => range
184
184
  });
185
185
  const renderPickerContent = () => {
@@ -215,9 +215,7 @@ const Picker = forwardRef((props, ref) => {
215
215
  remove();
216
216
  };
217
217
  }, []);
218
- return (<TouchableWithoutFeedback onPress={show}>
219
- {children}
220
- </TouchableWithoutFeedback>);
218
+ return createElement(TouchableWithoutFeedback, { onPress: show }, createElement(View, innerProps, children));
221
219
  });
222
220
  Picker.displayName = 'MpxPicker';
223
221
  export default Picker;
@@ -1,9 +1,10 @@
1
1
  import { View } from 'react-native';
2
- import React, { forwardRef, useRef } from 'react';
2
+ import React, { createElement, forwardRef, useRef } from 'react';
3
3
  import useInnerProps, { getCustomEvent } from '../getInnerListeners';
4
4
  import useNodesRef from '../useNodesRef';
5
5
  import { useLayout, splitProps, splitStyle, wrapChildren, useTransformStyle, extendObject } from '../utils';
6
6
  import { PickerViewStyleContext } from './pickerVIewContext';
7
+ import Portal from '../mpx-portal';
7
8
  const styles = {
8
9
  wrapper: {
9
10
  display: 'flex',
@@ -23,7 +24,7 @@ const _PickerView = forwardRef((props, ref) => {
23
24
  const activeValueRef = useRef(value);
24
25
  activeValueRef.current = value.slice();
25
26
  const snapActiveValueRef = useRef(null);
26
- const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext });
27
+ const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(style, { enableVar, externalVarContext });
27
28
  useNodesRef(props, ref, nodeRef, {
28
29
  style: normalStyle
29
30
  });
@@ -114,11 +115,11 @@ const _PickerView = forwardRef((props, ref) => {
114
115
  onInitialChange(isInvalid, validValue);
115
116
  return renderColumns;
116
117
  };
117
- return (<PickerViewStyleContext.Provider value={textStyle}>
118
- <View {...innerProps}>
119
- <View style={[styles.wrapper]}>{renderPickerColumns()}</View>
120
- </View>
121
- </PickerViewStyleContext.Provider>);
118
+ const finalComponent = createElement(PickerViewStyleContext.Provider, { value: textStyle }, createElement(View, innerProps, createElement(View, { style: [styles.wrapper] }, renderPickerColumns())));
119
+ if (hasPositionFixed) {
120
+ return createElement(Portal, null, finalComponent);
121
+ }
122
+ return finalComponent;
122
123
  });
123
124
  _PickerView.displayName = 'MpxPickerView';
124
125
  export default _PickerView;
@@ -1,7 +1,7 @@
1
- import React, { forwardRef, useRef, useState, useMemo, useEffect, useCallback } from 'react';
1
+ import React, { forwardRef, useRef, useState, useMemo, useEffect, useCallback, createElement } from 'react';
2
2
  import { StyleSheet, View } from 'react-native';
3
3
  import Reanimated, { useAnimatedRef, useScrollViewOffset } from 'react-native-reanimated';
4
- import { useTransformStyle, splitStyle, splitProps, useLayout, usePrevious, isAndroid, isIOS, isHarmony } from '../utils';
4
+ import { useTransformStyle, splitStyle, splitProps, useLayout, usePrevious, isAndroid, isIOS, isHarmony, extendObject } from '../utils';
5
5
  import useNodesRef from '../useNodesRef';
6
6
  import PickerIndicator from './pickerViewIndicator';
7
7
  import PickerMask from './pickerViewMask';
@@ -220,11 +220,28 @@ const _PickerViewColumn = forwardRef((props, ref) => {
220
220
  return (<MpxPickerVIewColumnItem key={index} item={item} index={index} itemHeight={itemHeight} textStyle={textStyle} textProps={textProps} visibleCount={visibleCount} onItemLayout={onItemLayout}/>);
221
221
  });
222
222
  const renderScollView = () => {
223
- return (<PickerViewColumnAnimationContext.Provider value={offsetYShared}>
224
- <Reanimated.ScrollView ref={scrollViewRef} bounces={true} horizontal={false} nestedScrollEnabled={true} removeClippedSubviews={false} showsVerticalScrollIndicator={false} showsHorizontalScrollIndicator={false} scrollEventThrottle={16} {...layoutProps} onTouchEnd={onClickOnceItem} style={[{ width: '100%' }]} decelerationRate="fast" snapToOffsets={snapToOffsets} onScroll={onScroll} onScrollBeginDrag={onScrollBeginDrag} onScrollEndDrag={onScrollEndDrag} onMomentumScrollBegin={onMomentumScrollBegin} onMomentumScrollEnd={onMomentumScrollEnd} onContentSizeChange={onContentSizeChange} contentContainerStyle={contentContainerStyle}>
225
- {renderInnerchild()}
226
- </Reanimated.ScrollView>
227
- </PickerViewColumnAnimationContext.Provider>);
223
+ const innerProps = extendObject({}, layoutProps, {
224
+ ref: scrollViewRef,
225
+ bounces: true,
226
+ horizontal: false,
227
+ nestedScrollEnabled: true,
228
+ removeClippedSubviews: false,
229
+ showsVerticalScrollIndicator: false,
230
+ showsHorizontalScrollIndicator: false,
231
+ scrollEventThrottle: 16,
232
+ style: styles.scrollView,
233
+ decelerationRate: 'fast',
234
+ snapToOffsets: snapToOffsets,
235
+ onTouchEnd: onClickOnceItem,
236
+ onScroll,
237
+ onScrollBeginDrag,
238
+ onScrollEndDrag,
239
+ onMomentumScrollBegin,
240
+ onMomentumScrollEnd,
241
+ onContentSizeChange,
242
+ contentContainerStyle
243
+ });
244
+ return createElement(PickerViewColumnAnimationContext.Provider, { value: offsetYShared }, createElement(Reanimated.ScrollView, innerProps, renderInnerchild()));
228
245
  };
229
246
  const renderIndicator = () => (<PickerIndicator itemHeight={itemHeight} indicatorItemStyle={pickerIndicatorStyle}/>);
230
247
  const renderMask = () => (<PickerMask itemHeight={itemHeight} maskContainerStyle={pickerMaskStyle}/>);
@@ -235,7 +252,8 @@ const _PickerViewColumn = forwardRef((props, ref) => {
235
252
  </View>);
236
253
  });
237
254
  const styles = StyleSheet.create({
238
- wrapper: { display: 'flex', flex: 1 }
255
+ wrapper: { display: 'flex', flex: 1 },
256
+ scrollView: { width: '100%' }
239
257
  });
240
258
  _PickerViewColumn.displayName = 'MpxPickerViewColumn';
241
259
  export default _PickerViewColumn;
@@ -8,6 +8,7 @@ import { FormContext, RadioGroupContext } from './context';
8
8
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
9
9
  import useNodesRef from './useNodesRef';
10
10
  import { useLayout, useTransformStyle, wrapChildren, extendObject } from './utils';
11
+ import Portal from './mpx-portal';
11
12
  const radioGroup = forwardRef((props, ref) => {
12
13
  const { style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
13
14
  const propsRef = useRef({});
@@ -23,7 +24,7 @@ const radioGroup = forwardRef((props, ref) => {
23
24
  flexWrap: 'wrap'
24
25
  };
25
26
  const styleObj = extendObject({}, defaultStyle, style);
26
- const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
27
+ const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
27
28
  const nodeRef = useRef(null);
28
29
  useNodesRef(props, ref, nodeRef, { style: normalStyle });
29
30
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
@@ -77,10 +78,16 @@ const radioGroup = forwardRef((props, ref) => {
77
78
  }), ['name'], {
78
79
  layoutRef
79
80
  });
80
- return createElement(View, innerProps, createElement(RadioGroupContext.Provider, { value: contextValue }, wrapChildren(props, {
81
+ const finalComponent = createElement(View, innerProps, createElement(RadioGroupContext.Provider, {
82
+ value: contextValue
83
+ }, wrapChildren(props, {
81
84
  hasVarDec,
82
85
  varContext: varContextRef.current
83
86
  })));
87
+ if (hasPositionFixed) {
88
+ return createElement(Portal, null, finalComponent);
89
+ }
90
+ return finalComponent;
84
91
  });
85
92
  radioGroup.displayName = 'MpxRadioGroup';
86
93
  export default radioGroup;
@@ -12,6 +12,7 @@ import useInnerProps, { getCustomEvent } from './getInnerListeners';
12
12
  import useNodesRef from './useNodesRef';
13
13
  import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils';
14
14
  import Icon from './mpx-icon';
15
+ import Portal from './mpx-portal';
15
16
  const styles = StyleSheet.create({
16
17
  container: {
17
18
  flexDirection: 'row',
@@ -73,7 +74,7 @@ const Radio = forwardRef((radioProps, ref) => {
73
74
  bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props));
74
75
  onChange(evt);
75
76
  };
76
- const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
77
+ const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
77
78
  const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle);
78
79
  if (backgroundStyle) {
79
80
  warn('Radio does not support background image-related styles!');
@@ -123,7 +124,7 @@ const Radio = forwardRef((radioProps, ref) => {
123
124
  }
124
125
  }
125
126
  }, [checked]);
126
- return createElement(View, innerProps, createElement(View, { style: defaultStyle }, createElement(Icon, {
127
+ const finalComponent = createElement(View, innerProps, createElement(View, { style: defaultStyle }, createElement(Icon, {
127
128
  type: 'success',
128
129
  size: 24,
129
130
  color: disabled ? '#E1E1E1' : color,
@@ -134,6 +135,10 @@ const Radio = forwardRef((radioProps, ref) => {
134
135
  textStyle,
135
136
  textProps
136
137
  }));
138
+ if (hasPositionFixed) {
139
+ return createElement(Portal, null, finalComponent);
140
+ }
141
+ return finalComponent;
137
142
  });
138
143
  Radio.displayName = 'MpxRadio';
139
144
  export default Radio;
@@ -8,6 +8,7 @@ import useNodesRef from '../useNodesRef'; // 引入辅助函数
8
8
  import { useTransformStyle, useLayout, extendObject } from '../utils';
9
9
  import { WebView } from 'react-native-webview';
10
10
  import { generateHTML } from './html';
11
+ import Portal from '../mpx-portal';
11
12
  function jsonToHtmlStr(elements) {
12
13
  let htmlStr = '';
13
14
  for (const element of elements) {
@@ -30,7 +31,7 @@ const _RichText = forwardRef((props, ref) => {
30
31
  const { style = {}, nodes, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
31
32
  const nodeRef = useRef(null);
32
33
  const [webViewHeight, setWebViewHeight] = useState(0);
33
- const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(Object.assign({
34
+ const { normalStyle, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(Object.assign({
34
35
  width: '100%',
35
36
  height: webViewHeight
36
37
  }, style), {
@@ -51,12 +52,16 @@ const _RichText = forwardRef((props, ref) => {
51
52
  layoutRef
52
53
  });
53
54
  const html = typeof nodes === 'string' ? nodes : jsonToHtmlStr(nodes);
54
- return createElement(View, innerProps, createElement(WebView, {
55
+ let finalComponent = createElement(View, innerProps, createElement(WebView, {
55
56
  source: { html: generateHTML(html) },
56
57
  onMessage: (event) => {
57
58
  setWebViewHeight(+event.nativeEvent.data);
58
59
  }
59
60
  }));
61
+ if (hasPositionFixed) {
62
+ finalComponent = createElement(Portal, null, finalComponent);
63
+ }
64
+ return finalComponent;
60
65
  });
61
66
  _RichText.displayName = 'mpx-rich-text';
62
67
  export default _RichText;
@@ -34,11 +34,12 @@
34
34
  import { ScrollView, RefreshControl, Gesture, GestureDetector } from 'react-native-gesture-handler';
35
35
  import { isValidElement, Children, useRef, useState, useEffect, forwardRef, useContext, useMemo, createElement } from 'react';
36
36
  import Animated, { useAnimatedRef, useSharedValue, withTiming, useAnimatedStyle, runOnJS } from 'react-native-reanimated';
37
- import { warn } from '@mpxjs/utils';
37
+ import { warn, hasOwn } from '@mpxjs/utils';
38
38
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
39
39
  import useNodesRef from './useNodesRef';
40
40
  import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, extendObject, flatGesture, HIDDEN_STYLE } from './utils';
41
41
  import { IntersectionObserverContext, ScrollViewContext } from './context';
42
+ import Portal from './mpx-portal';
42
43
  const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
43
44
  const { textProps, innerProps: props = {} } = splitProps(scrollViewProps);
44
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 = false, 'refresher-enabled': refresherEnabled, 'refresher-default-style': refresherDefaultStyle, 'refresher-background': refresherBackground, 'refresher-threshold': refresherThreshold = 45, '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, 'scroll-event-throttle': scrollEventThrottle = 0, __selectRef } = props;
@@ -72,7 +73,7 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
72
73
  };
73
74
  const { refresherContent, otherContent } = getRefresherContent(props.children);
74
75
  const hasRefresher = refresherContent && refresherEnabled;
75
- const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
76
+ const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, hasPositionFixed, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
76
77
  const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
77
78
  const scrollViewRef = useAnimatedRef();
78
79
  useNodesRef(props, ref, scrollViewRef, {
@@ -464,7 +465,11 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
464
465
  })
465
466
  .simultaneousWithExternalGesture(scrollViewRef);
466
467
  const scrollAdditionalProps = extendObject({
467
- style: extendObject({}, innerStyle, layoutStyle),
468
+ style: extendObject(hasOwn(innerStyle, 'flex') || hasOwn(innerStyle, 'flexGrow')
469
+ ? {}
470
+ : {
471
+ flexGrow: 0
472
+ }, innerStyle, layoutStyle),
468
473
  pinchGestureEnabled: false,
469
474
  alwaysBounceVertical: false,
470
475
  alwaysBounceHorizontal: false,
@@ -540,7 +545,11 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
540
545
  textStyle,
541
546
  textProps
542
547
  })));
543
- return hasRefresher ? withRefresherScrollView : commonScrollView;
548
+ let scrollViewComponent = hasRefresher ? withRefresherScrollView : commonScrollView;
549
+ if (hasPositionFixed) {
550
+ scrollViewComponent = createElement(Portal, null, scrollViewComponent);
551
+ }
552
+ return scrollViewComponent;
544
553
  });
545
554
  _ScrollView.displayName = 'MpxScrollView';
546
555
  export default _ScrollView;
@@ -1,5 +1,5 @@
1
1
  import Animated, { useAnimatedStyle, interpolate } from 'react-native-reanimated';
2
- import { forwardRef, useRef, useContext } from 'react';
2
+ import { forwardRef, useRef, useContext, createElement } from 'react';
3
3
  import useInnerProps from './getInnerListeners';
4
4
  import useNodesRef from './useNodesRef'; // 引入辅助函数
5
5
  import { useTransformStyle, splitStyle, splitProps, wrapChildren, useLayout, extendObject } from './utils';
@@ -45,14 +45,16 @@ const _SwiperItem = forwardRef((props, ref) => {
45
45
  transform: transformStyle
46
46
  });
47
47
  });
48
- return (<Animated.View {...innerProps} style={[innerStyle, layoutStyle, itemAnimatedStyle, customStyle]} data-itemId={props['item-id']}>
49
- {wrapChildren(props, {
50
- hasVarDec,
51
- varContext: varContextRef.current,
52
- textStyle,
53
- textProps
54
- })}
55
- </Animated.View>);
48
+ const mergeProps = extendObject({}, innerProps, {
49
+ style: [innerStyle, layoutStyle, itemAnimatedStyle, customStyle],
50
+ 'data-itemId': props['item-id']
51
+ });
52
+ return createElement(Animated.View, mergeProps, wrapChildren(props, {
53
+ hasVarDec,
54
+ varContext: varContextRef.current,
55
+ textStyle,
56
+ textProps
57
+ }));
56
58
  });
57
59
  _SwiperItem.displayName = 'MpxSwiperItem';
58
60
  export default _SwiperItem;