@mpxjs/webpack-plugin 2.9.70 → 2.9.71

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 (60) hide show
  1. package/lib/platform/template/wx/component-config/movable-view.js +8 -1
  2. package/lib/platform/template/wx/component-config/picker-view.js +1 -5
  3. package/lib/platform/template/wx/component-config/scroll-view.js +1 -1
  4. package/lib/platform/template/wx/index.js +0 -4
  5. package/lib/runtime/components/react/context.ts +8 -0
  6. package/lib/runtime/components/react/dist/context.js +2 -0
  7. package/lib/runtime/components/react/dist/getInnerListeners.js +34 -31
  8. package/lib/runtime/components/react/dist/mpx-button.jsx +16 -44
  9. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +93 -58
  10. package/lib/runtime/components/react/dist/mpx-navigator.jsx +1 -1
  11. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +35 -0
  12. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +151 -127
  13. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +38 -34
  14. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +10 -11
  15. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +11 -4
  16. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +31 -8
  17. package/lib/runtime/components/react/dist/mpx-swiper.jsx +670 -0
  18. package/lib/runtime/components/react/dist/mpx-view.jsx +15 -53
  19. package/lib/runtime/components/react/dist/pickerFaces.js +7 -6
  20. package/lib/runtime/components/react/dist/pickerVIewContext.js +14 -0
  21. package/lib/runtime/components/react/dist/pickerViewIndicator.jsx +23 -0
  22. package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
  23. package/lib/runtime/components/react/dist/useAnimationHooks.js +20 -2
  24. package/lib/runtime/components/react/dist/utils.jsx +74 -11
  25. package/lib/runtime/components/react/getInnerListeners.ts +43 -32
  26. package/lib/runtime/components/react/mpx-button.tsx +20 -57
  27. package/lib/runtime/components/react/mpx-movable-view.tsx +119 -74
  28. package/lib/runtime/components/react/mpx-navigator.tsx +1 -1
  29. package/lib/runtime/components/react/mpx-picker-view-column-item.tsx +76 -0
  30. package/lib/runtime/components/react/mpx-picker-view-column.tsx +206 -183
  31. package/lib/runtime/components/react/mpx-picker-view.tsx +49 -48
  32. package/lib/runtime/components/react/mpx-rich-text/index.tsx +12 -18
  33. package/lib/runtime/components/react/mpx-scroll-view.tsx +21 -10
  34. package/lib/runtime/components/react/mpx-swiper-item.tsx +45 -11
  35. package/lib/runtime/components/react/mpx-swiper.tsx +742 -0
  36. package/lib/runtime/components/react/mpx-view.tsx +18 -65
  37. package/lib/runtime/components/react/pickerFaces.ts +10 -7
  38. package/lib/runtime/components/react/pickerVIewContext.ts +27 -0
  39. package/lib/runtime/components/react/pickerViewIndicator.tsx +34 -0
  40. package/lib/runtime/components/react/pickerViewMask.tsx +30 -0
  41. package/lib/runtime/components/react/types/{getInnerListeners.ts → getInnerListeners.d.ts} +4 -5
  42. package/lib/runtime/components/react/types/global.d.ts +10 -0
  43. package/lib/runtime/components/react/useAnimationHooks.ts +24 -3
  44. package/lib/runtime/components/react/utils.tsx +85 -12
  45. package/lib/runtime/components/web/mpx-checkbox.vue +1 -1
  46. package/lib/runtime/components/web/mpx-picker-view-column.vue +9 -4
  47. package/lib/template-compiler/compiler.js +61 -13
  48. package/lib/wxss/loader.js +15 -2
  49. package/package.json +3 -3
  50. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -480
  51. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
  52. package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
  53. package/lib/runtime/components/react/dist/pickerOverlay.jsx +0 -21
  54. package/lib/runtime/components/react/dist/types/common.js +0 -1
  55. package/lib/runtime/components/react/dist/types/getInnerListeners.js +0 -1
  56. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +0 -527
  57. package/lib/runtime/components/react/mpx-swiper/index.tsx +0 -80
  58. package/lib/runtime/components/react/mpx-swiper/type.ts +0 -87
  59. package/lib/runtime/components/react/pickerOverlay.tsx +0 -32
  60. /package/lib/runtime/components/react/types/{common.ts → common.d.ts} +0 -0
@@ -34,7 +34,7 @@
34
34
  * ✘ bindagreeprivacyauthorization
35
35
  * ✔ bindtap
36
36
  */
37
- import { createElement, useEffect, useRef, useState, ReactNode, forwardRef, useContext, JSX } from 'react'
37
+ import { createElement, useEffect, useRef, ReactNode, forwardRef, useContext, JSX } from 'react'
38
38
  import {
39
39
  View,
40
40
  StyleSheet,
@@ -45,10 +45,12 @@ import {
45
45
  NativeSyntheticEvent
46
46
  } from 'react-native'
47
47
  import { warn } from '@mpxjs/utils'
48
- import { getCurrentPage, splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
48
+ import { GestureDetector, PanGesture } from 'react-native-gesture-handler'
49
+ import { getCurrentPage, splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useHover } from './utils'
49
50
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
50
51
  import useNodesRef, { HandlerRef } from './useNodesRef'
51
52
  import { RouteContext, FormContext } from './context'
53
+ import type { ExtendedViewStyle } from './types/common'
52
54
 
53
55
  export type Type = 'default' | 'primary' | 'warn'
54
56
 
@@ -68,7 +70,7 @@ export interface ButtonProps {
68
70
  disabled?: boolean
69
71
  loading?: boolean
70
72
  'hover-class'?: string
71
- 'hover-style'?: ViewStyle & TextStyle & Record<string, any>
73
+ 'hover-style'?: ExtendedViewStyle
72
74
  'hover-start-time'?: number
73
75
  'hover-stay-time'?: number
74
76
  'open-type'?: OpenType
@@ -83,8 +85,6 @@ export interface ButtonProps {
83
85
  children: ReactNode
84
86
  bindgetuserinfo?: (userInfo: any) => void
85
87
  bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
86
- bindtouchstart?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
87
- bindtouchend?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
88
88
  }
89
89
 
90
90
  const LOADING_IMAGE_URI =
@@ -216,15 +216,16 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
216
216
  style = {},
217
217
  children,
218
218
  bindgetuserinfo,
219
- bindtap,
220
- bindtouchstart,
221
- bindtouchend
219
+ bindtap
222
220
  } = props
223
221
 
224
222
  const pageId = useContext(RouteContext)
225
223
 
226
224
  const formContext = useContext(FormContext)
227
225
 
226
+ const enableHover = hoverClass !== 'none'
227
+ const { isHover, gesture } = useHover({ enableHover, hoverStartTime, hoverStayTime, disabled })
228
+
228
229
  let submitFn: () => void | undefined
229
230
  let resetFn: () => void | undefined
230
231
 
@@ -233,27 +234,15 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
233
234
  resetFn = formContext.reset
234
235
  }
235
236
 
236
- const refs = useRef<{
237
- hoverStartTimer: ReturnType<typeof setTimeout> | undefined
238
- hoverStayTimer: ReturnType<typeof setTimeout> | undefined
239
- }>({
240
- hoverStartTimer: undefined,
241
- hoverStayTimer: undefined
242
- })
243
-
244
- const [isHover, setIsHover] = useState(false)
245
-
246
237
  const isMiniSize = size === 'mini'
247
238
 
248
- const applyHoverEffect = isHover && hoverClass !== 'none'
249
-
250
239
  const [color, hoverColor, plainColor, disabledColor] = TypeColorMap[type]
251
240
 
252
- const normalBackgroundColor = disabled ? disabledColor : applyHoverEffect || loading ? hoverColor : color
241
+ const normalBackgroundColor = disabled ? disabledColor : isHover || loading ? hoverColor : color
253
242
 
254
243
  const plainBorderColor = disabled
255
244
  ? 'rgba(0, 0, 0, .2)'
256
- : applyHoverEffect
245
+ : isHover
257
246
  ? `rgba(${plainColor},.6)`
258
247
  : `rgb(${plainColor})`
259
248
 
@@ -261,14 +250,14 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
261
250
 
262
251
  const plainTextColor = disabled
263
252
  ? 'rgba(0, 0, 0, .2)'
264
- : applyHoverEffect
253
+ : isHover
265
254
  ? `rgba(${plainColor}, .6)`
266
255
  : `rgb(${plainColor})`
267
256
 
268
257
  const normalTextColor =
269
258
  type === 'default'
270
- ? `rgba(0, 0, 0, ${disabled ? 0.3 : applyHoverEffect || loading ? 0.6 : 1})`
271
- : `rgba(255 ,255 ,255 , ${disabled || applyHoverEffect || loading ? 0.6 : 1})`
259
+ ? `rgba(0, 0, 0, ${disabled ? 0.3 : isHover || loading ? 0.6 : 1})`
260
+ : `rgba(255 ,255 ,255 , ${disabled || isHover || loading ? 0.6 : 1})`
272
261
 
273
262
  const viewStyle = {
274
263
  borderWidth: 1,
@@ -297,7 +286,7 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
297
286
  {},
298
287
  defaultStyle,
299
288
  style,
300
- applyHoverEffect ? hoverStyle : {}
289
+ isHover ? hoverStyle : {}
301
290
  )
302
291
 
303
292
  const {
@@ -366,34 +355,6 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
366
355
  }
367
356
  }
368
357
 
369
- const setStayTimer = () => {
370
- clearTimeout(refs.current.hoverStayTimer)
371
- refs.current.hoverStayTimer = setTimeout(() => {
372
- setIsHover(false)
373
- clearTimeout(refs.current.hoverStayTimer)
374
- }, hoverStayTime)
375
- }
376
-
377
- const setStartTimer = () => {
378
- clearTimeout(refs.current.hoverStartTimer)
379
- refs.current.hoverStartTimer = setTimeout(() => {
380
- setIsHover(true)
381
- clearTimeout(refs.current.hoverStartTimer)
382
- }, hoverStartTime)
383
- }
384
-
385
- const onTouchStart = (evt: NativeSyntheticEvent<TouchEvent>) => {
386
- bindtouchstart && bindtouchstart(evt)
387
- if (disabled) return
388
- setStartTimer()
389
- }
390
-
391
- const onTouchEnd = (evt: NativeSyntheticEvent<TouchEvent>) => {
392
- bindtouchend && bindtouchend(evt)
393
- if (disabled) return
394
- setStayTimer()
395
- }
396
-
397
358
  const handleFormTypeFn = () => {
398
359
  if (formType === 'submit') {
399
360
  submitFn && submitFn()
@@ -418,8 +379,6 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
418
379
  },
419
380
  layoutProps,
420
381
  {
421
- bindtouchstart: (bindtouchstart || !disabled) && onTouchStart,
422
- bindtouchend: (bindtouchend || !disabled) && onTouchEnd,
423
382
  bindtap: !disabled && onTap
424
383
  }
425
384
  ),
@@ -442,7 +401,7 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
442
401
  }
443
402
  )
444
403
 
445
- return createElement(View, innerProps, loading && createElement(Loading, { alone: !children }),
404
+ const baseButton = createElement(View, innerProps, loading && createElement(Loading, { alone: !children }),
446
405
  wrapChildren(
447
406
  props,
448
407
  {
@@ -453,6 +412,10 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
453
412
  }
454
413
  )
455
414
  )
415
+
416
+ return enableHover
417
+ ? createElement(GestureDetector, { gesture: gesture as PanGesture }, baseButton)
418
+ : baseButton
456
419
  })
457
420
 
458
421
  Button.displayName = 'MpxButton'
@@ -11,7 +11,7 @@
11
11
  * ✘ scale-min
12
12
  * ✘ scale-max
13
13
  * ✘ scale-value
14
- * animation
14
+ * animation
15
15
  * ✔ bindchange
16
16
  * ✘ bindscale
17
17
  * ✔ htouchmove
@@ -19,10 +19,10 @@
19
19
  */
20
20
  import { useEffect, forwardRef, ReactNode, useContext, useCallback, useRef, useMemo, createElement } from 'react'
21
21
  import { StyleSheet, NativeSyntheticEvent, View, LayoutChangeEvent } from 'react-native'
22
- import { getCustomEvent } from './getInnerListeners'
22
+ import useInnerProps, { 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, extendObject } from './utils'
25
+ import { useTransformStyle, splitProps, splitStyle, HIDDEN_STYLE, wrapChildren, GestureHandler, flatGesture, extendObject, omit } from './utils'
26
26
  import { GestureDetector, Gesture, GestureTouchEvent, GestureStateChangeEvent, PanGestureHandlerEventPayload, PanGesture } from 'react-native-gesture-handler'
27
27
  import Animated, {
28
28
  useSharedValue,
@@ -33,6 +33,7 @@ import Animated, {
33
33
  useAnimatedReaction,
34
34
  withSpring
35
35
  } from 'react-native-reanimated'
36
+ import { collectDataset, noop } from '@mpxjs/utils'
36
37
 
37
38
  interface MovableViewProps {
38
39
  children: ReactNode;
@@ -42,17 +43,22 @@ interface MovableViewProps {
42
43
  y?: number;
43
44
  disabled?: boolean;
44
45
  animation?: boolean;
46
+ id?: string;
45
47
  bindchange?: (event: unknown) => void;
46
- bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent>) => void;
47
- catchtouchstart?: (event: NativeSyntheticEvent<TouchEvent>) => void;
48
- bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void;
49
- catchtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void;
50
- catchtouchend?: (event: NativeSyntheticEvent<TouchEvent>) => void;
51
- bindtouchend?: (event: NativeSyntheticEvent<TouchEvent>) => void;
52
- bindhtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void;
53
- bindvtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void;
54
- catchhtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void;
55
- catchvtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => 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;
56
62
  onLayout?: (event: LayoutChangeEvent) => void;
57
63
  'out-of-bounds'?: boolean;
58
64
  'wait-for'?: Array<GestureHandler>;
@@ -153,10 +159,10 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
153
159
  })
154
160
 
155
161
  const hasSimultaneousHandlersChanged = prevSimultaneousHandlersRef.current.length !== (originSimultaneousHandlers?.length || 0) ||
156
- (originSimultaneousHandlers || []).some((handler, index) => handler !== prevSimultaneousHandlersRef.current[index])
162
+ (originSimultaneousHandlers || []).some((handler, index) => handler !== prevSimultaneousHandlersRef.current[index])
157
163
 
158
164
  const hasWaitForHandlersChanged = prevWaitForHandlersRef.current.length !== (waitFor?.length || 0) ||
159
- (waitFor || []).some((handler, index) => handler !== prevWaitForHandlersRef.current[index])
165
+ (waitFor || []).some((handler, index) => handler !== prevWaitForHandlersRef.current[index])
160
166
 
161
167
  if (hasSimultaneousHandlersChanged || hasWaitForHandlersChanged) {
162
168
  gestureSwitch.current = !gestureSwitch.current
@@ -333,8 +339,7 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
333
339
  props.onLayout && props.onLayout(e)
334
340
  }
335
341
 
336
- const extendEvent = useCallback((e: any) => {
337
- 'worklet'
342
+ const extendEvent = useCallback((e: any, obj?: Record<string, any>) => {
338
343
  const touchArr = [e.changedTouches, e.allTouches]
339
344
  touchArr.forEach(touches => {
340
345
  touches && touches.forEach((item: { absoluteX: number; absoluteY: number; pageX: number; pageY: number }) => {
@@ -342,48 +347,69 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
342
347
  item.pageY = item.absoluteY
343
348
  })
344
349
  })
345
- e.touches = e.allTouches
350
+ Object.assign(e, {
351
+ touches: e.allTouches,
352
+ detail: {
353
+ x: e.changedTouches[0].absoluteX,
354
+ y: e.changedTouches[0].absoluteY
355
+ },
356
+ currentTarget: {
357
+ id: props.id || '',
358
+ dataset: collectDataset(props),
359
+ offsetLeft: 0,
360
+ offsetTop: 0
361
+ }
362
+ }, obj)
346
363
  }, [])
347
364
 
348
- const gesture = useMemo(() => {
349
- const handleTriggerStart = (e: any) => {
350
- 'worklet'
351
- extendEvent(e)
352
- bindtouchstart && runOnJS(bindtouchstart)(e)
353
- catchtouchstart && runOnJS(catchtouchstart)(e)
354
- }
355
-
356
- const handleTriggerMove = (e: any) => {
357
- 'worklet'
358
- extendEvent(e)
359
- const hasTouchmove = !!bindhtouchmove || !!bindvtouchmove || !!bindtouchmove
360
- const hasCatchTouchmove = !!catchhtouchmove || !!catchvtouchmove || !!catchtouchmove
365
+ const triggerStartOnJS = ({ e }: { e: GestureTouchEvent }) => {
366
+ extendEvent(e)
367
+ bindtouchstart && bindtouchstart(e)
368
+ catchtouchstart && catchtouchstart(e)
369
+ }
361
370
 
362
- if (hasTouchmove) {
363
- if (touchEvent.value === 'htouchmove') {
364
- bindhtouchmove && runOnJS(bindhtouchmove)(e)
365
- } else if (touchEvent.value === 'vtouchmove') {
366
- bindvtouchmove && runOnJS(bindvtouchmove)(e)
367
- }
368
- bindtouchmove && runOnJS(bindtouchmove)(e)
371
+ const triggerMoveOnJS = ({ e, hasTouchmove, hasCatchTouchmove, touchEvent }: { e: GestureTouchEvent; hasTouchmove: boolean; hasCatchTouchmove: boolean; touchEvent: string }) => {
372
+ extendEvent(e)
373
+ if (hasTouchmove) {
374
+ if (touchEvent === 'htouchmove') {
375
+ bindhtouchmove && bindhtouchmove(e)
376
+ } else if (touchEvent === 'vtouchmove') {
377
+ bindvtouchmove && bindvtouchmove(e)
369
378
  }
379
+ bindtouchmove && bindtouchmove(e)
380
+ }
370
381
 
371
- if (hasCatchTouchmove) {
372
- if (touchEvent.value === 'htouchmove') {
373
- catchhtouchmove && runOnJS(catchhtouchmove)(e)
374
- } else if (touchEvent.value === 'vtouchmove') {
375
- catchvtouchmove && runOnJS(catchvtouchmove)(e)
376
- }
377
- catchtouchmove && runOnJS(catchtouchmove)(e)
382
+ if (hasCatchTouchmove) {
383
+ if (touchEvent === 'htouchmove') {
384
+ catchhtouchmove && catchhtouchmove(e)
385
+ } else if (touchEvent === 'vtouchmove') {
386
+ catchvtouchmove && catchvtouchmove(e)
378
387
  }
388
+ catchtouchmove && catchtouchmove(e)
379
389
  }
390
+ }
391
+
392
+ const triggerEndOnJS = ({ e }: { e: GestureTouchEvent }) => {
393
+ extendEvent(e)
394
+ bindtouchend && bindtouchend(e)
395
+ catchtouchend && catchtouchend(e)
396
+ }
380
397
 
381
- const handleTriggerEnd = (e: any) => {
398
+ const gesture = useMemo(() => {
399
+ const handleTriggerMove = (e: GestureTouchEvent) => {
382
400
  'worklet'
383
- extendEvent(e)
384
- bindtouchend && runOnJS(bindtouchend)(e)
385
- catchtouchend && runOnJS(catchtouchend)(e)
401
+ const hasTouchmove = !!bindhtouchmove || !!bindvtouchmove || !!bindtouchmove
402
+ const hasCatchTouchmove = !!catchhtouchmove || !!catchvtouchmove || !!catchtouchmove
403
+ if (hasTouchmove || hasCatchTouchmove) {
404
+ runOnJS(triggerMoveOnJS)({
405
+ e,
406
+ touchEvent: touchEvent.value,
407
+ hasTouchmove,
408
+ hasCatchTouchmove
409
+ })
410
+ }
386
411
  }
412
+
387
413
  const gesturePan = Gesture.Pan()
388
414
  .onTouchesDown((e: GestureTouchEvent) => {
389
415
  'worklet'
@@ -393,12 +419,14 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
393
419
  x: changedTouches.x,
394
420
  y: changedTouches.y
395
421
  }
396
- handleTriggerStart(e)
422
+ if (bindtouchstart || catchtouchstart) {
423
+ runOnJS(triggerStartOnJS)({ e })
424
+ }
397
425
  })
398
426
  .onTouchesMove((e: GestureTouchEvent) => {
399
427
  'worklet'
400
- isMoving.value = true
401
428
  const changedTouches = e.changedTouches[0] || { x: 0, y: 0 }
429
+ isMoving.value = true
402
430
  if (isFirstTouch.value) {
403
431
  touchEvent.value = Math.abs(changedTouches.x - startPosition.value.x) > Math.abs(changedTouches.y - startPosition.value.y) ? 'htouchmove' : 'vtouchmove'
404
432
  isFirstTouch.value = false
@@ -430,7 +458,9 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
430
458
  'worklet'
431
459
  isFirstTouch.value = true
432
460
  isMoving.value = false
433
- handleTriggerEnd(e)
461
+ if (bindtouchend || catchtouchend) {
462
+ runOnJS(triggerEndOnJS)({ e })
463
+ }
434
464
  if (disabled) return
435
465
  if (!inertia) {
436
466
  const { x, y } = checkBoundaryPosition({ positionX: offsetX.value, positionY: offsetY.value })
@@ -454,8 +484,8 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
454
484
  })
455
485
  .onFinalize((e: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {
456
486
  'worklet'
457
- if (!inertia || disabled || !animation) return
458
487
  isMoving.value = false
488
+ if (!inertia || disabled || !animation) return
459
489
  if (direction === 'horizontal' || direction === 'all') {
460
490
  xInertialMotion.value = true
461
491
  offsetX.value = withDecay({
@@ -497,35 +527,50 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
497
527
  }
498
528
  })
499
529
 
500
- const injectCatchEvent = (props: Record<string, any>) => {
501
- const eventHandlers: Record<string, any> = {}
502
- const catchEventList = [
503
- { name: 'onTouchStart', value: ['catchtouchstart'] },
504
- { name: 'onTouchMove', value: ['catchtouchmove', 'catchvtouchmove', 'catchhtouchmove'] },
505
- { name: 'onTouchEnd', value: ['catchtouchend'] }
530
+ const rewriteCatchEvent = () => {
531
+ const handlers: Record<string, typeof noop> = {}
532
+
533
+ const events = [
534
+ { type: 'touchstart' },
535
+ { type: 'touchmove', alias: ['vtouchmove', 'htouchmove'] },
536
+ { type: 'touchend' }
506
537
  ]
507
- catchEventList.forEach(event => {
508
- event.value.forEach(name => {
509
- if (props[name] && !eventHandlers[event.name]) {
510
- eventHandlers[event.name] = (e: NativeSyntheticEvent<TouchEvent>) => {
511
- e.stopPropagation()
512
- }
513
- }
514
- })
538
+ events.forEach(({ type, alias = [] }) => {
539
+ const hasCatchEvent =
540
+ props[`catch${type}` as keyof typeof props] ||
541
+ alias.some(name => props[`catch${name}` as keyof typeof props])
542
+ if (hasCatchEvent) handlers[`catch${type}`] = noop
515
543
  })
516
- return eventHandlers
544
+
545
+ return handlers
517
546
  }
518
547
 
519
- const catchEventHandlers = injectCatchEvent(props)
520
548
  const layoutStyle = !hasLayoutRef.current && hasSelfPercent ? HIDDEN_STYLE : {}
521
549
 
550
+ // bind 相关 touch 事件直接由 gesture 触发,无须重复挂载
551
+ // catch 相关 touch 事件需要重写并通过 useInnerProps 注入阻止冒泡逻辑
552
+ const filterProps = omit(props, [
553
+ 'bindtouchstart',
554
+ 'bindtouchmove',
555
+ 'bindvtouchmove',
556
+ 'bindhtouchmove',
557
+ 'bindtouchend',
558
+ 'catchtouchstart',
559
+ 'catchtouchmove',
560
+ 'catchvtouchmove',
561
+ 'catchhtouchmove',
562
+ 'catchtouchend'
563
+ ])
564
+
565
+ const innerProps = useInnerProps(filterProps, extendObject({
566
+ ref: nodeRef,
567
+ onLayout: onLayout,
568
+ style: [innerStyle, animatedStyles, layoutStyle]
569
+ }, rewriteCatchEvent()))
570
+
522
571
  return createElement(GestureDetector, { gesture: gesture }, createElement(
523
572
  Animated.View,
524
- extendObject({
525
- ref: nodeRef,
526
- onLayout: onLayout,
527
- style: [innerStyle, animatedStyles, layoutStyle]
528
- }, catchEventHandlers),
573
+ innerProps,
529
574
  wrapChildren(
530
575
  props,
531
576
  {
@@ -24,7 +24,7 @@ const _Navigator = forwardRef<View, _NavigatorProps>((props, ref): JSX.Element =
24
24
  const {
25
25
  children,
26
26
  'open-type': openType,
27
- url,
27
+ url = '',
28
28
  delta
29
29
  } = props
30
30
 
@@ -0,0 +1,76 @@
1
+ import React, { useEffect } from 'react'
2
+ import { LayoutChangeEvent } from 'react-native'
3
+ import Reanimated, { Extrapolation, interpolate, useAnimatedStyle, useSharedValue } from 'react-native-reanimated'
4
+ import { wrapChildren, extendObject } from './utils'
5
+ import { createFaces } from './pickerFaces'
6
+ import { usePickerViewColumnAnimationContext, usePickerViewStyleContext } from './pickerVIewContext'
7
+
8
+ interface PickerColumnItemProps {
9
+ item: React.ReactElement
10
+ index: number
11
+ itemHeight: number
12
+ itemWidth?: number | '100%'
13
+ textStyle: Record<string, any>
14
+ visibleCount: number
15
+ textProps?: any
16
+ onItemLayout?: (e: LayoutChangeEvent) => void
17
+ }
18
+
19
+ const PickerViewColumnItem: React.FC<PickerColumnItemProps> = ({
20
+ item,
21
+ index,
22
+ itemHeight,
23
+ itemWidth = '100%',
24
+ textStyle,
25
+ textProps,
26
+ visibleCount,
27
+ onItemLayout
28
+ }) => {
29
+ const textStyleFromAncestor = usePickerViewStyleContext()
30
+ const offsetYShared = usePickerViewColumnAnimationContext()
31
+ const facesShared = useSharedValue(createFaces(itemHeight, visibleCount))
32
+
33
+ useEffect(() => {
34
+ facesShared.value = createFaces(itemHeight, visibleCount)
35
+ }, [itemHeight])
36
+
37
+ const animatedStyles = useAnimatedStyle(() => {
38
+ const inputRange = facesShared.value.map((f) => itemHeight * (index + f.index))
39
+ return {
40
+ opacity: interpolate(offsetYShared.value, inputRange, facesShared.value.map((x) => x.opacity), Extrapolation.CLAMP),
41
+ transform: [
42
+ { translateY: interpolate(offsetYShared.value, inputRange, facesShared.value.map((x) => x.offsetY), Extrapolation.EXTEND) },
43
+ { rotateX: interpolate(offsetYShared.value, inputRange, facesShared.value.map((x) => x.deg), Extrapolation.CLAMP) + 'deg' },
44
+ { scale: interpolate(offsetYShared.value, inputRange, facesShared.value.map((x) => x.scale), Extrapolation.EXTEND) }
45
+ ]
46
+ }
47
+ })
48
+
49
+ const strKey = `picker-column-item-${index}`
50
+ const restProps = index === 0 ? { onLayout: onItemLayout } : {}
51
+ const itemProps = extendObject(
52
+ {
53
+ style: extendObject(
54
+ { height: itemHeight, width: '100%' },
55
+ textStyleFromAncestor,
56
+ textStyle,
57
+ item.props.style
58
+ )
59
+ },
60
+ textProps,
61
+ restProps
62
+ )
63
+ const realItem = React.cloneElement(item, itemProps)
64
+
65
+ return (
66
+ <Reanimated.View
67
+ key={strKey}
68
+ style={[{ height: itemHeight, width: itemWidth }, animatedStyles]}
69
+ >
70
+ {realItem}
71
+ </Reanimated.View>
72
+ )
73
+ }
74
+
75
+ PickerViewColumnItem.displayName = 'MpxPickerViewColumnItem'
76
+ export default PickerViewColumnItem