@mpxjs/webpack-plugin 2.10.7-beta.9 → 2.10.7
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/lib/dependencies/RecordPageConfigsMapDependency.js +1 -1
- package/lib/index.js +5 -6
- package/lib/platform/style/wx/index.js +0 -7
- package/lib/platform/template/wx/component-config/index.js +1 -5
- package/lib/platform/template/wx/component-config/movable-view.js +10 -1
- package/lib/platform/template/wx/index.js +2 -1
- package/lib/runtime/components/react/context.ts +4 -23
- package/lib/runtime/components/react/dist/context.js +2 -5
- package/lib/runtime/components/react/dist/getInnerListeners.js +1 -1
- package/lib/runtime/components/react/dist/mpx-button.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +9 -63
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +63 -308
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +15 -31
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +27 -53
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +14 -28
- package/lib/runtime/components/react/dist/useAnimationHooks.js +2 -87
- package/lib/runtime/components/react/getInnerListeners.ts +1 -1
- package/lib/runtime/components/react/mpx-button.tsx +2 -3
- package/lib/runtime/components/react/mpx-movable-area.tsx +11 -98
- package/lib/runtime/components/react/mpx-movable-view.tsx +64 -358
- package/lib/runtime/components/react/mpx-scroll-view.tsx +59 -84
- package/lib/runtime/components/react/mpx-swiper.tsx +25 -53
- package/lib/runtime/components/react/mpx-web-view.tsx +13 -33
- package/lib/runtime/components/react/types/global.d.ts +15 -0
- package/lib/runtime/components/react/useAnimationHooks.ts +2 -85
- package/lib/runtime/components/web/mpx-scroll-view.vue +4 -18
- package/lib/template-compiler/bind-this.js +1 -2
- package/lib/template-compiler/compiler.js +2 -2
- package/package.json +4 -4
- package/lib/platform/template/wx/component-config/sticky-header.js +0 -23
- package/lib/platform/template/wx/component-config/sticky-section.js +0 -23
- package/lib/runtime/components/react/AsyncContainer.tsx +0 -189
- package/lib/runtime/components/react/dist/AsyncContainer.jsx +0 -141
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +0 -117
- package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +0 -45
- package/lib/runtime/components/react/mpx-sticky-header.tsx +0 -181
- package/lib/runtime/components/react/mpx-sticky-section.tsx +0 -96
- package/lib/runtime/components/web/mpx-sticky-header.vue +0 -99
- package/lib/runtime/components/web/mpx-sticky-section.vue +0 -15
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* ✘ scale-area
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { View } from 'react-native'
|
|
6
|
-
import { JSX, forwardRef, ReactNode, useRef, useMemo,
|
|
7
|
-
import { GestureDetector, Gesture } from 'react-native-gesture-handler'
|
|
8
|
-
import { useSharedValue } from 'react-native-reanimated'
|
|
6
|
+
import { JSX, forwardRef, ReactNode, useRef, useMemo, createElement } from 'react'
|
|
9
7
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
10
8
|
import useInnerProps from './getInnerListeners'
|
|
11
|
-
import { MovableAreaContext
|
|
9
|
+
import { MovableAreaContext } from './context'
|
|
12
10
|
import { useTransformStyle, wrapChildren, useLayout, extendObject } from './utils'
|
|
13
11
|
import Portal from './mpx-portal'
|
|
14
12
|
|
|
@@ -17,7 +15,6 @@ interface MovableAreaProps {
|
|
|
17
15
|
children: ReactNode
|
|
18
16
|
width?: number
|
|
19
17
|
height?: number
|
|
20
|
-
'scale-area'?: boolean
|
|
21
18
|
'enable-offset'?: boolean
|
|
22
19
|
'enable-var'?: boolean
|
|
23
20
|
'external-var-context'?: Record<string, any>
|
|
@@ -26,21 +23,8 @@ interface MovableAreaProps {
|
|
|
26
23
|
'parent-height'?: number
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
interface MovableViewCallbacks {
|
|
30
|
-
onScale: (scaleInfo: {scale: number}) => void
|
|
31
|
-
onScaleEnd?: () => void
|
|
32
|
-
}
|
|
33
|
-
|
|
34
26
|
const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaProps>((props: MovableAreaProps, ref): JSX.Element => {
|
|
35
|
-
const {
|
|
36
|
-
style = {},
|
|
37
|
-
'scale-area': scaleArea = false,
|
|
38
|
-
'enable-var': enableVar,
|
|
39
|
-
'external-var-context': externalVarContext,
|
|
40
|
-
'parent-font-size': parentFontSize,
|
|
41
|
-
'parent-width': parentWidth,
|
|
42
|
-
'parent-height': parentHeight
|
|
43
|
-
} = props
|
|
27
|
+
const { style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props
|
|
44
28
|
|
|
45
29
|
const {
|
|
46
30
|
hasSelfPercent,
|
|
@@ -52,67 +36,17 @@ const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaP
|
|
|
52
36
|
setHeight
|
|
53
37
|
} = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
54
38
|
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
useNodesRef(props, ref, movableAreaRef, {
|
|
39
|
+
const movableViewRef = useRef(null)
|
|
40
|
+
useNodesRef(props, ref, movableViewRef, {
|
|
58
41
|
style: normalStyle
|
|
59
42
|
})
|
|
60
43
|
|
|
61
|
-
|
|
62
|
-
const registerMovableView = useCallback((id: string, callbacks: { onScale?: (scaleInfo: { scale: number }) => void; onScaleEnd?: () => void }) => {
|
|
63
|
-
movableViewsValue.value = extendObject(movableViewsValue.value, { [id]: callbacks })
|
|
64
|
-
}, [])
|
|
65
|
-
|
|
66
|
-
const unregisterMovableView = useCallback((id: string) => {
|
|
67
|
-
delete movableViewsValue.value[id]
|
|
68
|
-
}, [])
|
|
69
|
-
|
|
70
|
-
// 处理区域缩放手势
|
|
71
|
-
const handleAreaScale = useCallback((scaleInfo: { scale: number }) => {
|
|
72
|
-
'worklet'
|
|
73
|
-
if (scaleArea) {
|
|
74
|
-
// 将缩放信息广播给所有注册的 MovableView
|
|
75
|
-
Object.values(movableViewsValue.value).forEach((callbacks) => {
|
|
76
|
-
callbacks.onScale && callbacks.onScale(scaleInfo)
|
|
77
|
-
})
|
|
78
|
-
}
|
|
79
|
-
}, [scaleArea])
|
|
80
|
-
|
|
81
|
-
// 处理区域缩放结束
|
|
82
|
-
const handleAreaScaleEnd = useCallback(() => {
|
|
83
|
-
'worklet'
|
|
84
|
-
if (scaleArea) {
|
|
85
|
-
// 通知所有注册的 MovableView 缩放结束
|
|
86
|
-
Object.values(movableViewsValue.value).forEach((callbacks) => {
|
|
87
|
-
callbacks.onScaleEnd && callbacks.onScaleEnd()
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
}, [scaleArea])
|
|
91
|
-
|
|
92
|
-
const contextValue: MovableAreaContextValue = useMemo(() => ({
|
|
44
|
+
const contextValue = useMemo(() => ({
|
|
93
45
|
height: normalStyle.height || 10,
|
|
94
|
-
width: normalStyle.width || 10
|
|
95
|
-
|
|
96
|
-
registerMovableView,
|
|
97
|
-
unregisterMovableView
|
|
98
|
-
}), [normalStyle.width, normalStyle.height, scaleArea])
|
|
46
|
+
width: normalStyle.width || 10
|
|
47
|
+
}), [normalStyle.width, normalStyle.height])
|
|
99
48
|
|
|
100
|
-
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef:
|
|
101
|
-
|
|
102
|
-
// 创建缩放手势
|
|
103
|
-
const scaleGesture = useMemo(() => {
|
|
104
|
-
if (!scaleArea) return null
|
|
105
|
-
|
|
106
|
-
return Gesture.Pinch()
|
|
107
|
-
.onUpdate((e) => {
|
|
108
|
-
'worklet'
|
|
109
|
-
handleAreaScale(e)
|
|
110
|
-
})
|
|
111
|
-
.onEnd(() => {
|
|
112
|
-
'worklet'
|
|
113
|
-
handleAreaScaleEnd()
|
|
114
|
-
})
|
|
115
|
-
}, [scaleArea])
|
|
49
|
+
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: movableViewRef })
|
|
116
50
|
|
|
117
51
|
const innerProps = useInnerProps(
|
|
118
52
|
extendObject(
|
|
@@ -121,7 +55,7 @@ const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaP
|
|
|
121
55
|
layoutProps,
|
|
122
56
|
{
|
|
123
57
|
style: extendObject({ height: contextValue.height, width: contextValue.width }, normalStyle, layoutStyle),
|
|
124
|
-
ref:
|
|
58
|
+
ref: movableViewRef
|
|
125
59
|
}
|
|
126
60
|
),
|
|
127
61
|
[],
|
|
@@ -139,30 +73,9 @@ const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaP
|
|
|
139
73
|
}
|
|
140
74
|
)
|
|
141
75
|
))
|
|
142
|
-
|
|
143
|
-
// 如果启用了 scale-area,包装一个 GestureDetector
|
|
144
|
-
if (scaleArea && scaleGesture) {
|
|
145
|
-
movableComponent = createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(
|
|
146
|
-
GestureDetector,
|
|
147
|
-
{ gesture: scaleGesture },
|
|
148
|
-
createElement(
|
|
149
|
-
View,
|
|
150
|
-
innerProps,
|
|
151
|
-
wrapChildren(
|
|
152
|
-
props,
|
|
153
|
-
{
|
|
154
|
-
hasVarDec,
|
|
155
|
-
varContext: varContextRef.current
|
|
156
|
-
}
|
|
157
|
-
)
|
|
158
|
-
)
|
|
159
|
-
))
|
|
160
|
-
}
|
|
161
|
-
|
|
162
76
|
if (hasPositionFixed) {
|
|
163
77
|
movableComponent = createElement(Portal, null, movableComponent)
|
|
164
78
|
}
|
|
165
|
-
|
|
166
79
|
return movableComponent
|
|
167
80
|
})
|
|
168
81
|
|