@mpxjs/webpack-plugin 2.10.3 → 2.10.4-beta.11

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 (155) hide show
  1. package/lib/config.js +2 -1
  2. package/lib/index.js +1 -1
  3. package/lib/platform/json/wx/index.js +6 -4
  4. package/lib/platform/style/wx/index.js +42 -30
  5. package/lib/platform/template/wx/component-config/button.js +20 -3
  6. package/lib/platform/template/wx/component-config/canvas.js +4 -0
  7. package/lib/platform/template/wx/component-config/checkbox-group.js +4 -0
  8. package/lib/platform/template/wx/component-config/checkbox.js +4 -0
  9. package/lib/platform/template/wx/component-config/cover-image.js +7 -1
  10. package/lib/platform/template/wx/component-config/cover-view.js +4 -0
  11. package/lib/platform/template/wx/component-config/fix-component-name.js +3 -2
  12. package/lib/platform/template/wx/component-config/form.js +7 -1
  13. package/lib/platform/template/wx/component-config/icon.js +4 -0
  14. package/lib/platform/template/wx/component-config/image.js +7 -1
  15. package/lib/platform/template/wx/component-config/index.js +5 -1
  16. package/lib/platform/template/wx/component-config/input.js +19 -4
  17. package/lib/platform/template/wx/component-config/label.js +4 -0
  18. package/lib/platform/template/wx/component-config/movable-area.js +7 -1
  19. package/lib/platform/template/wx/component-config/movable-view.js +12 -3
  20. package/lib/platform/template/wx/component-config/navigator.js +4 -0
  21. package/lib/platform/template/wx/component-config/picker-view-column.js +4 -0
  22. package/lib/platform/template/wx/component-config/picker-view.js +7 -1
  23. package/lib/platform/template/wx/component-config/picker.js +7 -1
  24. package/lib/platform/template/wx/component-config/radio-group.js +4 -0
  25. package/lib/platform/template/wx/component-config/radio.js +4 -0
  26. package/lib/platform/template/wx/component-config/rich-text.js +4 -0
  27. package/lib/platform/template/wx/component-config/root-portal.js +4 -0
  28. package/lib/platform/template/wx/component-config/scroll-view.js +10 -2
  29. package/lib/platform/template/wx/component-config/sticky-header.js +23 -0
  30. package/lib/platform/template/wx/component-config/sticky-section.js +23 -0
  31. package/lib/platform/template/wx/component-config/swiper-item.js +7 -1
  32. package/lib/platform/template/wx/component-config/swiper.js +12 -3
  33. package/lib/platform/template/wx/component-config/switch.js +4 -0
  34. package/lib/platform/template/wx/component-config/text.js +24 -3
  35. package/lib/platform/template/wx/component-config/textarea.js +17 -2
  36. package/lib/platform/template/wx/component-config/unsupported.js +7 -0
  37. package/lib/platform/template/wx/component-config/video.js +10 -2
  38. package/lib/platform/template/wx/component-config/view.js +11 -1
  39. package/lib/platform/template/wx/component-config/web-view.js +4 -0
  40. package/lib/platform/template/wx/index.js +42 -75
  41. package/lib/react/processJSON.js +7 -6
  42. package/lib/react/processScript.js +1 -18
  43. package/lib/runtime/components/react/context.ts +12 -3
  44. package/lib/runtime/components/react/dist/context.js +4 -1
  45. package/lib/runtime/components/react/dist/event.config.js +0 -1
  46. package/lib/runtime/components/react/dist/getInnerListeners.js +127 -142
  47. package/lib/runtime/components/react/dist/mpx-button.jsx +4 -5
  48. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +4 -5
  49. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +2 -2
  50. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +2 -3
  51. package/lib/runtime/components/react/dist/mpx-form.jsx +2 -2
  52. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
  53. package/lib/runtime/components/react/dist/mpx-image.jsx +2 -2
  54. package/lib/runtime/components/react/dist/mpx-inline-text.jsx +11 -0
  55. package/lib/runtime/components/react/dist/mpx-input.jsx +20 -17
  56. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +24 -31
  57. package/lib/runtime/components/react/dist/mpx-label.jsx +2 -3
  58. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +2 -2
  59. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +1 -1
  60. package/lib/runtime/components/react/dist/mpx-navigator.jsx +11 -3
  61. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +194 -68
  62. package/lib/runtime/components/react/dist/mpx-picker/dateData.js +17 -0
  63. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +180 -98
  64. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +79 -139
  65. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +190 -90
  66. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +60 -75
  67. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +100 -228
  68. package/lib/runtime/components/react/dist/{mpx-picker-view.jsx → mpx-picker-view/index.jsx} +5 -6
  69. package/lib/runtime/components/react/dist/{mpx-picker-view-column.jsx → mpx-picker-view-column/index.jsx} +66 -18
  70. package/lib/runtime/components/react/dist/{mpx-picker-view-column-item.jsx → mpx-picker-view-column/pickerViewColumnItem.jsx} +8 -5
  71. package/lib/runtime/components/react/dist/{pickerFaces.js → mpx-picker-view-column/pickerViewFaces.js} +6 -0
  72. package/lib/runtime/components/react/dist/mpx-popup/index.jsx +61 -0
  73. package/lib/runtime/components/react/dist/mpx-popup/popupBase.jsx +92 -0
  74. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +2 -2
  75. package/lib/runtime/components/react/dist/mpx-radio.jsx +2 -3
  76. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +2 -2
  77. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +207 -29
  78. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +7 -5
  79. package/lib/runtime/components/react/dist/mpx-simple-view.jsx +11 -15
  80. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +115 -0
  81. package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +45 -0
  82. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -5
  83. package/lib/runtime/components/react/dist/mpx-swiper.jsx +9 -9
  84. package/lib/runtime/components/react/dist/mpx-switch.jsx +3 -5
  85. package/lib/runtime/components/react/dist/mpx-text.jsx +4 -7
  86. package/lib/runtime/components/react/dist/mpx-video.jsx +5 -5
  87. package/lib/runtime/components/react/dist/mpx-view.jsx +23 -9
  88. package/lib/runtime/components/react/dist/mpx-web-view.jsx +16 -13
  89. package/lib/runtime/components/react/dist/useAnimationHooks.js +26 -4
  90. package/lib/runtime/components/react/dist/utils.jsx +14 -2
  91. package/lib/runtime/components/react/event.config.ts +1 -6
  92. package/lib/runtime/components/react/getInnerListeners.ts +148 -191
  93. package/lib/runtime/components/react/mpx-button.tsx +7 -7
  94. package/lib/runtime/components/react/mpx-canvas/index.tsx +25 -17
  95. package/lib/runtime/components/react/mpx-checkbox-group.tsx +4 -3
  96. package/lib/runtime/components/react/mpx-checkbox.tsx +8 -9
  97. package/lib/runtime/components/react/mpx-form.tsx +25 -19
  98. package/lib/runtime/components/react/mpx-icon/index.tsx +4 -3
  99. package/lib/runtime/components/react/mpx-image.tsx +4 -3
  100. package/lib/runtime/components/react/mpx-inline-text.tsx +18 -0
  101. package/lib/runtime/components/react/mpx-input.tsx +24 -21
  102. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +31 -42
  103. package/lib/runtime/components/react/mpx-label.tsx +4 -5
  104. package/lib/runtime/components/react/mpx-movable-area.tsx +22 -13
  105. package/lib/runtime/components/react/mpx-movable-view.tsx +47 -40
  106. package/lib/runtime/components/react/mpx-navigator.tsx +4 -6
  107. package/lib/runtime/components/react/mpx-picker/date.tsx +226 -69
  108. package/lib/runtime/components/react/mpx-picker/dateData.ts +22 -0
  109. package/lib/runtime/components/react/mpx-picker/index.tsx +242 -118
  110. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +96 -139
  111. package/lib/runtime/components/react/mpx-picker/region.tsx +217 -89
  112. package/lib/runtime/components/react/mpx-picker/selector.tsx +75 -80
  113. package/lib/runtime/components/react/mpx-picker/time.tsx +119 -236
  114. package/lib/runtime/components/react/mpx-picker/type.ts +85 -71
  115. package/lib/runtime/components/react/{mpx-picker-view.tsx → mpx-picker-view/index.tsx} +24 -21
  116. package/lib/runtime/components/react/{mpx-picker-view-column.tsx → mpx-picker-view-column/index.tsx} +72 -21
  117. package/lib/runtime/components/react/{mpx-picker-view-column-item.tsx → mpx-picker-view-column/pickerViewColumnItem.tsx} +8 -5
  118. package/lib/runtime/components/react/{pickerFaces.ts → mpx-picker-view-column/pickerViewFaces.ts} +7 -0
  119. package/lib/runtime/components/react/mpx-popup/index.tsx +86 -0
  120. package/lib/runtime/components/react/mpx-popup/popupBase.tsx +130 -0
  121. package/lib/runtime/components/react/mpx-radio-group.tsx +4 -3
  122. package/lib/runtime/components/react/mpx-radio.tsx +8 -9
  123. package/lib/runtime/components/react/mpx-rich-text/index.tsx +15 -6
  124. package/lib/runtime/components/react/mpx-scroll-view.tsx +326 -96
  125. package/lib/runtime/components/react/mpx-simple-text.tsx +17 -8
  126. package/lib/runtime/components/react/mpx-simple-view.tsx +17 -16
  127. package/lib/runtime/components/react/mpx-sticky-header.tsx +179 -0
  128. package/lib/runtime/components/react/mpx-sticky-section.tsx +96 -0
  129. package/lib/runtime/components/react/mpx-swiper-item.tsx +31 -24
  130. package/lib/runtime/components/react/mpx-swiper.tsx +67 -61
  131. package/lib/runtime/components/react/mpx-switch.tsx +19 -14
  132. package/lib/runtime/components/react/mpx-text.tsx +16 -13
  133. package/lib/runtime/components/react/mpx-video.tsx +36 -35
  134. package/lib/runtime/components/react/mpx-view.tsx +41 -17
  135. package/lib/runtime/components/react/mpx-web-view.tsx +15 -12
  136. package/lib/runtime/components/react/types/getInnerListeners.d.ts +69 -35
  137. package/lib/runtime/components/react/types/global.d.ts +1 -1
  138. package/lib/runtime/components/react/useAnimationHooks.ts +29 -9
  139. package/lib/runtime/components/react/utils.tsx +15 -3
  140. package/lib/runtime/components/web/mini-video-controls.min.js +1 -1
  141. package/lib/runtime/components/web/mpx-input.vue +1 -1
  142. package/lib/runtime/components/web/mpx-scroll-view.vue +21 -4
  143. package/lib/runtime/components/web/mpx-sticky-header.vue +91 -0
  144. package/lib/runtime/components/web/mpx-sticky-section.vue +15 -0
  145. package/lib/runtime/stringify.wxs +2 -2
  146. package/lib/template-compiler/compiler.js +8 -8
  147. package/lib/utils/env.js +1 -1
  148. package/package.json +4 -5
  149. package/LICENSE +0 -433
  150. /package/lib/runtime/components/react/dist/{pickerVIewContext.js → mpx-picker-view/pickerVIewContext.js} +0 -0
  151. /package/lib/runtime/components/react/dist/{pickerViewIndicator.jsx → mpx-picker-view-column/pickerViewIndicator.jsx} +0 -0
  152. /package/lib/runtime/components/react/dist/{pickerViewMask.jsx → mpx-picker-view-column/pickerViewMask.jsx} +0 -0
  153. /package/lib/runtime/components/react/{pickerVIewContext.ts → mpx-picker-view/pickerVIewContext.ts} +0 -0
  154. /package/lib/runtime/components/react/{pickerViewIndicator.tsx → mpx-picker-view-column/pickerViewIndicator.tsx} +0 -0
  155. /package/lib/runtime/components/react/{pickerViewMask.tsx → mpx-picker-view-column/pickerViewMask.tsx} +0 -0
@@ -87,14 +87,15 @@ const Icon = forwardRef<HandlerRef<Text, IconProps>, IconProps>(
87
87
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
88
88
 
89
89
  const innerProps = useInnerProps(
90
- props,
91
90
  extendObject(
91
+ {},
92
+ props,
93
+ layoutProps,
92
94
  {
93
95
  ref: nodeRef,
94
96
  source,
95
97
  style: extendObject({}, normalStyle, layoutStyle, { tintColor: color })
96
- },
97
- layoutProps
98
+ }
98
99
  ),
99
100
  [],
100
101
  {
@@ -379,8 +379,10 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
379
379
  }, [src, isSvg, isLayoutMode])
380
380
 
381
381
  const innerProps = useInnerProps(
382
- props,
383
382
  extendObject(
383
+ {},
384
+ props,
385
+ layoutProps,
384
386
  {
385
387
  ref: nodeRef,
386
388
  style: extendObject(
@@ -390,8 +392,7 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
390
392
  isHeightFixMode ? { width: fixedWidth } : {},
391
393
  isWidthFixMode ? { height: fixedHeight } : {}
392
394
  )
393
- },
394
- layoutProps
395
+ }
395
396
  ),
396
397
  [
397
398
  'src',
@@ -0,0 +1,18 @@
1
+ import { Text, TextProps } from 'react-native'
2
+ import { JSX, createElement } from 'react'
3
+
4
+ import { extendObject } from './utils'
5
+
6
+ const InlineText = (props: TextProps): JSX.Element => {
7
+ const {
8
+ allowFontScaling = false
9
+ } = props
10
+
11
+ return createElement(Text, extendObject({}, props, {
12
+ allowFontScaling
13
+ }))
14
+ }
15
+
16
+ InlineText.displayName = 'MpxInlineText'
17
+
18
+ export default InlineText
@@ -39,7 +39,6 @@
39
39
  */
40
40
  import { JSX, forwardRef, useRef, useState, useContext, useEffect, createElement } from 'react'
41
41
  import {
42
- Platform,
43
42
  TextInput,
44
43
  TextStyle,
45
44
  ViewStyle,
@@ -51,10 +50,11 @@ import {
51
50
  TextInputSelectionChangeEventData,
52
51
  TextInputFocusEventData,
53
52
  TextInputChangeEventData,
54
- TextInputSubmitEditingEventData
53
+ TextInputSubmitEditingEventData,
54
+ NativeTouchEvent
55
55
  } from 'react-native'
56
56
  import { warn } from '@mpxjs/utils'
57
- import { useUpdateEffect, useTransformStyle, useLayout, extendObject } from './utils'
57
+ import { useUpdateEffect, useTransformStyle, useLayout, extendObject, isIOS } from './utils'
58
58
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
59
59
  import useNodesRef, { HandlerRef } from './useNodesRef'
60
60
  import { FormContext, FormFieldValue, KeyboardAvoidContext } from './context'
@@ -121,11 +121,7 @@ const keyboardTypeMap: Record<Type, string> = {
121
121
  text: 'default',
122
122
  number: 'numeric',
123
123
  idcard: 'default',
124
- digit:
125
- Platform.select({
126
- ios: 'decimal-pad',
127
- android: 'numeric'
128
- }) || ''
124
+ digit: isIOS ? 'decimal-pad' : 'numeric'
129
125
  }
130
126
 
131
127
  const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps>((props: FinalInputProps, ref): JSX.Element => {
@@ -195,7 +191,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
195
191
 
196
192
  const [inputValue, setInputValue] = useState(defaultValue)
197
193
  const [contentHeight, setContentHeight] = useState(0)
198
- const [selection, setSelection] = useState({ start: -1, end: -1 })
194
+ const [selection, setSelection] = useState({ start: -1, end: tmpValue.current.length })
199
195
 
200
196
  const styleObj = extendObject(
201
197
  { padding: 0, backgroundColor: '#fff' },
@@ -221,15 +217,17 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
221
217
 
222
218
  useEffect(() => {
223
219
  if (inputValue !== value) {
224
- setInputValue(parseValue(value))
220
+ const parsed = parseValue(value)
221
+ tmpValue.current = parsed
222
+ setInputValue(parsed)
225
223
  }
226
224
  }, [value])
227
225
 
228
226
  useEffect(() => {
229
- if (typeof cursor === 'number') {
227
+ if (selectionStart > -1) {
228
+ setSelection({ start: selectionStart, end: selectionEnd === -1 ? tmpValue.current.length : selectionEnd })
229
+ } else if (typeof cursor === 'number') {
230
230
  setSelection({ start: cursor, end: cursor })
231
- } else if (selectionStart >= 0 && selectionEnd >= 0 && selectionStart !== selectionEnd) {
232
- setSelection({ start: selectionStart, end: selectionEnd })
233
231
  }
234
232
  }, [cursor, selectionStart, selectionEnd])
235
233
 
@@ -290,6 +288,10 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
290
288
  setKeyboardAvoidContext()
291
289
  }
292
290
 
291
+ const onTouchEnd = (evt: NativeSyntheticEvent<NativeTouchEvent & { origin?: string }>) => {
292
+ evt.nativeEvent.origin = 'input'
293
+ }
294
+
293
295
  const onFocus = (evt: NativeSyntheticEvent<TextInputFocusEventData>) => {
294
296
  setKeyboardAvoidContext()
295
297
  bindfocus && bindfocus(
@@ -388,6 +390,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
388
390
  }
389
391
 
390
392
  const resetValue = () => {
393
+ tmpValue.current = ''
391
394
  setInputValue('')
392
395
  }
393
396
 
@@ -427,8 +430,10 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
427
430
  }, [focus])
428
431
 
429
432
  const innerProps = useInnerProps(
430
- props,
431
433
  extendObject(
434
+ {},
435
+ props,
436
+ layoutProps,
432
437
  {
433
438
  ref: nodeRef,
434
439
  style: extendObject({}, normalStyle, layoutStyle),
@@ -440,25 +445,23 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
440
445
  maxLength: maxlength === -1 ? undefined : maxlength,
441
446
  editable: !disabled,
442
447
  autoFocus: !!autoFocus || !!focus,
443
- selection: selection,
448
+ selection: selectionStart > -1 || typeof cursor === 'number' ? selection : undefined,
444
449
  selectionColor: cursorColor,
445
450
  blurOnSubmit: !multiline && !confirmHold,
446
451
  underlineColorAndroid: 'rgba(0,0,0,0)',
447
452
  textAlignVertical: textAlignVertical,
448
453
  placeholderTextColor: placeholderStyle?.color,
449
- multiline: !!multiline
450
- },
451
- !!multiline && confirmType === 'return' ? {} : { enterKeyHint: confirmType },
452
- layoutProps,
453
- {
454
+ multiline: !!multiline,
454
455
  onTouchStart,
456
+ onTouchEnd,
455
457
  onFocus,
456
458
  onBlur,
457
459
  onChange,
458
460
  onSelectionChange,
459
461
  onContentSizeChange,
460
462
  onSubmitEditing: bindconfirm && !multiline && onSubmitEditing
461
- }
463
+ },
464
+ !!multiline && confirmType === 'return' ? {} : { enterKeyHint: confirmType }
462
465
  ),
463
466
  [
464
467
  'type',
@@ -1,8 +1,8 @@
1
- import React, { ReactNode, useContext, useEffect, useMemo } from 'react'
2
- import { DimensionValue, EmitterSubscription, Keyboard, Platform, View, ViewStyle } from 'react-native'
3
- import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing, runOnJS } from 'react-native-reanimated'
4
- import { GestureDetector, Gesture } from 'react-native-gesture-handler'
1
+ import React, { ReactNode, useContext, useEffect } from 'react'
2
+ import { DimensionValue, EmitterSubscription, Keyboard, View, ViewStyle, NativeSyntheticEvent, NativeTouchEvent } from 'react-native'
3
+ import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing } from 'react-native-reanimated'
5
4
  import { KeyboardAvoidContext } from './context'
5
+ import { isIOS } from './utils'
6
6
 
7
7
  type KeyboardAvoidViewProps = {
8
8
  children?: ReactNode
@@ -11,7 +11,6 @@ type KeyboardAvoidViewProps = {
11
11
  }
12
12
 
13
13
  const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: KeyboardAvoidViewProps) => {
14
- const isIOS = Platform.OS === 'ios'
15
14
  const duration = isIOS ? 250 : 300
16
15
  const easing = isIOS ? Easing.inOut(Easing.ease) : Easing.out(Easing.quad)
17
16
 
@@ -19,25 +18,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
19
18
  const basic = useSharedValue('auto')
20
19
  const keyboardAvoid = useContext(KeyboardAvoidContext)
21
20
 
22
- const dismiss = () => {
23
- Keyboard.isVisible() && Keyboard.dismiss()
24
- }
25
-
26
- const gesture = useMemo(() => {
27
- return Gesture.Tap()
28
- .onEnd(() => {
29
- dismiss()
30
- }).runOnJS(true)
31
- }, [])
32
-
33
- const animatedStyle = useAnimatedStyle(() => {
34
- return Object.assign(
35
- {
36
- transform: [{ translateY: -offset.value }]
37
- },
38
- isIOS ? {} : { flexBasis: basic.value as DimensionValue }
39
- )
40
- })
21
+ const animatedStyle = useAnimatedStyle(() => ({
22
+ transform: [{ translateY: -offset.value }],
23
+ flexBasis: basic.value as DimensionValue
24
+ }))
41
25
 
42
26
  const resetKeyboard = () => {
43
27
  if (keyboardAvoid?.current) {
@@ -47,6 +31,12 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
47
31
  basic.value = 'auto'
48
32
  }
49
33
 
34
+ const onTouchEnd = ({ nativeEvent }: NativeSyntheticEvent<NativeTouchEvent & { origin?: string }>) => {
35
+ if (nativeEvent.origin !== 'input') {
36
+ Keyboard.isVisible() && Keyboard.dismiss()
37
+ }
38
+ }
39
+
50
40
  useEffect(() => {
51
41
  let subscriptions: EmitterSubscription[] = []
52
42
 
@@ -62,7 +52,12 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
62
52
  const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing
63
53
  const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing)
64
54
  const value = aboveOffset > 0 ? belowValue : aboveValue
65
- offset.value = withTiming(value, { duration, easing })
55
+ offset.value = withTiming(value, { duration, easing }, (finished) => {
56
+ if (finished) {
57
+ // Set flexBasic after animation to trigger re-layout and reset layout information
58
+ basic.value = '99.99%'
59
+ }
60
+ })
66
61
  })
67
62
  })
68
63
  }),
@@ -82,11 +77,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
82
77
  const value = aboveOffset > 0 ? belowValue : aboveValue
83
78
  offset.value = withTiming(value, { duration, easing }, (finished) => {
84
79
  if (finished) {
85
- /**
86
- * In the Android environment, the layout information is not synchronized after the animation,
87
- * which results in the inability to correctly trigger element events.
88
- * Here, we utilize flexBasic to proactively trigger a re-layout
89
- */
80
+ // Set flexBasic after animation to trigger re-layout and reset layout information
90
81
  basic.value = '99.99%'
91
82
  }
92
83
  })
@@ -102,18 +93,16 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
102
93
  }, [keyboardAvoid])
103
94
 
104
95
  return (
105
- <GestureDetector gesture={gesture}>
106
- <View style={style}>
107
- <Animated.View
108
- style={[
109
- contentContainerStyle,
110
- animatedStyle
111
- ]}
112
- >
113
- {children}
114
- </Animated.View>
115
- </View>
116
- </GestureDetector>
96
+ <View style={style} onTouchEnd={onTouchEnd}>
97
+ <Animated.View
98
+ style={[
99
+ contentContainerStyle,
100
+ animatedStyle
101
+ ]}
102
+ >
103
+ {children}
104
+ </Animated.View>
105
+ </View>
117
106
  )
118
107
  }
119
108
 
@@ -75,14 +75,13 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
75
75
  }, [])
76
76
 
77
77
  const innerProps = useInnerProps(
78
- props,
79
78
  extendObject(
80
- {
81
- ref: nodeRef,
82
- style: extendObject({}, innerStyle, layoutStyle)
83
- },
79
+ {},
80
+ props,
84
81
  layoutProps,
85
82
  {
83
+ ref: nodeRef,
84
+ style: extendObject({}, innerStyle, layoutStyle),
86
85
  bindtap: onTap
87
86
  }
88
87
  ),
@@ -10,16 +10,16 @@ import { MovableAreaContext } from './context'
10
10
  import { useTransformStyle, wrapChildren, useLayout, extendObject } from './utils'
11
11
 
12
12
  interface MovableAreaProps {
13
- style?: Record<string, any>;
14
- children: ReactNode;
15
- width?: number;
16
- height?: number;
17
- 'enable-offset'?: boolean;
13
+ style?: Record<string, any>
14
+ children: ReactNode
15
+ width?: number
16
+ height?: number
17
+ 'enable-offset'?: boolean
18
18
  'enable-var'?: boolean
19
- 'external-var-context'?: Record<string, any>;
20
- 'parent-font-size'?: number;
21
- 'parent-width'?: number;
22
- 'parent-height'?: number;
19
+ 'external-var-context'?: Record<string, any>
20
+ 'parent-font-size'?: number
21
+ 'parent-width'?: number
22
+ 'parent-height'?: number
23
23
  }
24
24
 
25
25
  const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaProps>((props: MovableAreaProps, ref): JSX.Element => {
@@ -46,10 +46,19 @@ const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaP
46
46
 
47
47
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: movableViewRef })
48
48
 
49
- const innerProps = useInnerProps(props, extendObject({
50
- style: extendObject({ height: contextValue.height, width: contextValue.width, overflow: 'hidden' }, normalStyle, layoutStyle),
51
- ref: movableViewRef
52
- }, layoutProps), [], { layoutRef })
49
+ const innerProps = useInnerProps(
50
+ extendObject(
51
+ {},
52
+ props,
53
+ layoutProps,
54
+ {
55
+ style: extendObject({ height: contextValue.height, width: contextValue.width, overflow: 'hidden' }, normalStyle, layoutStyle),
56
+ ref: movableViewRef
57
+ }
58
+ ),
59
+ [],
60
+ { layoutRef }
61
+ )
53
62
 
54
63
  return createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(
55
64
  View,
@@ -36,39 +36,39 @@ import Animated, {
36
36
  import { collectDataset, noop } from '@mpxjs/utils'
37
37
 
38
38
  interface MovableViewProps {
39
- children: ReactNode;
40
- style?: Record<string, any>;
41
- direction: 'all' | 'vertical' | 'horizontal' | 'none';
42
- x?: number;
43
- y?: number;
44
- disabled?: boolean;
45
- animation?: boolean;
46
- id?: string;
47
- bindchange?: (event: unknown) => void;
48
- bindtouchstart?: (event: GestureTouchEvent) => void;
49
- catchtouchstart?: (event: GestureTouchEvent) => void;
50
- bindtouchmove?: (event: GestureTouchEvent) => void;
51
- catchtouchmove?: (event: GestureTouchEvent) => void;
52
- catchtouchend?: (event: GestureTouchEvent) => void;
53
- bindtouchend?: (event: GestureTouchEvent) => void;
54
- bindhtouchmove?: (event: GestureTouchEvent) => void;
55
- bindvtouchmove?: (event: GestureTouchEvent) => void;
56
- catchhtouchmove?: (event: GestureTouchEvent) => void;
57
- catchvtouchmove?: (event: GestureTouchEvent) => void;
58
- bindlongpress?: (event: GestureTouchEvent) => void;
59
- catchlongpress?: (event: GestureTouchEvent) => void;
60
- bindtap?: (event: GestureTouchEvent) => void;
61
- catchtap?: (event: GestureTouchEvent) => void;
62
- onLayout?: (event: LayoutChangeEvent) => void;
63
- 'out-of-bounds'?: boolean;
64
- 'wait-for'?: Array<GestureHandler>;
65
- 'simultaneous-handlers'?: Array<GestureHandler>;
66
- inertia?: boolean;
39
+ children: ReactNode
40
+ style?: Record<string, any>
41
+ direction: 'all' | 'vertical' | 'horizontal' | 'none'
42
+ x?: number
43
+ y?: number
44
+ disabled?: boolean
45
+ animation?: boolean
46
+ id?: string
47
+ bindchange?: (event: unknown) => void
48
+ bindtouchstart?: (event: GestureTouchEvent) => void
49
+ catchtouchstart?: (event: GestureTouchEvent) => void
50
+ bindtouchmove?: (event: GestureTouchEvent) => void
51
+ catchtouchmove?: (event: GestureTouchEvent) => void
52
+ catchtouchend?: (event: GestureTouchEvent) => void
53
+ bindtouchend?: (event: GestureTouchEvent) => void
54
+ bindhtouchmove?: (event: GestureTouchEvent) => void
55
+ bindvtouchmove?: (event: GestureTouchEvent) => void
56
+ catchhtouchmove?: (event: GestureTouchEvent) => void
57
+ catchvtouchmove?: (event: GestureTouchEvent) => void
58
+ bindlongpress?: (event: GestureTouchEvent) => void
59
+ catchlongpress?: (event: GestureTouchEvent) => void
60
+ bindtap?: (event: GestureTouchEvent) => void
61
+ catchtap?: (event: GestureTouchEvent) => void
62
+ onLayout?: (event: LayoutChangeEvent) => void
63
+ 'out-of-bounds'?: boolean
64
+ 'wait-for'?: Array<GestureHandler>
65
+ 'simultaneous-handlers'?: Array<GestureHandler>
66
+ inertia?: boolean
67
67
  'enable-var'?: boolean
68
- 'external-var-context'?: Record<string, any>;
69
- 'parent-font-size'?: number;
70
- 'parent-width'?: number;
71
- 'parent-height'?: number;
68
+ 'external-var-context'?: Record<string, any>
69
+ 'parent-font-size'?: number
70
+ 'parent-width'?: number
71
+ 'parent-height'?: number
72
72
  }
73
73
 
74
74
  const styles = StyleSheet.create({
@@ -235,7 +235,7 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
235
235
  offsetX: offsetX.value,
236
236
  offsetY: offsetY.value
237
237
  }),
238
- (currentValue: { offsetX: any; offsetY: any; }) => {
238
+ (currentValue: { offsetX: any; offsetY: any }) => {
239
239
  const { offsetX, offsetY } = currentValue
240
240
  runOnJS(handleTriggerChange)({
241
241
  x: offsetX,
@@ -342,11 +342,11 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
342
342
  props.onLayout && props.onLayout(e)
343
343
  }
344
344
 
345
- const extendEvent = useCallback((e: any, type: 'start'|'move'|'end') => {
345
+ const extendEvent = useCallback((e: any, type: 'start' | 'move' | 'end') => {
346
346
  const { y: navigationY = 0 } = navigation?.layout || {}
347
347
  const touchArr = [e.changedTouches, e.allTouches]
348
348
  touchArr.forEach(touches => {
349
- touches && touches.forEach((item: { absoluteX: number; absoluteY: number; pageX: number; pageY: number ; clientX: number; clientY: number}) => {
349
+ touches && touches.forEach((item: { absoluteX: number; absoluteY: number; pageX: number; pageY: number; clientX: number; clientY: number }) => {
350
350
  item.pageX = item.absoluteX
351
351
  item.pageY = item.absoluteY - navigationY
352
352
  item.clientX = item.absoluteX
@@ -565,11 +565,18 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
565
565
  'catchtouchend'
566
566
  ])
567
567
 
568
- const innerProps = useInnerProps(filterProps, extendObject({
569
- ref: nodeRef,
570
- onLayout: onLayout,
571
- style: [innerStyle, animatedStyles, layoutStyle]
572
- }, rewriteCatchEvent()))
568
+ const innerProps = useInnerProps(
569
+ extendObject(
570
+ {},
571
+ filterProps,
572
+ {
573
+ ref: nodeRef,
574
+ onLayout: onLayout,
575
+ style: [innerStyle, animatedStyles, layoutStyle]
576
+ },
577
+ rewriteCatchEvent()
578
+ )
579
+ )
573
580
 
574
581
  return createElement(GestureDetector, { gesture: gesture }, createElement(
575
582
  Animated.View,
@@ -7,9 +7,7 @@
7
7
  * ✔ url
8
8
  * ✔ delta
9
9
  */
10
- import { View } from 'react-native'
11
- import { useCallback, forwardRef, JSX, createElement } from 'react'
12
- import useInnerProps from './getInnerListeners'
10
+ import { useCallback, forwardRef, JSX, createElement, MutableRefObject } from 'react'
13
11
  import { redirectTo, navigateTo, navigateBack, reLaunch, switchTab } from '@mpxjs/api-proxy'
14
12
 
15
13
  import MpxView, { _ViewProps } from './mpx-view'
@@ -20,7 +18,7 @@ interface _NavigatorProps extends _ViewProps {
20
18
  delta: number
21
19
  }
22
20
 
23
- const _Navigator = forwardRef<View, _NavigatorProps>((props, ref): JSX.Element => {
21
+ const _Navigator = forwardRef<any, _NavigatorProps>((props, ref): JSX.Element => {
24
22
  const {
25
23
  children,
26
24
  'open-type': openType,
@@ -48,10 +46,10 @@ const _Navigator = forwardRef<View, _NavigatorProps>((props, ref): JSX.Element =
48
46
  }
49
47
  }, [openType, url, delta])
50
48
 
51
- const innerProps = useInnerProps(props, {
49
+ const innerProps = {
52
50
  ref,
53
51
  bindtap: handleClick
54
- })
52
+ }
55
53
 
56
54
  return createElement(MpxView, innerProps, children)
57
55
  })