@mpxjs/webpack-plugin 2.10.4-beta.9 → 2.10.5-beta.1

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 (70) hide show
  1. package/lib/index.js +10 -1
  2. package/lib/json-compiler/helper.js +1 -4
  3. package/lib/platform/style/wx/index.js +22 -21
  4. package/lib/platform/template/wx/index.js +21 -1
  5. package/lib/react/processScript.js +9 -1
  6. package/lib/react/script-helper.js +5 -1
  7. package/lib/resolver/PackageEntryPlugin.js +3 -1
  8. package/lib/runtime/components/react/dist/mpx-button.jsx +9 -4
  9. package/lib/runtime/components/react/dist/mpx-canvas/Image.js +2 -4
  10. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +20 -17
  11. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +7 -2
  12. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +7 -2
  13. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +7 -2
  14. package/lib/runtime/components/react/dist/mpx-image.jsx +9 -2
  15. package/lib/runtime/components/react/dist/mpx-input.jsx +7 -2
  16. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +1 -1
  17. package/lib/runtime/components/react/dist/mpx-label.jsx +7 -2
  18. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +7 -2
  19. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +76 -42
  20. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +11 -13
  21. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +8 -7
  22. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +28 -10
  23. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +9 -2
  24. package/lib/runtime/components/react/dist/mpx-radio.jsx +7 -2
  25. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +7 -2
  26. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +13 -4
  27. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +6 -3
  28. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +11 -9
  29. package/lib/runtime/components/react/dist/mpx-swiper.jsx +82 -36
  30. package/lib/runtime/components/react/dist/mpx-switch.jsx +7 -2
  31. package/lib/runtime/components/react/dist/mpx-text.jsx +7 -2
  32. package/lib/runtime/components/react/dist/mpx-video.jsx +7 -2
  33. package/lib/runtime/components/react/dist/mpx-view.jsx +13 -8
  34. package/lib/runtime/components/react/dist/useAnimationHooks.js +27 -4
  35. package/lib/runtime/components/react/dist/utils.jsx +87 -97
  36. package/lib/runtime/components/react/mpx-button.tsx +12 -3
  37. package/lib/runtime/components/react/mpx-canvas/Image.ts +4 -4
  38. package/lib/runtime/components/react/mpx-canvas/index.tsx +24 -17
  39. package/lib/runtime/components/react/mpx-checkbox-group.tsx +9 -1
  40. package/lib/runtime/components/react/mpx-checkbox.tsx +9 -1
  41. package/lib/runtime/components/react/mpx-icon/index.tsx +9 -1
  42. package/lib/runtime/components/react/mpx-image.tsx +38 -19
  43. package/lib/runtime/components/react/mpx-input.tsx +10 -1
  44. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +1 -1
  45. package/lib/runtime/components/react/mpx-label.tsx +9 -1
  46. package/lib/runtime/components/react/mpx-movable-area.tsx +7 -1
  47. package/lib/runtime/components/react/mpx-movable-view.tsx +75 -42
  48. package/lib/runtime/components/react/mpx-picker/index.tsx +18 -16
  49. package/lib/runtime/components/react/mpx-picker-view/index.tsx +22 -8
  50. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +36 -32
  51. package/lib/runtime/components/react/mpx-radio-group.tsx +20 -9
  52. package/lib/runtime/components/react/mpx-radio.tsx +9 -1
  53. package/lib/runtime/components/react/mpx-rich-text/index.tsx +10 -2
  54. package/lib/runtime/components/react/mpx-scroll-view.tsx +14 -3
  55. package/lib/runtime/components/react/mpx-sticky-header.tsx +7 -4
  56. package/lib/runtime/components/react/mpx-swiper-item.tsx +11 -19
  57. package/lib/runtime/components/react/mpx-swiper.tsx +95 -38
  58. package/lib/runtime/components/react/mpx-switch.tsx +10 -2
  59. package/lib/runtime/components/react/mpx-text.tsx +10 -2
  60. package/lib/runtime/components/react/mpx-video.tsx +7 -2
  61. package/lib/runtime/components/react/mpx-view.tsx +23 -9
  62. package/lib/runtime/components/react/useAnimationHooks.ts +30 -9
  63. package/lib/runtime/components/react/utils.tsx +95 -102
  64. package/lib/runtime/components/web/mpx-web-view.vue +1 -1
  65. package/lib/runtime/mpxGlobal.js +1 -0
  66. package/lib/runtime/optionProcessor.d.ts +5 -0
  67. package/lib/template-compiler/bind-this.js +8 -7
  68. package/lib/template-compiler/compiler.js +1 -1
  69. package/lib/wxs/pre-loader.js +1 -0
  70. package/package.json +2 -2
@@ -42,7 +42,8 @@ import {
42
42
  TextStyle,
43
43
  Animated,
44
44
  Easing,
45
- NativeSyntheticEvent
45
+ NativeSyntheticEvent,
46
+ useAnimatedValue
46
47
  } from 'react-native'
47
48
  import { warn } from '@mpxjs/utils'
48
49
  import { GestureDetector, PanGesture } from 'react-native-gesture-handler'
@@ -51,6 +52,7 @@ import useInnerProps, { getCustomEvent } from './getInnerListeners'
51
52
  import useNodesRef, { HandlerRef } from './useNodesRef'
52
53
  import { RouteContext, FormContext } from './context'
53
54
  import type { ExtendedViewStyle } from './types/common'
55
+ import Portal from './mpx-portal'
54
56
 
55
57
  export type Type = 'default' | 'primary' | 'warn'
56
58
 
@@ -156,7 +158,7 @@ const timer = (data: any, time = 3000) => new Promise((resolve) => {
156
158
  })
157
159
 
158
160
  const Loading = ({ alone = false }: { alone: boolean }): JSX.Element => {
159
- const image = useRef(new Animated.Value(0)).current
161
+ const image = useAnimatedValue(0)
160
162
 
161
163
  const rotate = image.interpolate({
162
164
  inputRange: [0, 1],
@@ -290,6 +292,7 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
290
292
  )
291
293
 
292
294
  const {
295
+ hasPositionFixed,
293
296
  hasSelfPercent,
294
297
  normalStyle,
295
298
  hasVarDec,
@@ -412,9 +415,15 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
412
415
  )
413
416
  )
414
417
 
415
- return enableHover
418
+ const finalComponent = enableHover
416
419
  ? createElement(GestureDetector, { gesture: gesture as PanGesture }, baseButton)
417
420
  : baseButton
421
+
422
+ if (hasPositionFixed) {
423
+ return createElement(Portal, null, finalComponent)
424
+ }
425
+
426
+ return finalComponent
418
427
  })
419
428
 
420
429
  Button.displayName = 'MpxButton'
@@ -1,4 +1,5 @@
1
1
  import { WebviewMessage, WEBVIEW_TARGET, registerWebviewProperties, CanvasInstance } from './utils'
2
+ import { extendObject } from '../utils'
2
3
 
3
4
  const PROPERTIES = {
4
5
  crossOrigin: undefined,
@@ -60,10 +61,9 @@ export class Image {
60
61
  this[key] = value
61
62
  }
62
63
  }
63
- callbackFn({
64
- ...message.payload,
65
- target: this
66
- })
64
+ callbackFn(
65
+ extendObject({}, message.payload, { target: this })
66
+ )
67
67
  }
68
68
  })
69
69
  }
@@ -9,7 +9,7 @@
9
9
  * ✔ bindlongtap
10
10
  * ✔ binderror
11
11
  */
12
- import React, { createElement, useRef, useState, useCallback, useEffect, forwardRef, JSX, TouchEvent, MutableRefObject } from 'react'
12
+ import { createElement, useRef, useState, useCallback, useEffect, forwardRef, JSX, TouchEvent, MutableRefObject } from 'react'
13
13
  import { View, Platform, StyleSheet, NativeSyntheticEvent } from 'react-native'
14
14
  import { WebView } from 'react-native-webview'
15
15
  import useNodesRef, { HandlerRef } from '../useNodesRef'
@@ -31,6 +31,7 @@ import './CanvasGradient'
31
31
  import { createImage as canvasCreateImage } from './Image'
32
32
  import { createImageData as canvasCreateImageData } from './ImageData'
33
33
  import { useConstructorsRegistry } from './constructorsRegistry'
34
+ import Portal from '../mpx-portal'
34
35
 
35
36
  const stylesheet = StyleSheet.create({
36
37
  container: { overflow: 'hidden', flex: 0 },
@@ -71,6 +72,7 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
71
72
  const {
72
73
  normalStyle,
73
74
  hasSelfPercent,
75
+ hasPositionFixed,
74
76
  setWidth,
75
77
  setHeight
76
78
  } = useTransformStyle(extendObject({}, style, stylesheet.container), {
@@ -166,10 +168,7 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
166
168
 
167
169
  const postMessage = useCallback(async (message: WebviewMessage) => {
168
170
  if (!canvasRef.current?.bus) return
169
- const { type, payload } = await canvasRef.current.bus.post({
170
- id: ID(),
171
- ...message
172
- })
171
+ const { type, payload } = await canvasRef.current.bus.post(extendObject({ id: ID() }, message))
173
172
 
174
173
  switch (type) {
175
174
  case 'error': {
@@ -204,7 +203,7 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
204
203
  }
205
204
 
206
205
  const onMessage = useCallback((e: { nativeEvent: { data: string } }) => {
207
- let data = JSON.parse(e.nativeEvent.data)
206
+ const data = JSON.parse(e.nativeEvent.data)
208
207
  switch (data.type) {
209
208
  case 'error': {
210
209
  const { binderror } = props
@@ -220,27 +219,27 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
220
219
  break
221
220
  }
222
221
  default: {
222
+ const newData: { payload?: unknown } = {}
223
+ // createLinearGradient 方法调用需要在 constructors 中需要注册 CanvasGradient
224
+ const constructor = constructors[data.meta.constructor]
223
225
  if (data.payload) {
224
- // createLinearGradient 方法调用需要在 constructors 中需要注册 CanvasGradient
225
- const constructor = constructors[data.meta.constructor]
226
226
  if (constructor) {
227
227
  const { args, payload } = data
228
228
  // RN 端同步生成一个 CanvasGradient 的实例
229
229
  const object = constructor.constructLocally(canvasRef.current, ...args)
230
- Object.assign(object, payload, {
230
+ extendObject(object, payload, {
231
231
  [WEBVIEW_TARGET]: data.meta.target
232
232
  })
233
- data = {
234
- ...data,
233
+ extendObject(newData, data, {
235
234
  payload: object
236
- }
235
+ })
237
236
  }
238
237
  for (const listener of canvasRef.current.listeners) {
239
- listener(data.payload)
238
+ listener(constructor ? newData.payload : data.payload)
240
239
  }
241
240
  }
242
241
  if (canvasRef.current.bus) {
243
- canvasRef.current.bus.handle(data)
242
+ canvasRef.current.bus.handle(constructor && data.payload ? newData : data)
244
243
  }
245
244
  }
246
245
  }
@@ -259,9 +258,11 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
259
258
  context: context2D
260
259
  })
261
260
 
262
- if (__mpx_mode__ !== 'ios') {
261
+ let canvasComponent
262
+
263
+ if (__mpx_mode__ === 'android') {
263
264
  const isAndroid9 = Platform.Version as number >= 28
264
- return createElement(View, innerProps, createElement(
265
+ canvasComponent = createElement(View, innerProps, createElement(
265
266
  WebView,
266
267
  {
267
268
  ref: (element) => {
@@ -288,7 +289,7 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
288
289
  )
289
290
  }
290
291
 
291
- return createElement(View, innerProps, createElement(WebView, {
292
+ canvasComponent = createElement(View, innerProps, createElement(WebView, {
292
293
  ref: (element) => {
293
294
  if (canvasRef.current) {
294
295
  canvasRef.current.webview = element
@@ -301,6 +302,12 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
301
302
  onLoad: onLoad,
302
303
  scrollEnabled: false
303
304
  }))
305
+
306
+ if (hasPositionFixed) {
307
+ canvasComponent = createElement(Portal, null, canvasComponent)
308
+ }
309
+
310
+ return canvasComponent
304
311
  })
305
312
 
306
313
  _Canvas.displayName = 'mpxCanvas'
@@ -21,6 +21,7 @@ import { FormContext, FormFieldValue, CheckboxGroupContext, GroupValue } from '.
21
21
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
22
22
  import useNodesRef, { HandlerRef } from './useNodesRef'
23
23
  import { useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
24
+ import Portal from './mpx-portal'
24
25
 
25
26
  export interface CheckboxGroupProps {
26
27
  name: string
@@ -68,6 +69,7 @@ const CheckboxGroup = forwardRef<
68
69
  const styleObj = extendObject({}, defaultStyle, style)
69
70
 
70
71
  const {
72
+ hasPositionFixed,
71
73
  hasSelfPercent,
72
74
  normalStyle,
73
75
  hasVarDec,
@@ -159,7 +161,7 @@ const CheckboxGroup = forwardRef<
159
161
  }
160
162
  }, [])
161
163
 
162
- return createElement(
164
+ const finalComponent = createElement(
163
165
  View,
164
166
  innerProps,
165
167
  createElement(
@@ -174,6 +176,12 @@ const CheckboxGroup = forwardRef<
174
176
  )
175
177
  )
176
178
  )
179
+
180
+ if (hasPositionFixed) {
181
+ return createElement(Portal, null, finalComponent)
182
+ }
183
+
184
+ return finalComponent
177
185
  })
178
186
 
179
187
  CheckboxGroup.displayName = 'MpxCheckboxGroup'
@@ -28,6 +28,7 @@ import useNodesRef, { HandlerRef } from './useNodesRef'
28
28
  import Icon from './mpx-icon'
29
29
  import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
30
30
  import { CheckboxGroupContext, LabelContext } from './context'
31
+ import Portal from './mpx-portal'
31
32
 
32
33
  interface Selection {
33
34
  value?: string
@@ -128,6 +129,7 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
128
129
  }
129
130
 
130
131
  const {
132
+ hasPositionFixed,
131
133
  hasSelfPercent,
132
134
  normalStyle,
133
135
  hasVarDec,
@@ -206,7 +208,7 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
206
208
  }
207
209
  }, [checked])
208
210
 
209
- return createElement(View, innerProps,
211
+ const finalComponent = createElement(View, innerProps,
210
212
  createElement(
211
213
  View,
212
214
  { style: defaultStyle },
@@ -227,6 +229,12 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
227
229
  }
228
230
  )
229
231
  )
232
+
233
+ if (hasPositionFixed) {
234
+ return createElement(Portal, null, finalComponent)
235
+ }
236
+
237
+ return finalComponent
230
238
  }
231
239
  )
232
240
 
@@ -17,6 +17,7 @@ import Cancel from './icons/cancel.png'
17
17
  import Download from './icons/download.png'
18
18
  import Search from './icons/search.png'
19
19
  import Clear from './icons/clear.png'
20
+ import Portal from '../mpx-portal'
20
21
 
21
22
  export type IconType =
22
23
  | 'success'
@@ -75,6 +76,7 @@ const Icon = forwardRef<HandlerRef<Text, IconProps>, IconProps>(
75
76
  const styleObj = extendObject({}, defaultStyle, style)
76
77
 
77
78
  const {
79
+ hasPositionFixed,
78
80
  hasSelfPercent,
79
81
  normalStyle,
80
82
  setWidth,
@@ -103,7 +105,13 @@ const Icon = forwardRef<HandlerRef<Text, IconProps>, IconProps>(
103
105
  }
104
106
  )
105
107
 
106
- return createElement(Image, innerProps)
108
+ const finalComponent = createElement(Image, innerProps)
109
+
110
+ if (hasPositionFixed) {
111
+ return createElement(Portal, null, finalComponent)
112
+ }
113
+
114
+ return finalComponent
107
115
  }
108
116
  )
109
117
 
@@ -27,6 +27,7 @@ import { SvgCssUri } from 'react-native-svg/css'
27
27
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
28
28
  import useNodesRef, { HandlerRef } from './useNodesRef'
29
29
  import { SVG_REGEXP, useLayout, useTransformStyle, renderImage, extendObject } from './utils'
30
+ import Portal from './mpx-portal'
30
31
 
31
32
  export type Mode =
32
33
  | 'scaleToFill'
@@ -159,7 +160,13 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
159
160
  }
160
161
  }
161
162
 
162
- const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
163
+ const {
164
+ hasPositionFixed,
165
+ hasSelfPercent,
166
+ normalStyle,
167
+ setWidth,
168
+ setHeight
169
+ } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
163
170
 
164
171
  const { layoutRef, layoutStyle, layoutProps } = useLayout({
165
172
  props,
@@ -356,25 +363,31 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
356
363
 
357
364
  useEffect(() => {
358
365
  if (!isSvg && isLayoutMode) {
359
- RNImage.getSize(src, (width: number, height: number) => {
360
- state.current.imageWidth = width
361
- state.current.imageHeight = height
362
- state.current.ratio = !width ? 0 : height / width
363
-
364
- if (isWidthFixMode
365
- ? state.current.viewWidth
366
- : isHeightFixMode
367
- ? state.current.viewHeight
368
- : state.current.viewWidth && state.current.viewHeight) {
369
- state.current.viewWidth && setViewWidth(state.current.viewWidth)
370
- state.current.viewHeight && setViewHeight(state.current.viewHeight)
371
- setRatio(!width ? 0 : height / width)
372
- setImageWidth(width)
373
- setImageHeight(height)
374
- state.current = {}
366
+ RNImage.getSize(
367
+ src,
368
+ (width: number, height: number) => {
369
+ state.current.imageWidth = width
370
+ state.current.imageHeight = height
371
+ state.current.ratio = !width ? 0 : height / width
372
+
373
+ if (isWidthFixMode
374
+ ? state.current.viewWidth
375
+ : isHeightFixMode
376
+ ? state.current.viewHeight
377
+ : state.current.viewWidth && state.current.viewHeight) {
378
+ state.current.viewWidth && setViewWidth(state.current.viewWidth)
379
+ state.current.viewHeight && setViewHeight(state.current.viewHeight)
380
+ setRatio(!width ? 0 : height / width)
381
+ setImageWidth(width)
382
+ setImageHeight(height)
383
+ state.current = {}
384
+ setLoaded(true)
385
+ }
386
+ },
387
+ () => {
375
388
  setLoaded(true)
376
389
  }
377
- })
390
+ )
378
391
  }
379
392
  }, [src, isSvg, isLayoutMode])
380
393
 
@@ -441,7 +454,13 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
441
454
 
442
455
  const LayoutImage = createElement(View, innerProps, loaded && BaseImage)
443
456
 
444
- return isSvg ? SvgImage : isLayoutMode ? LayoutImage : BaseImage
457
+ const finalComponent = isSvg ? SvgImage : isLayoutMode ? LayoutImage : BaseImage
458
+
459
+ if (hasPositionFixed) {
460
+ return createElement(Portal, null, finalComponent)
461
+ }
462
+
463
+ return finalComponent
445
464
  })
446
465
 
447
466
  Image.displayName = 'mpx-image'
@@ -58,6 +58,7 @@ import { useUpdateEffect, useTransformStyle, useLayout, extendObject, isIOS } fr
58
58
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
59
59
  import useNodesRef, { HandlerRef } from './useNodesRef'
60
60
  import { FormContext, FormFieldValue, KeyboardAvoidContext } from './context'
61
+ import Portal from './mpx-portal'
61
62
 
62
63
  type InputStyle = Omit<
63
64
  TextStyle & ViewStyle & Pick<FlexStyle, 'minHeight'>,
@@ -202,6 +203,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
202
203
  )
203
204
 
204
205
  const {
206
+ hasPositionFixed,
205
207
  hasSelfPercent,
206
208
  normalStyle,
207
209
  setWidth,
@@ -481,7 +483,14 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
481
483
  layoutRef
482
484
  }
483
485
  )
484
- return createElement(TextInput, innerProps)
486
+
487
+ const finalComponent = createElement(TextInput, innerProps)
488
+
489
+ if (hasPositionFixed) {
490
+ return createElement(Portal, null, finalComponent)
491
+ }
492
+
493
+ return finalComponent
485
494
  })
486
495
 
487
496
  Input.displayName = 'MpxInput'
@@ -48,7 +48,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
48
48
  const { ref, cursorSpacing = 0 } = keyboardAvoid.current
49
49
  setTimeout(() => {
50
50
  ref?.current?.measure((x: number, y: number, width: number, height: number, pageX: number, pageY: number) => {
51
- const aboveOffset = pageY + height - endCoordinates.screenY
51
+ const aboveOffset = offset.value + pageY + height - endCoordinates.screenY
52
52
  const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing
53
53
  const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing)
54
54
  const value = aboveOffset > 0 ? belowValue : aboveValue
@@ -8,6 +8,7 @@ import useInnerProps, { getCustomEvent } from './getInnerListeners'
8
8
  import useNodesRef, { HandlerRef } from './useNodesRef'
9
9
  import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
10
10
  import { LabelContext, LabelContextValue } from './context'
11
+ import Portal from './mpx-portal'
11
12
 
12
13
  export interface LabelProps {
13
14
  for?: string
@@ -45,6 +46,7 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
45
46
  const styleObj = extendObject({}, defaultStyle, style)
46
47
 
47
48
  const {
49
+ hasPositionFixed,
48
50
  hasSelfPercent,
49
51
  normalStyle,
50
52
  hasVarDec,
@@ -91,7 +93,7 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
91
93
  }
92
94
  )
93
95
 
94
- return createElement(View, innerProps, createElement(
96
+ const finalComponent = createElement(View, innerProps, createElement(
95
97
  LabelContext.Provider,
96
98
  { value: contextRef },
97
99
  wrapChildren(
@@ -104,6 +106,12 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
104
106
  }
105
107
  )
106
108
  ))
109
+
110
+ if (hasPositionFixed) {
111
+ return createElement(Portal, null, finalComponent)
112
+ }
113
+
114
+ return finalComponent
107
115
  }
108
116
  )
109
117
 
@@ -8,6 +8,7 @@ import useNodesRef, { HandlerRef } from './useNodesRef'
8
8
  import useInnerProps from './getInnerListeners'
9
9
  import { MovableAreaContext } from './context'
10
10
  import { useTransformStyle, wrapChildren, useLayout, extendObject } from './utils'
11
+ import Portal from './mpx-portal'
11
12
 
12
13
  interface MovableAreaProps {
13
14
  style?: Record<string, any>
@@ -30,6 +31,7 @@ const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaP
30
31
  normalStyle,
31
32
  hasVarDec,
32
33
  varContextRef,
34
+ hasPositionFixed,
33
35
  setWidth,
34
36
  setHeight
35
37
  } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
@@ -60,7 +62,7 @@ const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaP
60
62
  { layoutRef }
61
63
  )
62
64
 
63
- return createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(
65
+ let movableComponent: JSX.Element = createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(
64
66
  View,
65
67
  innerProps,
66
68
  wrapChildren(
@@ -71,6 +73,10 @@ const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaP
71
73
  }
72
74
  )
73
75
  ))
76
+ if (hasPositionFixed) {
77
+ movableComponent = createElement(Portal, null, movableComponent)
78
+ }
79
+ return movableComponent
74
80
  })
75
81
 
76
82
  _MovableArea.displayName = 'MpxMovableArea'