@mpxjs/webpack-plugin 2.9.70-alpha.0 → 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.
- package/LICENSE +433 -0
- package/README.md +1 -1
- package/lib/config.js +0 -14
- package/lib/dependencies/ResolveDependency.js +0 -5
- package/lib/index.js +7 -38
- package/lib/json-compiler/helper.js +3 -3
- package/lib/loader.js +0 -53
- package/lib/parser.js +1 -1
- package/lib/platform/json/wx/index.js +21 -8
- package/lib/platform/style/wx/index.js +51 -54
- package/lib/platform/template/wx/component-config/button.js +2 -14
- package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
- package/lib/platform/template/wx/component-config/image.js +0 -4
- package/lib/platform/template/wx/component-config/index.js +1 -1
- package/lib/platform/template/wx/component-config/input.js +0 -4
- package/lib/platform/template/wx/component-config/movable-view.js +8 -1
- package/lib/platform/template/wx/component-config/picker-view.js +1 -5
- package/lib/platform/template/wx/component-config/rich-text.js +6 -2
- package/lib/platform/template/wx/component-config/scroll-view.js +1 -5
- package/lib/platform/template/wx/component-config/switch.js +0 -4
- package/lib/platform/template/wx/component-config/text.js +0 -4
- package/lib/platform/template/wx/component-config/textarea.js +0 -5
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/platform/template/wx/component-config/view.js +0 -4
- package/lib/platform/template/wx/index.js +1 -131
- package/lib/resolve-loader.js +1 -4
- package/lib/runtime/components/react/context.ts +8 -0
- package/lib/runtime/components/react/dist/context.js +2 -0
- package/lib/runtime/components/react/dist/getInnerListeners.js +39 -37
- package/lib/runtime/components/react/dist/mpx-button.jsx +16 -44
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +2 -4
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +5 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +93 -58
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +10 -14
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +94 -81
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +19 -16
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +10 -11
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +11 -4
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +31 -8
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +435 -371
- package/lib/runtime/components/react/dist/mpx-view.jsx +18 -53
- package/lib/runtime/components/react/dist/pickerFaces.js +3 -8
- package/lib/runtime/components/react/dist/pickerVIewContext.js +5 -0
- package/lib/runtime/components/react/dist/{pickerViewOverlay.jsx → pickerViewIndicator.jsx} +6 -6
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +2 -2
- package/lib/runtime/components/react/dist/useAnimationHooks.js +27 -10
- package/lib/runtime/components/react/dist/utils.jsx +162 -70
- package/lib/runtime/components/react/event.config.ts +25 -26
- package/lib/runtime/components/react/getInnerListeners.ts +236 -182
- package/lib/runtime/components/react/mpx-button.tsx +27 -69
- package/lib/runtime/components/react/mpx-canvas/html.ts +2 -4
- package/lib/runtime/components/react/mpx-canvas/index.tsx +44 -46
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +15 -13
- package/lib/runtime/components/react/mpx-checkbox.tsx +20 -21
- package/lib/runtime/components/react/mpx-form.tsx +15 -20
- package/lib/runtime/components/react/mpx-icon.tsx +2 -2
- package/lib/runtime/components/react/mpx-image.tsx +87 -47
- package/lib/runtime/components/react/mpx-input.tsx +24 -32
- package/lib/runtime/components/react/mpx-label.tsx +12 -14
- package/lib/runtime/components/react/mpx-movable-area.tsx +10 -16
- package/lib/runtime/components/react/mpx-movable-view.tsx +133 -92
- package/lib/runtime/components/react/mpx-navigator.tsx +3 -9
- package/lib/runtime/components/react/mpx-picker-view-column-item.tsx +76 -0
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +206 -183
- package/lib/runtime/components/react/mpx-picker-view.tsx +49 -48
- package/lib/runtime/components/react/mpx-radio-group.tsx +13 -15
- package/lib/runtime/components/react/mpx-radio.tsx +19 -25
- package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +115 -0
- package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
- package/lib/runtime/components/react/mpx-scroll-view.tsx +53 -43
- package/lib/runtime/components/react/mpx-swiper-item.tsx +45 -11
- package/lib/runtime/components/react/mpx-swiper.tsx +742 -0
- package/lib/runtime/components/react/mpx-switch.tsx +19 -15
- package/lib/runtime/components/react/mpx-text.tsx +8 -16
- package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
- package/lib/runtime/components/react/mpx-view.tsx +28 -77
- package/lib/runtime/components/react/mpx-web-view.tsx +94 -59
- package/lib/runtime/components/react/pickerFaces.ts +10 -7
- package/lib/runtime/components/react/pickerVIewContext.ts +27 -0
- package/lib/runtime/components/react/pickerViewIndicator.tsx +34 -0
- package/lib/runtime/components/react/pickerViewMask.tsx +30 -0
- package/lib/runtime/components/react/types/{getInnerListeners.ts → getInnerListeners.d.ts} +4 -5
- package/lib/runtime/components/react/types/global.d.ts +12 -1
- package/lib/runtime/components/react/useAnimationHooks.ts +60 -15
- package/lib/runtime/components/react/utils.tsx +175 -71
- package/lib/runtime/components/web/mpx-checkbox.vue +1 -1
- package/lib/runtime/components/web/mpx-picker-view-column.vue +9 -4
- package/lib/runtime/components/web/mpx-web-view.vue +34 -20
- package/lib/runtime/optionProcessor.js +0 -22
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/scope-id.js +30 -2
- package/lib/template-compiler/compiler.js +91 -39
- package/lib/utils/env.js +1 -6
- package/lib/utils/pre-process-json.js +9 -5
- package/lib/wxss/loader.js +15 -2
- package/package.json +4 -7
- package/lib/dependencies/AddEntryDependency.js +0 -24
- package/lib/runtime/components/react/dist/types/common.js +0 -1
- package/lib/runtime/components/react/dist/types/getInnerListeners.js +0 -1
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +0 -527
- package/lib/runtime/components/react/mpx-swiper/index.tsx +0 -80
- package/lib/runtime/components/react/mpx-swiper/type.ts +0 -87
- package/lib/runtime/components/react/pickerOverlay.tsx +0 -32
- package/lib/runtime/components/tenon/getInnerListeners.js +0 -334
- package/lib/runtime/components/tenon/tenon-button.vue +0 -309
- package/lib/runtime/components/tenon/tenon-image.vue +0 -66
- package/lib/runtime/components/tenon/tenon-input.vue +0 -171
- package/lib/runtime/components/tenon/tenon-rich-text.vue +0 -26
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +0 -127
- package/lib/runtime/components/tenon/tenon-switch.vue +0 -96
- package/lib/runtime/components/tenon/tenon-text.vue +0 -70
- package/lib/runtime/components/tenon/tenon-textarea.vue +0 -86
- package/lib/runtime/components/tenon/tenon-view.vue +0 -93
- package/lib/runtime/components/web/event.js +0 -105
- package/lib/runtime/optionProcessor.tenon.js +0 -84
- package/lib/style-compiler/plugins/hm.js +0 -20
- package/lib/tenon/index.js +0 -117
- package/lib/tenon/processJSON.js +0 -352
- package/lib/tenon/processScript.js +0 -203
- package/lib/tenon/processStyles.js +0 -21
- package/lib/tenon/processTemplate.js +0 -126
- package/lib/tenon/script-helper.js +0 -223
- package/lib/utils/get-relative-path.js +0 -25
- /package/lib/runtime/components/react/types/{common.ts → common.d.ts} +0 -0
|
@@ -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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
return createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(
|
|
55
|
+
View,
|
|
56
|
+
innerProps,
|
|
57
|
+
wrapChildren(
|
|
58
|
+
props,
|
|
59
59
|
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
hasVarDec,
|
|
64
|
-
varContext: varContextRef.current
|
|
65
|
-
}
|
|
66
|
-
)
|
|
60
|
+
hasVarDec,
|
|
61
|
+
varContext: varContextRef.current
|
|
67
62
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
63
|
+
)
|
|
64
|
+
))
|
|
71
65
|
})
|
|
72
66
|
|
|
73
67
|
_MovableArea.displayName = 'MpxMovableArea'
|
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
* ✘ scale-min
|
|
12
12
|
* ✘ scale-max
|
|
13
13
|
* ✘ scale-value
|
|
14
|
-
*
|
|
14
|
+
* ✔ animation
|
|
15
15
|
* ✔ bindchange
|
|
16
16
|
* ✘ bindscale
|
|
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
|
-
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 } 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:
|
|
47
|
-
catchtouchstart?: (event:
|
|
48
|
-
bindtouchmove?: (event:
|
|
49
|
-
catchtouchmove?: (event:
|
|
50
|
-
catchtouchend?: (event:
|
|
51
|
-
bindtouchend?: (event:
|
|
52
|
-
bindhtouchmove?: (event:
|
|
53
|
-
bindvtouchmove?: (event:
|
|
54
|
-
catchhtouchmove?: (event:
|
|
55
|
-
catchvtouchmove?: (event:
|
|
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
|
-
|
|
162
|
+
(originSimultaneousHandlers || []).some((handler, index) => handler !== prevSimultaneousHandlersRef.current[index])
|
|
157
163
|
|
|
158
164
|
const hasWaitForHandlersChanged = prevWaitForHandlersRef.current.length !== (waitFor?.length || 0) ||
|
|
159
|
-
|
|
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
|
|
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
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
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
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
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
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
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
|
+
}
|
|
380
391
|
|
|
381
|
-
|
|
392
|
+
const triggerEndOnJS = ({ e }: { e: GestureTouchEvent }) => {
|
|
393
|
+
extendEvent(e)
|
|
394
|
+
bindtouchend && bindtouchend(e)
|
|
395
|
+
catchtouchend && catchtouchend(e)
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const gesture = useMemo(() => {
|
|
399
|
+
const handleTriggerMove = (e: GestureTouchEvent) => {
|
|
382
400
|
'worklet'
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,49 +527,60 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
|
|
|
497
527
|
}
|
|
498
528
|
})
|
|
499
529
|
|
|
500
|
-
const
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
{
|
|
505
|
-
{
|
|
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
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
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
|
-
|
|
544
|
+
|
|
545
|
+
return handlers
|
|
517
546
|
}
|
|
518
547
|
|
|
519
|
-
const catchEventHandlers = injectCatchEvent(props)
|
|
520
548
|
const layoutStyle = !hasLayoutRef.current && hasSelfPercent ? HIDDEN_STYLE : {}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
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
|
+
|
|
571
|
+
return createElement(GestureDetector, { gesture: gesture }, createElement(
|
|
572
|
+
Animated.View,
|
|
573
|
+
innerProps,
|
|
574
|
+
wrapChildren(
|
|
575
|
+
props,
|
|
576
|
+
{
|
|
577
|
+
hasVarDec,
|
|
578
|
+
varContext: varContextRef.current,
|
|
579
|
+
textStyle,
|
|
580
|
+
textProps
|
|
581
|
+
}
|
|
582
|
+
)
|
|
583
|
+
))
|
|
543
584
|
})
|
|
544
585
|
|
|
545
586
|
_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
|
|
|
@@ -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
|
|
|
@@ -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'
|
|
@@ -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
|