@mpxjs/webpack-plugin 2.9.70-alpha.0 → 2.9.70

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 (99) hide show
  1. package/LICENSE +433 -0
  2. package/README.md +1 -1
  3. package/lib/config.js +0 -14
  4. package/lib/dependencies/ResolveDependency.js +0 -5
  5. package/lib/index.js +7 -38
  6. package/lib/json-compiler/helper.js +3 -3
  7. package/lib/loader.js +0 -53
  8. package/lib/parser.js +1 -1
  9. package/lib/platform/json/wx/index.js +21 -8
  10. package/lib/platform/style/wx/index.js +51 -54
  11. package/lib/platform/template/wx/component-config/button.js +2 -14
  12. package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
  13. package/lib/platform/template/wx/component-config/image.js +0 -4
  14. package/lib/platform/template/wx/component-config/index.js +1 -1
  15. package/lib/platform/template/wx/component-config/input.js +0 -4
  16. package/lib/platform/template/wx/component-config/rich-text.js +6 -2
  17. package/lib/platform/template/wx/component-config/scroll-view.js +0 -4
  18. package/lib/platform/template/wx/component-config/switch.js +0 -4
  19. package/lib/platform/template/wx/component-config/text.js +0 -4
  20. package/lib/platform/template/wx/component-config/textarea.js +0 -5
  21. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  22. package/lib/platform/template/wx/component-config/view.js +0 -4
  23. package/lib/platform/template/wx/index.js +1 -127
  24. package/lib/resolve-loader.js +1 -4
  25. package/lib/runtime/components/react/dist/getInnerListeners.js +5 -6
  26. package/lib/runtime/components/react/dist/mpx-canvas/html.js +2 -4
  27. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +5 -1
  28. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +96 -107
  29. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +26 -27
  30. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +480 -0
  31. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +68 -0
  32. package/lib/runtime/components/react/dist/mpx-swiper/type.js +1 -0
  33. package/lib/runtime/components/react/dist/mpx-view.jsx +6 -3
  34. package/lib/runtime/components/react/dist/pickerFaces.js +6 -12
  35. package/lib/runtime/components/react/dist/{pickerViewOverlay.jsx → pickerOverlay.jsx} +3 -5
  36. package/lib/runtime/components/react/dist/useAnimationHooks.js +7 -8
  37. package/lib/runtime/components/react/dist/utils.jsx +89 -60
  38. package/lib/runtime/components/react/event.config.ts +25 -26
  39. package/lib/runtime/components/react/getInnerListeners.ts +212 -169
  40. package/lib/runtime/components/react/mpx-button.tsx +9 -14
  41. package/lib/runtime/components/react/mpx-canvas/html.ts +2 -4
  42. package/lib/runtime/components/react/mpx-canvas/index.tsx +44 -46
  43. package/lib/runtime/components/react/mpx-checkbox-group.tsx +15 -13
  44. package/lib/runtime/components/react/mpx-checkbox.tsx +20 -21
  45. package/lib/runtime/components/react/mpx-form.tsx +15 -20
  46. package/lib/runtime/components/react/mpx-icon.tsx +2 -2
  47. package/lib/runtime/components/react/mpx-image.tsx +87 -47
  48. package/lib/runtime/components/react/mpx-input.tsx +24 -32
  49. package/lib/runtime/components/react/mpx-label.tsx +12 -14
  50. package/lib/runtime/components/react/mpx-movable-area.tsx +10 -16
  51. package/lib/runtime/components/react/mpx-movable-view.tsx +20 -24
  52. package/lib/runtime/components/react/mpx-navigator.tsx +2 -8
  53. package/lib/runtime/components/react/mpx-radio-group.tsx +13 -15
  54. package/lib/runtime/components/react/mpx-radio.tsx +19 -25
  55. package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
  56. package/lib/runtime/components/react/mpx-rich-text/index.tsx +121 -0
  57. package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
  58. package/lib/runtime/components/react/mpx-scroll-view.tsx +40 -41
  59. package/lib/runtime/components/react/mpx-switch.tsx +19 -15
  60. package/lib/runtime/components/react/mpx-text.tsx +8 -16
  61. package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
  62. package/lib/runtime/components/react/mpx-view.tsx +18 -20
  63. package/lib/runtime/components/react/mpx-web-view.tsx +94 -59
  64. package/lib/runtime/components/react/types/global.d.ts +2 -1
  65. package/lib/runtime/components/react/useAnimationHooks.ts +36 -12
  66. package/lib/runtime/components/react/utils.tsx +91 -60
  67. package/lib/runtime/components/web/mpx-web-view.vue +34 -20
  68. package/lib/runtime/optionProcessor.js +0 -22
  69. package/lib/style-compiler/index.js +1 -1
  70. package/lib/style-compiler/plugins/scope-id.js +30 -2
  71. package/lib/template-compiler/compiler.js +30 -26
  72. package/lib/utils/env.js +1 -6
  73. package/lib/utils/pre-process-json.js +9 -5
  74. package/package.json +4 -7
  75. package/lib/dependencies/AddEntryDependency.js +0 -24
  76. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +0 -39
  77. package/lib/runtime/components/react/dist/mpx-swiper.jsx +0 -606
  78. package/lib/runtime/components/react/dist/pickerVIewContext.js +0 -9
  79. package/lib/runtime/components/react/dist/pickerViewMask.jsx +0 -18
  80. package/lib/runtime/components/tenon/getInnerListeners.js +0 -334
  81. package/lib/runtime/components/tenon/tenon-button.vue +0 -309
  82. package/lib/runtime/components/tenon/tenon-image.vue +0 -66
  83. package/lib/runtime/components/tenon/tenon-input.vue +0 -171
  84. package/lib/runtime/components/tenon/tenon-rich-text.vue +0 -26
  85. package/lib/runtime/components/tenon/tenon-scroll-view.vue +0 -127
  86. package/lib/runtime/components/tenon/tenon-switch.vue +0 -96
  87. package/lib/runtime/components/tenon/tenon-text.vue +0 -70
  88. package/lib/runtime/components/tenon/tenon-textarea.vue +0 -86
  89. package/lib/runtime/components/tenon/tenon-view.vue +0 -93
  90. package/lib/runtime/components/web/event.js +0 -105
  91. package/lib/runtime/optionProcessor.tenon.js +0 -84
  92. package/lib/style-compiler/plugins/hm.js +0 -20
  93. package/lib/tenon/index.js +0 -117
  94. package/lib/tenon/processJSON.js +0 -352
  95. package/lib/tenon/processScript.js +0 -203
  96. package/lib/tenon/processStyles.js +0 -21
  97. package/lib/tenon/processTemplate.js +0 -126
  98. package/lib/tenon/script-helper.js +0 -223
  99. package/lib/utils/get-relative-path.js +0 -25
@@ -13,7 +13,8 @@ import {
13
13
  ReactNode,
14
14
  useContext,
15
15
  Dispatch,
16
- SetStateAction
16
+ SetStateAction,
17
+ createElement
17
18
  } from 'react'
18
19
  import {
19
20
  View,
@@ -206,28 +207,26 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
206
207
  }
207
208
  }, [checked])
208
209
 
209
- return (
210
- <View {...innerProps}>
211
- <View style={defaultStyle}>
212
- <Icon
213
- type='success_no_circle'
214
- size={18}
215
- color={disabled ? '#ADADAD' : color}
216
- style={isChecked ? styles.iconChecked : styles.icon}
217
- />
218
- </View>
210
+ return createElement(View, innerProps,
211
+ createElement(
212
+ View,
213
+ { style: defaultStyle },
214
+ createElement(Icon, {
215
+ type: 'success_no_circle',
216
+ size: 18,
217
+ color: disabled ? '#ADADAD' : color,
218
+ style: isChecked ? styles.iconChecked : styles.icon
219
+ })
220
+ ),
221
+ wrapChildren(
222
+ props,
219
223
  {
220
- wrapChildren(
221
- props,
222
- {
223
- hasVarDec,
224
- varContext: varContextRef.current,
225
- textStyle,
226
- textProps
227
- }
228
- )
224
+ hasVarDec,
225
+ varContext: varContextRef.current,
226
+ textStyle,
227
+ textProps
229
228
  }
230
- </View>
229
+ )
231
230
  )
232
231
  }
233
232
  )
@@ -5,7 +5,7 @@
5
5
  * ✔ bindreset
6
6
  */
7
7
  import { View } from 'react-native'
8
- import { JSX, useRef, forwardRef, ReactNode, useMemo, useCallback } from 'react'
8
+ import { JSX, useRef, forwardRef, ReactNode, useMemo, createElement } from 'react'
9
9
  import useNodesRef, { HandlerRef } from './useNodesRef'
10
10
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
11
11
  import { FormContext } from './context'
@@ -102,25 +102,20 @@ const _Form = forwardRef<HandlerRef<View, FormProps>, FormProps>((fromProps: For
102
102
  reset
103
103
  }
104
104
  }, [])
105
- return (
106
- <View
107
- {...innerProps}
108
- >
109
- <FormContext.Provider value={contextValue}>
110
- {
111
- wrapChildren(
112
- props,
113
- {
114
- hasVarDec,
115
- varContext: varContextRef.current,
116
- textStyle,
117
- textProps
118
- }
119
- )
120
- }
121
- </FormContext.Provider>
122
- </View>
123
- )
105
+
106
+ return createElement(View, innerProps, createElement(
107
+ FormContext.Provider,
108
+ { value: contextValue },
109
+ wrapChildren(
110
+ props,
111
+ {
112
+ hasVarDec,
113
+ varContext: varContextRef.current,
114
+ textStyle,
115
+ textProps
116
+ }
117
+ )
118
+ ))
124
119
  })
125
120
 
126
121
  _Form.displayName = 'MpxForm'
@@ -3,7 +3,7 @@
3
3
  * ✔ size
4
4
  * ✔ color
5
5
  */
6
- import { JSX, forwardRef, useRef } from 'react'
6
+ import { JSX, forwardRef, useRef, createElement } from 'react'
7
7
  import { Text, TextStyle, Image } from 'react-native'
8
8
  import useInnerProps from './getInnerListeners'
9
9
  import useNodesRef, { HandlerRef } from './useNodesRef'
@@ -93,7 +93,7 @@ const Icon = forwardRef<HandlerRef<Text, IconProps>, IconProps>(
93
93
  }
94
94
  )
95
95
 
96
- return <Image {...innerProps} />
96
+ return createElement(Image, innerProps)
97
97
  }
98
98
  )
99
99
 
@@ -10,7 +10,7 @@
10
10
  * ✔ bindtap
11
11
  * ✔ DEFAULT_SIZE
12
12
  */
13
- import { useEffect, useMemo, useState, useRef, forwardRef } from 'react'
13
+ import { useEffect, useMemo, useState, useRef, forwardRef, createElement } from 'react'
14
14
  import {
15
15
  Image as RNImage,
16
16
  View,
@@ -22,10 +22,11 @@ import {
22
22
  DimensionValue,
23
23
  ImageLoadEventData
24
24
  } from 'react-native'
25
+ import { noop } from '@mpxjs/utils'
25
26
  import { SvgCssUri } from 'react-native-svg/css'
26
27
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
27
28
  import useNodesRef, { HandlerRef } from './useNodesRef'
28
- import { SVG_REGEXP, useLayout, useTransformStyle, extendObject } from './utils'
29
+ import { SVG_REGEXP, useLayout, useTransformStyle, renderImage, extendObject } from './utils'
29
30
 
30
31
  export type Mode =
31
32
  | 'scaleToFill'
@@ -54,10 +55,19 @@ export interface ImageProps {
54
55
  'parent-font-size'?: number
55
56
  'parent-width'?: number
56
57
  'parent-height'?: number
58
+ 'enable-fast-image'?: boolean
57
59
  bindload?: (evt: NativeSyntheticEvent<ImageLoadEventData> | unknown) => void
58
60
  binderror?: (evt: NativeSyntheticEvent<ImageErrorEventData> | unknown) => void
59
61
  }
60
62
 
63
+ interface ImageState {
64
+ viewWidth?: number
65
+ viewHeight?: number
66
+ imageWidth?: number
67
+ imageHeight?: number
68
+ ratio?: number
69
+ }
70
+
61
71
  const DEFAULT_IMAGE_WIDTH = 320
62
72
  const DEFAULT_IMAGE_HEIGHT = 240
63
73
 
@@ -101,6 +111,7 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
101
111
  'enable-var': enableVar,
102
112
  'external-var-context': externalVarContext,
103
113
  'parent-font-size': parentFontSize,
114
+ 'enable-fast-image': enableFastImage,
104
115
  'parent-width': parentWidth,
105
116
  'parent-height': parentHeight,
106
117
  bindload,
@@ -119,23 +130,13 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
119
130
  { overflow: 'hidden' }
120
131
  )
121
132
 
122
- const nodeRef = useRef(null)
123
-
124
- const onLayout = ({ nativeEvent: { layout: { width, height } } }: LayoutChangeEvent) => {
125
- setViewWidth(width)
126
- setViewHeight(height)
127
- }
128
-
129
- const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
133
+ const state = useRef<ImageState>({})
130
134
 
135
+ const nodeRef = useRef(null)
131
136
  useNodesRef(props, ref, nodeRef, {
132
- style: normalStyle
137
+ defaultStyle
133
138
  })
134
139
 
135
- const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef, onLayout })
136
-
137
- const { width, height } = normalStyle
138
-
139
140
  const isSvg = SVG_REGEXP.test(src)
140
141
  const isWidthFixMode = mode === 'widthFix'
141
142
  const isHeightFixMode = mode === 'heightFix'
@@ -143,11 +144,40 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
143
144
  const isLayoutMode = isWidthFixMode || isHeightFixMode || isCropMode
144
145
  const resizeMode: ImageResizeMode = ModeMap.get(mode) || 'stretch'
145
146
 
147
+ const onLayout = ({ nativeEvent: { layout: { width, height } } }: LayoutChangeEvent) => {
148
+ state.current.viewWidth = width
149
+ state.current.viewHeight = height
150
+
151
+ if (state.current.imageWidth && state.current.imageHeight && state.current.ratio) {
152
+ setViewWidth(width)
153
+ setViewHeight(height)
154
+ setRatio(state.current.ratio)
155
+ setImageWidth(state.current.imageWidth)
156
+ setImageHeight(state.current.imageHeight)
157
+ state.current = {}
158
+ setLoaded(true)
159
+ }
160
+ }
161
+
162
+ const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
163
+
164
+ const { layoutRef, layoutStyle, layoutProps } = useLayout({
165
+ props,
166
+ hasSelfPercent,
167
+ setWidth,
168
+ setHeight,
169
+ nodeRef,
170
+ onLayout: isLayoutMode ? onLayout : noop
171
+ })
172
+
173
+ const { width, height } = normalStyle
174
+
146
175
  const [viewWidth, setViewWidth] = useState(isNumber(width) ? width : 0)
147
176
  const [viewHeight, setViewHeight] = useState(isNumber(height) ? height : 0)
148
177
  const [imageWidth, setImageWidth] = useState(0)
149
178
  const [imageHeight, setImageHeight] = useState(0)
150
179
  const [ratio, setRatio] = useState(0)
180
+ const [loaded, setLoaded] = useState(!isLayoutMode)
151
181
 
152
182
  const fixedHeight = useMemo(() => {
153
183
  const fixed = viewWidth * ratio
@@ -327,9 +357,23 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
327
357
  useEffect(() => {
328
358
  if (!isSvg && isLayoutMode) {
329
359
  RNImage.getSize(src, (width: number, height: number) => {
330
- setRatio(!width ? 0 : height / width)
331
- setImageWidth(width)
332
- setImageHeight(height)
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 = {}
375
+ setLoaded(true)
376
+ }
333
377
  })
334
378
  }
335
379
  }, [src, isSvg, isLayoutMode])
@@ -359,35 +403,31 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
359
403
  }
360
404
  )
361
405
 
362
- return (
363
- <View {...innerProps}>
364
- {
365
- isSvg
366
- ? <SvgCssUri
367
- uri={src}
368
- onLayout={onSvgLoad}
369
- onError={binderror && onSvgError}
370
- style={extendObject(
371
- { transformOrigin: 'top left' },
372
- modeStyle
373
- )}
374
- />
375
- : <RNImage
376
- source={{ uri: src }}
377
- resizeMode={resizeMode}
378
- onLoad={bindload && onImageLoad}
379
- onError={binderror && onImageError}
380
- style={extendObject(
381
- {
382
- transformOrigin: 'top left',
383
- width: isCropMode ? imageWidth : '100%',
384
- height: isCropMode ? imageHeight : '100%'
385
- },
386
- isCropMode ? modeStyle : {}
387
- )}
388
- />
389
- }
390
- </View>
406
+ return createElement(View, innerProps,
407
+ isSvg
408
+ ? createElement(SvgCssUri, {
409
+ uri: src,
410
+ onLayout: onSvgLoad,
411
+ onError: binderror && onSvgError,
412
+ style: extendObject(
413
+ { transformOrigin: 'top left' },
414
+ modeStyle
415
+ )
416
+ })
417
+ : loaded && renderImage({
418
+ source: { uri: src },
419
+ resizeMode: resizeMode,
420
+ onLoad: bindload && onImageLoad,
421
+ onError: binderror && onImageError,
422
+ style: extendObject(
423
+ {
424
+ transformOrigin: 'top left',
425
+ width: isCropMode ? imageWidth : '100%',
426
+ height: isCropMode ? imageHeight : '100%'
427
+ },
428
+ isCropMode ? modeStyle : {}
429
+ )
430
+ }, enableFastImage)
391
431
  )
392
432
  })
393
433
 
@@ -37,7 +37,7 @@
37
37
  * ✘ bind:keyboardcompositionend
38
38
  * ✘ bind:onkeyboardheightchange
39
39
  */
40
- import { JSX, forwardRef, useMemo, useRef, useState, useContext, useEffect } from 'react'
40
+ import { JSX, forwardRef, useMemo, useRef, useState, useContext, useEffect, createElement } from 'react'
41
41
  import {
42
42
  KeyboardTypeOptions,
43
43
  Platform,
@@ -187,7 +187,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
187
187
  { padding: 0, backgroundColor: '#fff' },
188
188
  style,
189
189
  multiline && autoHeight
190
- ? { height: Math.max((style as any)?.minHeight || 35, contentHeight) }
190
+ ? { minHeight: Math.max((style as any)?.minHeight || 35, contentHeight) }
191
191
  : {}
192
192
  )
193
193
 
@@ -405,7 +405,22 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
405
405
  {
406
406
  ref: nodeRef,
407
407
  style: extendObject({}, normalStyle, layoutStyle),
408
- allowFontScaling
408
+ allowFontScaling,
409
+ keyboardType: keyboardType,
410
+ secureTextEntry: !!password,
411
+ defaultValue: defaultValue,
412
+ value: inputValue,
413
+ maxLength: maxlength === -1 ? undefined : maxlength,
414
+ editable: !disabled,
415
+ autoFocus: !!autoFocus || !!focus,
416
+ returnKeyType: confirmType,
417
+ selection: selection,
418
+ selectionColor: cursorColor,
419
+ blurOnSubmit: !multiline && !confirmHold,
420
+ underlineColorAndroid: 'rgba(0,0,0,0)',
421
+ textAlignVertical: textAlignVertical,
422
+ placeholderTextColor: placeholderTextColor,
423
+ multiline: !!multiline
409
424
  },
410
425
  layoutProps,
411
426
  {
@@ -413,16 +428,17 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
413
428
  onBlur: bindblur && onInputBlur,
414
429
  onKeyPress: bindconfirm && onKeyPress,
415
430
  onSubmitEditing: bindconfirm && multiline && onSubmitEditing,
416
- onSelectionChange: bindselectionchange && onSelectionChange
431
+ onSelectionChange: bindselectionchange && onSelectionChange,
432
+ onTextInput: onTextInput,
433
+ onChange: onChange,
434
+ onContentSizeChange: onContentSizeChange
417
435
  }
418
436
  ),
419
437
  [
420
438
  'type',
421
- 'keyboardType',
422
439
  'password',
423
440
  'placeholder-style',
424
441
  'disabled',
425
- 'maxlength',
426
442
  'auto-focus',
427
443
  'focus',
428
444
  'confirm-type',
@@ -430,37 +446,13 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
430
446
  'cursor',
431
447
  'cursor-color',
432
448
  'selection-start',
433
- 'selection-end',
434
- 'multiline'
449
+ 'selection-end'
435
450
  ],
436
451
  {
437
452
  layoutRef
438
453
  }
439
454
  )
440
-
441
- return (
442
- <TextInput
443
- {...innerProps}
444
- keyboardType={keyboardType as KeyboardTypeOptions}
445
- secureTextEntry={!!password}
446
- defaultValue={defaultValue}
447
- value={inputValue}
448
- maxLength={maxlength === -1 ? undefined : maxlength}
449
- editable={!disabled}
450
- autoFocus={!!autoFocus || !!focus}
451
- returnKeyType={confirmType}
452
- selection={selection}
453
- selectionColor={cursorColor}
454
- blurOnSubmit={!multiline && !confirmHold}
455
- underlineColorAndroid="rgba(0,0,0,0)"
456
- textAlignVertical={textAlignVertical}
457
- placeholderTextColor={placeholderTextColor}
458
- multiline={!!multiline}
459
- onTextInput={onTextInput}
460
- onChange={onChange}
461
- onContentSizeChange={onContentSizeChange}
462
- />
463
- )
455
+ return createElement(TextInput, innerProps)
464
456
  })
465
457
 
466
458
  Input.displayName = 'MpxInput'
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * ✘ for
3
3
  */
4
- import { JSX, useRef, forwardRef, ReactNode, useCallback } from 'react'
4
+ import { JSX, useRef, forwardRef, ReactNode, useCallback, createElement } from 'react'
5
5
  import { View, ViewStyle, NativeSyntheticEvent } from 'react-native'
6
6
  import { noop, warn } from '@mpxjs/utils'
7
7
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
@@ -92,21 +92,19 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
92
92
  }
93
93
  )
94
94
 
95
- return <View {...innerProps}>
96
- <LabelContext.Provider value={contextRef}>
95
+ return createElement(View, innerProps, createElement(
96
+ LabelContext.Provider,
97
+ { value: contextRef },
98
+ wrapChildren(
99
+ props,
97
100
  {
98
- wrapChildren(
99
- props,
100
- {
101
- hasVarDec,
102
- varContext: varContextRef.current,
103
- textStyle,
104
- textProps
105
- }
106
- )
101
+ hasVarDec,
102
+ varContext: varContextRef.current,
103
+ textStyle,
104
+ textProps
107
105
  }
108
- </LabelContext.Provider>
109
- </View>
106
+ )
107
+ ))
110
108
  }
111
109
  )
112
110
 
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import { View } from 'react-native'
6
- import { JSX, forwardRef, ReactNode, useRef, useMemo } from 'react'
6
+ import { JSX, forwardRef, ReactNode, useRef, useMemo, createElement } from 'react'
7
7
  import useNodesRef, { HandlerRef } from './useNodesRef'
8
8
  import useInnerProps from './getInnerListeners'
9
9
  import { MovableAreaContext } from './context'
@@ -51,23 +51,17 @@ const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaP
51
51
  ref: movableViewRef
52
52
  }, layoutProps), [], { layoutRef })
53
53
 
54
- return (
55
- <MovableAreaContext.Provider value={contextValue}>
56
- <View
57
- {...innerProps}
58
- >
54
+ return createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(
55
+ View,
56
+ innerProps,
57
+ wrapChildren(
58
+ props,
59
59
  {
60
- wrapChildren(
61
- props,
62
- {
63
- hasVarDec,
64
- varContext: varContextRef.current
65
- }
66
- )
60
+ hasVarDec,
61
+ varContext: varContextRef.current
67
62
  }
68
- </View>
69
- </MovableAreaContext.Provider>
70
- )
63
+ )
64
+ ))
71
65
  })
72
66
 
73
67
  _MovableArea.displayName = 'MpxMovableArea'
@@ -17,12 +17,12 @@
17
17
  * ✔ htouchmove
18
18
  * ✔ vtouchmove
19
19
  */
20
- import { useEffect, forwardRef, ReactNode, useContext, useCallback, useRef, useMemo } from 'react'
20
+ import { useEffect, forwardRef, ReactNode, useContext, useCallback, useRef, useMemo, createElement } from 'react'
21
21
  import { StyleSheet, NativeSyntheticEvent, View, LayoutChangeEvent } from 'react-native'
22
22
  import { getCustomEvent } from './getInnerListeners'
23
23
  import useNodesRef, { HandlerRef } from './useNodesRef'
24
24
  import { MovableAreaContext } from './context'
25
- import { useTransformStyle, splitProps, splitStyle, HIDDEN_STYLE, wrapChildren, GestureHandler, flatGesture } from './utils'
25
+ import { useTransformStyle, splitProps, splitStyle, HIDDEN_STYLE, wrapChildren, GestureHandler, flatGesture, extendObject } from './utils'
26
26
  import { GestureDetector, Gesture, GestureTouchEvent, GestureStateChangeEvent, PanGestureHandlerEventPayload, PanGesture } from 'react-native-gesture-handler'
27
27
  import Animated, {
28
28
  useSharedValue,
@@ -518,28 +518,24 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
518
518
 
519
519
  const catchEventHandlers = injectCatchEvent(props)
520
520
  const layoutStyle = !hasLayoutRef.current && hasSelfPercent ? HIDDEN_STYLE : {}
521
- return (
522
- <GestureDetector gesture={gesture}>
523
- <Animated.View
524
- ref={nodeRef}
525
- onLayout={onLayout}
526
- style={[innerStyle, animatedStyles, layoutStyle]}
527
- {...catchEventHandlers}
528
- >
529
- {
530
- wrapChildren(
531
- props,
532
- {
533
- hasVarDec,
534
- varContext: varContextRef.current,
535
- textStyle,
536
- textProps
537
- }
538
- )
539
- }
540
- </Animated.View>
541
- </GestureDetector>
542
- )
521
+
522
+ return createElement(GestureDetector, { gesture: gesture }, createElement(
523
+ Animated.View,
524
+ extendObject({
525
+ ref: nodeRef,
526
+ onLayout: onLayout,
527
+ style: [innerStyle, animatedStyles, layoutStyle]
528
+ }, catchEventHandlers),
529
+ wrapChildren(
530
+ props,
531
+ {
532
+ hasVarDec,
533
+ varContext: varContextRef.current,
534
+ textStyle,
535
+ textProps
536
+ }
537
+ )
538
+ ))
543
539
  })
544
540
 
545
541
  _MovableView.displayName = 'MpxMovableView'
@@ -8,7 +8,7 @@
8
8
  * ✔ delta
9
9
  */
10
10
  import { View } from 'react-native'
11
- import { useCallback, forwardRef, JSX } from 'react'
11
+ import { useCallback, forwardRef, JSX, createElement } from 'react'
12
12
  import useInnerProps from './getInnerListeners'
13
13
  import { redirectTo, navigateTo, navigateBack, reLaunch, switchTab } from '@mpxjs/api-proxy'
14
14
 
@@ -53,13 +53,7 @@ const _Navigator = forwardRef<View, _NavigatorProps>((props, ref): JSX.Element =
53
53
  bindtap: handleClick
54
54
  })
55
55
 
56
- return (
57
- <MpxView
58
- {...innerProps}
59
- >
60
- {children}
61
- </MpxView>
62
- )
56
+ return createElement(MpxView, innerProps, children)
63
57
  })
64
58
 
65
59
  _Navigator.displayName = 'MpxNavigator'
@@ -8,7 +8,8 @@ import {
8
8
  ReactNode,
9
9
  useContext,
10
10
  useMemo,
11
- useEffect
11
+ useEffect,
12
+ createElement
12
13
  } from 'react'
13
14
  import {
14
15
  View,
@@ -154,20 +155,17 @@ const radioGroup = forwardRef<
154
155
  }
155
156
  )
156
157
 
157
- return (
158
- <View {...innerProps}>
159
- <RadioGroupContext.Provider value={contextValue}>
160
- {
161
- wrapChildren(
162
- props,
163
- {
164
- hasVarDec,
165
- varContext: varContextRef.current
166
- }
167
- )
168
- }
169
- </RadioGroupContext.Provider>
170
- </View>
158
+ return createElement(View, innerProps, createElement(
159
+ RadioGroupContext.Provider,
160
+ { value: contextValue },
161
+ wrapChildren(
162
+ props,
163
+ {
164
+ hasVarDec,
165
+ varContext: varContextRef.current
166
+ }
167
+ )
168
+ )
171
169
  )
172
170
  })
173
171