@mpxjs/webpack-plugin 2.10.7-beta.7 → 2.10.7-beta.9
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/lib/dependencies/RecordPageConfigsMapDependency.js +1 -1
- package/lib/platform/style/wx/index.js +7 -0
- package/lib/platform/template/wx/component-config/movable-view.js +1 -10
- package/lib/runtime/components/react/context.ts +12 -2
- package/lib/runtime/components/react/dist/context.js +1 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +63 -9
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +306 -61
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +15 -10
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +3 -1
- package/lib/runtime/components/react/mpx-movable-area.tsx +98 -11
- package/lib/runtime/components/react/mpx-movable-view.tsx +356 -62
- package/lib/runtime/components/react/mpx-scroll-view.tsx +16 -9
- package/lib/runtime/components/react/mpx-sticky-header.tsx +3 -1
- package/lib/runtime/components/web/mpx-scroll-view.vue +4 -7
- package/lib/runtime/components/web/mpx-sticky-header.vue +39 -31
- package/lib/template-compiler/bind-this.js +2 -1
- package/lib/template-compiler/compiler.js +1 -1
- package/package.json +1 -1
|
@@ -285,6 +285,13 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
285
285
|
|
|
286
286
|
// line-height
|
|
287
287
|
const formatLineHeight = ({ prop, value, selector }) => {
|
|
288
|
+
// line-height 0 直接返回
|
|
289
|
+
if (+value === 0) {
|
|
290
|
+
return {
|
|
291
|
+
prop,
|
|
292
|
+
value
|
|
293
|
+
}
|
|
294
|
+
}
|
|
288
295
|
return verifyValues({ prop, value, selector }) && ({
|
|
289
296
|
prop,
|
|
290
297
|
value: /^\s*(-?(\d+(\.\d+)?|\.\d+))\s*$/.test(value) ? `${Math.round(value * 100)}%` : value
|
|
@@ -2,9 +2,6 @@ const TAG_NAME = 'movable-view'
|
|
|
2
2
|
|
|
3
3
|
module.exports = function ({ print }) {
|
|
4
4
|
const aliEventLog = print({ platform: 'ali', tag: TAG_NAME, isError: false, type: 'event' })
|
|
5
|
-
const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
|
|
6
|
-
const harmonyEventLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false, type: 'event' })
|
|
7
|
-
const iosEventLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
|
|
8
5
|
const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
|
|
9
6
|
const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
|
|
10
7
|
const harmonyPropLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false })
|
|
@@ -36,7 +33,7 @@ module.exports = function ({ print }) {
|
|
|
36
33
|
harmony: harmonyPropLog
|
|
37
34
|
},
|
|
38
35
|
{
|
|
39
|
-
test: /^(damping|friction
|
|
36
|
+
test: /^(damping|friction)$/,
|
|
40
37
|
ios: iosPropLog,
|
|
41
38
|
android: androidPropLog,
|
|
42
39
|
harmony: harmonyPropLog
|
|
@@ -46,12 +43,6 @@ module.exports = function ({ print }) {
|
|
|
46
43
|
{
|
|
47
44
|
test: /^(htouchmove|vtouchmove)$/,
|
|
48
45
|
ali: aliEventLog
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
test: /^(bindscale)$/,
|
|
52
|
-
ios: iosEventLog,
|
|
53
|
-
android: androidEventLog,
|
|
54
|
-
harmony: harmonyEventLog
|
|
55
46
|
}
|
|
56
47
|
]
|
|
57
48
|
}
|
|
@@ -51,14 +51,24 @@ export interface RouteContextValue {
|
|
|
51
51
|
pageId: number
|
|
52
52
|
navigation: Record<string, any>
|
|
53
53
|
}
|
|
54
|
+
export interface MovableAreaContextValue {
|
|
55
|
+
width: number
|
|
56
|
+
height: number
|
|
57
|
+
scaleArea: boolean
|
|
58
|
+
onAreaScale?: (scaleInfo: { scale: number }) => void
|
|
59
|
+
registerMovableView?: (id: string, callbacks: {
|
|
60
|
+
onScale: (scaleInfo: { scale: number }) => void
|
|
61
|
+
onScaleEnd?: () => void
|
|
62
|
+
}) => void
|
|
63
|
+
unregisterMovableView?: (id: string) => void
|
|
64
|
+
}
|
|
54
65
|
|
|
66
|
+
export const MovableAreaContext = createContext<MovableAreaContextValue>({ width: 0, height: 0, scaleArea: false })
|
|
55
67
|
export interface StickyContextValue {
|
|
56
68
|
registerStickyHeader: Function,
|
|
57
69
|
unregisterStickyHeader: Function
|
|
58
70
|
}
|
|
59
71
|
|
|
60
|
-
export const MovableAreaContext = createContext({ width: 0, height: 0 })
|
|
61
|
-
|
|
62
72
|
export const FormContext = createContext<FormContextValue | null>(null)
|
|
63
73
|
|
|
64
74
|
export const CheckboxGroupContext = createContext<GroupContextValue | null>(null)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
import { Animated } from 'react-native';
|
|
3
3
|
import { noop } from '@mpxjs/utils';
|
|
4
|
-
export const MovableAreaContext = createContext({ width: 0, height: 0 });
|
|
4
|
+
export const MovableAreaContext = createContext({ width: 0, height: 0, scaleArea: false });
|
|
5
5
|
export const FormContext = createContext(null);
|
|
6
6
|
export const CheckboxGroupContext = createContext(null);
|
|
7
7
|
export const RadioGroupContext = createContext(null);
|
|
@@ -1,33 +1,87 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* ✔ scale-area
|
|
3
3
|
*/
|
|
4
4
|
import { View } from 'react-native';
|
|
5
|
-
import { forwardRef, useRef, useMemo, createElement } from 'react';
|
|
5
|
+
import { forwardRef, useRef, useMemo, useCallback, createElement } from 'react';
|
|
6
|
+
import { GestureDetector, Gesture } from 'react-native-gesture-handler';
|
|
7
|
+
import { useSharedValue } from 'react-native-reanimated';
|
|
6
8
|
import useNodesRef from './useNodesRef';
|
|
7
9
|
import useInnerProps from './getInnerListeners';
|
|
8
10
|
import { MovableAreaContext } from './context';
|
|
9
11
|
import { useTransformStyle, wrapChildren, useLayout, extendObject } from './utils';
|
|
10
12
|
import Portal from './mpx-portal';
|
|
11
13
|
const _MovableArea = forwardRef((props, ref) => {
|
|
12
|
-
const { style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
14
|
+
const { style = {}, 'scale-area': scaleArea = false, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
13
15
|
const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, hasPositionFixed, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
+
const movableAreaRef = useRef(null);
|
|
17
|
+
const movableViewsValue = useSharedValue({});
|
|
18
|
+
useNodesRef(props, ref, movableAreaRef, {
|
|
16
19
|
style: normalStyle
|
|
17
20
|
});
|
|
21
|
+
// 注册/注销 MovableView 的回调
|
|
22
|
+
const registerMovableView = useCallback((id, callbacks) => {
|
|
23
|
+
movableViewsValue.value = extendObject(movableViewsValue.value, { [id]: callbacks });
|
|
24
|
+
}, []);
|
|
25
|
+
const unregisterMovableView = useCallback((id) => {
|
|
26
|
+
delete movableViewsValue.value[id];
|
|
27
|
+
}, []);
|
|
28
|
+
// 处理区域缩放手势
|
|
29
|
+
const handleAreaScale = useCallback((scaleInfo) => {
|
|
30
|
+
'worklet';
|
|
31
|
+
if (scaleArea) {
|
|
32
|
+
// 将缩放信息广播给所有注册的 MovableView
|
|
33
|
+
Object.values(movableViewsValue.value).forEach((callbacks) => {
|
|
34
|
+
callbacks.onScale && callbacks.onScale(scaleInfo);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}, [scaleArea]);
|
|
38
|
+
// 处理区域缩放结束
|
|
39
|
+
const handleAreaScaleEnd = useCallback(() => {
|
|
40
|
+
'worklet';
|
|
41
|
+
if (scaleArea) {
|
|
42
|
+
// 通知所有注册的 MovableView 缩放结束
|
|
43
|
+
Object.values(movableViewsValue.value).forEach((callbacks) => {
|
|
44
|
+
callbacks.onScaleEnd && callbacks.onScaleEnd();
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}, [scaleArea]);
|
|
18
48
|
const contextValue = useMemo(() => ({
|
|
19
49
|
height: normalStyle.height || 10,
|
|
20
|
-
width: normalStyle.width || 10
|
|
21
|
-
|
|
22
|
-
|
|
50
|
+
width: normalStyle.width || 10,
|
|
51
|
+
scaleArea,
|
|
52
|
+
registerMovableView,
|
|
53
|
+
unregisterMovableView
|
|
54
|
+
}), [normalStyle.width, normalStyle.height, scaleArea]);
|
|
55
|
+
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: movableAreaRef });
|
|
56
|
+
// 创建缩放手势
|
|
57
|
+
const scaleGesture = useMemo(() => {
|
|
58
|
+
if (!scaleArea)
|
|
59
|
+
return null;
|
|
60
|
+
return Gesture.Pinch()
|
|
61
|
+
.onUpdate((e) => {
|
|
62
|
+
'worklet';
|
|
63
|
+
handleAreaScale(e);
|
|
64
|
+
})
|
|
65
|
+
.onEnd(() => {
|
|
66
|
+
'worklet';
|
|
67
|
+
handleAreaScaleEnd();
|
|
68
|
+
});
|
|
69
|
+
}, [scaleArea]);
|
|
23
70
|
const innerProps = useInnerProps(extendObject({}, props, layoutProps, {
|
|
24
71
|
style: extendObject({ height: contextValue.height, width: contextValue.width }, normalStyle, layoutStyle),
|
|
25
|
-
ref:
|
|
72
|
+
ref: movableAreaRef
|
|
26
73
|
}), [], { layoutRef });
|
|
27
74
|
let movableComponent = createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(View, innerProps, wrapChildren(props, {
|
|
28
75
|
hasVarDec,
|
|
29
76
|
varContext: varContextRef.current
|
|
30
77
|
})));
|
|
78
|
+
// 如果启用了 scale-area,包装一个 GestureDetector
|
|
79
|
+
if (scaleArea && scaleGesture) {
|
|
80
|
+
movableComponent = createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(GestureDetector, { gesture: scaleGesture }, createElement(View, innerProps, wrapChildren(props, {
|
|
81
|
+
hasVarDec,
|
|
82
|
+
varContext: varContextRef.current
|
|
83
|
+
}))));
|
|
84
|
+
}
|
|
31
85
|
if (hasPositionFixed) {
|
|
32
86
|
movableComponent = createElement(Portal, null, movableComponent);
|
|
33
87
|
}
|