@mpxjs/webpack-plugin 2.9.69 → 2.9.70
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/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/fix-component-name.js +15 -12
- package/lib/platform/template/wx/component-config/index.js +1 -1
- package/lib/platform/template/wx/component-config/input.js +1 -1
- package/lib/platform/template/wx/component-config/rich-text.js +8 -0
- package/lib/platform/template/wx/component-config/swiper.js +1 -1
- package/lib/platform/template/wx/component-config/textarea.js +1 -1
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/react/processTemplate.js +3 -0
- package/lib/runtime/components/react/context.ts +4 -0
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/event.config.js +24 -24
- package/lib/runtime/components/react/dist/getInnerListeners.js +183 -166
- package/lib/runtime/components/react/dist/mpx-button.jsx +35 -42
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +2 -4
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +35 -13
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
- package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
- package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
- package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
- package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +3 -1
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
- package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
- package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +4 -2
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
- package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
- package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
- package/lib/runtime/components/react/dist/mpx-view.jsx +34 -46
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +105 -42
- package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -10
- package/lib/runtime/components/react/dist/utils.jsx +107 -82
- package/lib/runtime/components/react/event.config.ts +25 -26
- package/lib/runtime/components/react/getInnerListeners.ts +238 -188
- package/lib/runtime/components/react/mpx-button.tsx +64 -50
- package/lib/runtime/components/react/mpx-canvas/html.ts +2 -4
- package/lib/runtime/components/react/mpx-canvas/index.tsx +46 -48
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +28 -25
- package/lib/runtime/components/react/mpx-checkbox.tsx +48 -49
- package/lib/runtime/components/react/mpx-form.tsx +25 -28
- package/lib/runtime/components/react/mpx-icon.tsx +12 -17
- package/lib/runtime/components/react/mpx-image.tsx +436 -0
- package/lib/runtime/components/react/mpx-input.tsx +77 -57
- package/lib/runtime/components/react/mpx-label.tsx +26 -27
- package/lib/runtime/components/react/mpx-movable-area.tsx +18 -23
- package/lib/runtime/components/react/mpx-movable-view.tsx +21 -25
- package/lib/runtime/components/react/mpx-navigator.tsx +2 -8
- package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
- package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +4 -1
- package/lib/runtime/components/react/mpx-picker-view.tsx +7 -1
- package/lib/runtime/components/react/mpx-radio-group.tsx +24 -27
- package/lib/runtime/components/react/mpx-radio.tsx +45 -54
- package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +121 -0
- package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
- package/lib/runtime/components/react/mpx-scroll-view.tsx +72 -71
- package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
- package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
- package/lib/runtime/components/react/mpx-switch.tsx +29 -23
- package/lib/runtime/components/react/mpx-text.tsx +14 -18
- package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
- package/lib/runtime/components/react/mpx-view.tsx +55 -65
- package/lib/runtime/components/react/mpx-web-view.tsx +108 -63
- package/lib/runtime/components/react/types/global.d.ts +3 -17
- package/lib/runtime/components/react/useAnimationHooks.ts +36 -12
- package/lib/runtime/components/react/utils.tsx +113 -82
- package/lib/runtime/components/web/getInnerListeners.js +6 -6
- package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
- package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
- package/lib/runtime/components/web/mpx-picker.vue +382 -385
- package/lib/runtime/components/web/mpx-web-view.vue +175 -161
- package/lib/runtime/optionProcessor.js +7 -38
- package/lib/runtime/utils.js +2 -0
- package/lib/style-compiler/plugins/scope-id.js +30 -2
- package/lib/template-compiler/bind-this.js +7 -2
- package/lib/template-compiler/compiler.js +77 -46
- package/lib/template-compiler/gen-node-react.js +2 -2
- package/lib/utils/pre-process-json.js +9 -5
- package/package.json +5 -4
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
- package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
- package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
- package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
- package/lib/runtime/components/web/event.js +0 -105
|
@@ -57,7 +57,7 @@ const _Carouse = forwardRef<HandlerRef<ScrollView & View, CarouseProps>, Carouse
|
|
|
57
57
|
parentWidth,
|
|
58
58
|
parentHeight
|
|
59
59
|
} = props
|
|
60
|
-
// 计算
|
|
60
|
+
// 计算transform之类的
|
|
61
61
|
const {
|
|
62
62
|
normalStyle,
|
|
63
63
|
hasVarDec,
|
|
@@ -92,7 +92,9 @@ const _Carouse = forwardRef<HandlerRef<ScrollView & View, CarouseProps>, Carouse
|
|
|
92
92
|
// 内部存储上一次的offset值
|
|
93
93
|
const autoplayTimerRef = useRef<ReturnType <typeof setTimeout> | null>(null)
|
|
94
94
|
const scrollViewRef = useRef<ScrollView & View>(null)
|
|
95
|
-
useNodesRef<ScrollView & View, CarouseProps>(props, ref, scrollViewRef, {
|
|
95
|
+
useNodesRef<ScrollView & View, CarouseProps>(props, ref, scrollViewRef, {
|
|
96
|
+
style: normalStyle
|
|
97
|
+
})
|
|
96
98
|
const {
|
|
97
99
|
// 存储layout布局信息
|
|
98
100
|
layoutRef,
|
|
@@ -18,7 +18,6 @@ interface SwiperItemProps {
|
|
|
18
18
|
|
|
19
19
|
const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProps>((props: SwiperItemProps, ref) => {
|
|
20
20
|
const {
|
|
21
|
-
'enable-offset': enableOffset,
|
|
22
21
|
'enable-var': enableVar,
|
|
23
22
|
'external-var-context': externalVarContext,
|
|
24
23
|
style
|
|
@@ -26,7 +25,6 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp
|
|
|
26
25
|
|
|
27
26
|
const { textProps } = splitProps(props)
|
|
28
27
|
const nodeRef = useRef(null)
|
|
29
|
-
useNodesRef(props, ref, nodeRef, {})
|
|
30
28
|
|
|
31
29
|
const {
|
|
32
30
|
normalStyle,
|
|
@@ -37,6 +35,9 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp
|
|
|
37
35
|
setHeight
|
|
38
36
|
} = useTransformStyle(style, { enableVar, externalVarContext })
|
|
39
37
|
const { textStyle, innerStyle } = splitStyle(normalStyle)
|
|
38
|
+
useNodesRef(props, ref, nodeRef, {
|
|
39
|
+
style: normalStyle
|
|
40
|
+
})
|
|
40
41
|
|
|
41
42
|
const {
|
|
42
43
|
// 存储layout布局信息
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* ✔ color
|
|
6
6
|
*/
|
|
7
7
|
import { Switch, SwitchProps, ViewStyle, NativeSyntheticEvent } from 'react-native'
|
|
8
|
-
import { useRef, useEffect, forwardRef, JSX, useState, useContext } from 'react'
|
|
8
|
+
import { useRef, useEffect, forwardRef, JSX, useState, useContext, createElement } from 'react'
|
|
9
9
|
import { warn } from '@mpxjs/utils'
|
|
10
10
|
import useNodesRef, { HandlerRef } from './useNodesRef' // 引入辅助函数
|
|
11
11
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
12
12
|
|
|
13
13
|
import CheckBox from './mpx-checkbox'
|
|
14
14
|
import { FormContext, FormFieldValue } from './context'
|
|
15
|
-
import { useTransformStyle, useLayout } from './utils'
|
|
15
|
+
import { useTransformStyle, useLayout, extendObject } from './utils'
|
|
16
16
|
|
|
17
17
|
interface _SwitchProps extends SwitchProps {
|
|
18
18
|
style?: ViewStyle
|
|
@@ -42,7 +42,6 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
|
|
|
42
42
|
'parent-font-size': parentFontSize,
|
|
43
43
|
'parent-width': parentWidth,
|
|
44
44
|
'parent-height': parentHeight,
|
|
45
|
-
|
|
46
45
|
bindchange,
|
|
47
46
|
catchchange
|
|
48
47
|
} = props
|
|
@@ -77,7 +76,9 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
|
|
|
77
76
|
}, [checked])
|
|
78
77
|
|
|
79
78
|
const nodeRef = useRef(null)
|
|
80
|
-
useNodesRef<Switch, _SwitchProps>(props, ref, nodeRef
|
|
79
|
+
useNodesRef<Switch, _SwitchProps>(props, ref, nodeRef, {
|
|
80
|
+
style: normalStyle
|
|
81
|
+
})
|
|
81
82
|
|
|
82
83
|
const {
|
|
83
84
|
layoutRef,
|
|
@@ -119,12 +120,13 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
|
|
|
119
120
|
}
|
|
120
121
|
}, [])
|
|
121
122
|
|
|
122
|
-
const innerProps = useInnerProps(props, {
|
|
123
|
+
const innerProps = useInnerProps(props, extendObject({
|
|
123
124
|
ref: nodeRef,
|
|
124
|
-
style: {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
125
|
+
style: extendObject({}, normalStyle, layoutStyle)
|
|
126
|
+
},
|
|
127
|
+
layoutProps,
|
|
128
|
+
!disabled ? { [type === 'switch' ? 'onValueChange' : '_onChange']: onChange } : {})
|
|
129
|
+
, [
|
|
128
130
|
'checked',
|
|
129
131
|
'disabled',
|
|
130
132
|
'type',
|
|
@@ -134,22 +136,26 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
|
|
|
134
136
|
})
|
|
135
137
|
|
|
136
138
|
if (type === 'checkbox') {
|
|
137
|
-
return
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
return createElement(
|
|
140
|
+
CheckBox,
|
|
141
|
+
extendObject({}, innerProps, {
|
|
142
|
+
color: color,
|
|
143
|
+
style: normalStyle,
|
|
144
|
+
checked: isChecked
|
|
145
|
+
})
|
|
146
|
+
)
|
|
143
147
|
}
|
|
144
148
|
|
|
145
|
-
return
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
return createElement(
|
|
150
|
+
Switch,
|
|
151
|
+
extendObject({}, innerProps, {
|
|
152
|
+
style: normalStyle,
|
|
153
|
+
value: isChecked,
|
|
154
|
+
trackColor: { false: '#FFF', true: color },
|
|
155
|
+
thumbColor: isChecked ? '#FFF' : '#f4f3f4',
|
|
156
|
+
ios_backgroundColor: '#FFF'
|
|
157
|
+
})
|
|
158
|
+
)
|
|
153
159
|
})
|
|
154
160
|
|
|
155
161
|
_Switch.displayName = 'MpxSwitch'
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ✘ decode
|
|
6
6
|
*/
|
|
7
7
|
import { Text, TextStyle, TextProps } from 'react-native'
|
|
8
|
-
import { useRef, forwardRef, ReactNode, JSX } from 'react'
|
|
8
|
+
import { useRef, forwardRef, ReactNode, JSX, createElement } from 'react'
|
|
9
9
|
import useInnerProps from './getInnerListeners'
|
|
10
10
|
import useNodesRef, { HandlerRef } from './useNodesRef' // 引入辅助函数
|
|
11
11
|
import { useTransformStyle, wrapChildren } from './utils'
|
|
@@ -25,6 +25,7 @@ interface _TextProps extends TextProps {
|
|
|
25
25
|
const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref): JSX.Element => {
|
|
26
26
|
const {
|
|
27
27
|
style = {},
|
|
28
|
+
allowFontScaling = false,
|
|
28
29
|
selectable,
|
|
29
30
|
'enable-var': enableVar,
|
|
30
31
|
'external-var-context': externalVarContext,
|
|
@@ -49,33 +50,28 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
|
|
|
49
50
|
})
|
|
50
51
|
|
|
51
52
|
const nodeRef = useRef(null)
|
|
52
|
-
useNodesRef<Text, _TextProps>(props, ref, nodeRef
|
|
53
|
+
useNodesRef<Text, _TextProps>(props, ref, nodeRef, {
|
|
54
|
+
style: normalStyle
|
|
55
|
+
})
|
|
53
56
|
|
|
54
57
|
const innerProps = useInnerProps(props, {
|
|
55
58
|
ref: nodeRef,
|
|
56
59
|
style: normalStyle,
|
|
57
|
-
selectable: !!selectable || !!userSelect
|
|
60
|
+
selectable: !!selectable || !!userSelect,
|
|
61
|
+
allowFontScaling
|
|
58
62
|
}, [
|
|
59
63
|
'user-select'
|
|
60
64
|
], {
|
|
61
65
|
layoutRef
|
|
62
66
|
})
|
|
63
67
|
|
|
64
|
-
return (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
{
|
|
72
|
-
hasVarDec,
|
|
73
|
-
varContext: varContextRef.current
|
|
74
|
-
}
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
</Text>
|
|
78
|
-
)
|
|
68
|
+
return createElement(Text, innerProps, wrapChildren(
|
|
69
|
+
props,
|
|
70
|
+
{
|
|
71
|
+
hasVarDec,
|
|
72
|
+
varContext: varContextRef.current
|
|
73
|
+
}
|
|
74
|
+
))
|
|
79
75
|
})
|
|
80
76
|
|
|
81
77
|
_Text.displayName = 'MpxText'
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
* ✘ show-confirm-bar
|
|
10
10
|
* ✔ bindlinechange: No `heightRpx` info.
|
|
11
11
|
*/
|
|
12
|
-
import { JSX, forwardRef } from 'react'
|
|
12
|
+
import { JSX, forwardRef, createElement } from 'react'
|
|
13
13
|
import { Keyboard, TextInput } from 'react-native'
|
|
14
14
|
import Input, { InputProps, PrivateInputProps } from './mpx-input'
|
|
15
|
-
import { omit } from './utils'
|
|
15
|
+
import { omit, extendObject } from './utils'
|
|
16
16
|
import { HandlerRef } from './useNodesRef'
|
|
17
17
|
|
|
18
18
|
export type TextareProps = Omit<
|
|
@@ -29,14 +29,15 @@ const Textarea = forwardRef<HandlerRef<TextInput, TextareProps>, TextareProps>(
|
|
|
29
29
|
'multiline',
|
|
30
30
|
'confirm-hold'
|
|
31
31
|
])
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
|
|
33
|
+
return createElement(
|
|
34
|
+
Input,
|
|
35
|
+
extendObject({
|
|
36
|
+
ref: ref,
|
|
37
|
+
multiline: true,
|
|
38
|
+
confirmType: 'next',
|
|
39
|
+
bindblur: () => Keyboard.dismiss()
|
|
40
|
+
}, restProps)
|
|
40
41
|
)
|
|
41
42
|
}
|
|
42
43
|
)
|
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
* ✔ hover-stay-time
|
|
6
6
|
*/
|
|
7
7
|
import { View, TextStyle, NativeSyntheticEvent, ViewProps, ImageStyle, StyleSheet, Image, LayoutChangeEvent } from 'react-native'
|
|
8
|
-
import { useRef, useState, useEffect, forwardRef, ReactNode, JSX } from 'react'
|
|
8
|
+
import { useRef, useState, useEffect, forwardRef, ReactNode, JSX, createElement } from 'react'
|
|
9
9
|
import useInnerProps from './getInnerListeners'
|
|
10
10
|
import Animated from 'react-native-reanimated'
|
|
11
11
|
import useAnimationHooks from './useAnimationHooks'
|
|
12
12
|
import type { AnimationProp } from './useAnimationHooks'
|
|
13
13
|
import { ExtendedViewStyle } from './types/common'
|
|
14
14
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
15
|
-
import { parseUrl, PERCENT_REGEX, splitStyle, splitProps, useTransformStyle, wrapChildren, useLayout, renderImage, pickStyle } from './utils'
|
|
15
|
+
import { parseUrl, PERCENT_REGEX, splitStyle, splitProps, useTransformStyle, wrapChildren, useLayout, renderImage, pickStyle, extendObject } from './utils'
|
|
16
|
+
import { error } from '@mpxjs/utils'
|
|
16
17
|
import LinearGradient from 'react-native-linear-gradient'
|
|
17
18
|
|
|
18
19
|
export interface _ViewProps extends ViewProps {
|
|
@@ -236,10 +237,7 @@ function backgroundPosition (imageProps: ImageProps, preImageInfo: PreImageInfo,
|
|
|
236
237
|
}
|
|
237
238
|
}
|
|
238
239
|
|
|
239
|
-
imageProps.style
|
|
240
|
-
...imageProps.style as ImageStyle,
|
|
241
|
-
...style
|
|
242
|
-
}
|
|
240
|
+
extendObject(imageProps.style, style)
|
|
243
241
|
}
|
|
244
242
|
|
|
245
243
|
// background-size 转换
|
|
@@ -292,10 +290,7 @@ function backgroundSize (imageProps: ImageProps, preImageInfo: PreImageInfo, ima
|
|
|
292
290
|
}
|
|
293
291
|
|
|
294
292
|
// 样式合并
|
|
295
|
-
imageProps.style
|
|
296
|
-
...imageProps.style as ImageStyle,
|
|
297
|
-
...dimensions
|
|
298
|
-
}
|
|
293
|
+
extendObject(imageProps.style, dimensions)
|
|
299
294
|
}
|
|
300
295
|
|
|
301
296
|
// background-image转换为source
|
|
@@ -481,10 +476,9 @@ function parseLinearGradient (text: string): LinearInfo | undefined {
|
|
|
481
476
|
return prev
|
|
482
477
|
}, { colors: [], locations: [] })
|
|
483
478
|
|
|
484
|
-
return {
|
|
485
|
-
...linearInfo,
|
|
479
|
+
return extendObject({}, linearInfo, {
|
|
486
480
|
direction: direction.trim()
|
|
487
|
-
}
|
|
481
|
+
})
|
|
488
482
|
}
|
|
489
483
|
|
|
490
484
|
function parseBgImage (text: string): {
|
|
@@ -557,7 +551,7 @@ function inheritStyle (innerStyle: ExtendedViewStyle = {}) {
|
|
|
557
551
|
: undefined)
|
|
558
552
|
}
|
|
559
553
|
|
|
560
|
-
function
|
|
554
|
+
function useWrapImage (imageStyle?: ExtendedViewStyle, innerStyle?: Record<string, any>, enableFastImage?: boolean) {
|
|
561
555
|
// 预处理数据
|
|
562
556
|
const preImageInfo: PreImageInfo = preParseImage(imageStyle)
|
|
563
557
|
// 预解析
|
|
@@ -666,7 +660,8 @@ function wrapWithChildren (props: _ViewProps, { hasVarDec, enableBackground, tex
|
|
|
666
660
|
})
|
|
667
661
|
|
|
668
662
|
return [
|
|
669
|
-
|
|
663
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
664
|
+
enableBackground ? useWrapImage(backgroundStyle, innerStyle, enableFastImage) : null,
|
|
670
665
|
children
|
|
671
666
|
]
|
|
672
667
|
}
|
|
@@ -692,21 +687,16 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
|
|
|
692
687
|
const [isHover, setIsHover] = useState(false)
|
|
693
688
|
|
|
694
689
|
// 默认样式
|
|
695
|
-
const defaultStyle: ExtendedViewStyle =
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
}
|
|
703
|
-
}
|
|
690
|
+
const defaultStyle: ExtendedViewStyle = style.display === 'flex'
|
|
691
|
+
? {
|
|
692
|
+
flexDirection: 'row',
|
|
693
|
+
flexBasis: 'auto',
|
|
694
|
+
flexShrink: 1,
|
|
695
|
+
flexWrap: 'nowrap'
|
|
696
|
+
}
|
|
697
|
+
: {}
|
|
704
698
|
|
|
705
|
-
const styleObj: ExtendedViewStyle = {
|
|
706
|
-
...defaultStyle,
|
|
707
|
-
...style,
|
|
708
|
-
...(isHover ? hoverStyle : null)
|
|
709
|
-
}
|
|
699
|
+
const styleObj: ExtendedViewStyle = extendObject({}, defaultStyle, style, isHover ? hoverStyle as ExtendedViewStyle : {})
|
|
710
700
|
|
|
711
701
|
const {
|
|
712
702
|
normalStyle,
|
|
@@ -723,17 +713,17 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
|
|
|
723
713
|
parentHeight
|
|
724
714
|
})
|
|
725
715
|
|
|
726
|
-
const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle)
|
|
716
|
+
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
727
717
|
|
|
728
718
|
enableBackground = enableBackground || !!backgroundStyle
|
|
729
719
|
const enableBackgroundRef = useRef(enableBackground)
|
|
730
720
|
if (enableBackgroundRef.current !== enableBackground) {
|
|
731
|
-
|
|
721
|
+
error('[Mpx runtime error]: background use should be stable in the component lifecycle, or you can set [enable-background] with true.')
|
|
732
722
|
}
|
|
733
723
|
|
|
734
724
|
const nodeRef = useRef(null)
|
|
735
725
|
useNodesRef<View, _ViewProps>(props, ref, nodeRef, {
|
|
736
|
-
|
|
726
|
+
style: normalStyle
|
|
737
727
|
})
|
|
738
728
|
|
|
739
729
|
const dataRef = useRef<{
|
|
@@ -781,36 +771,43 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
|
|
|
781
771
|
layoutProps
|
|
782
772
|
} = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
783
773
|
|
|
784
|
-
const viewStyle =
|
|
774
|
+
const viewStyle = extendObject({}, innerStyle, layoutStyle)
|
|
785
775
|
|
|
786
776
|
enableAnimation = enableAnimation || !!animation
|
|
787
777
|
const enableAnimationRef = useRef(enableAnimation)
|
|
788
778
|
if (enableAnimationRef.current !== enableAnimation) {
|
|
789
|
-
|
|
779
|
+
error('[Mpx runtime error]: animation use should be stable in the component lifecycle, or you can set [enable-animation] with true.')
|
|
790
780
|
}
|
|
791
|
-
const finalStyle = enableAnimation
|
|
792
|
-
? useAnimationHooks({
|
|
793
|
-
animation,
|
|
794
|
-
style: viewStyle
|
|
795
|
-
})
|
|
796
|
-
: viewStyle
|
|
797
781
|
|
|
798
|
-
const
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
782
|
+
const finalStyle = enableAnimationRef.current
|
|
783
|
+
? [viewStyle,
|
|
784
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
785
|
+
useAnimationHooks({
|
|
786
|
+
animation,
|
|
787
|
+
style: viewStyle
|
|
788
|
+
})]
|
|
789
|
+
: viewStyle
|
|
790
|
+
const innerProps = useInnerProps(
|
|
791
|
+
props,
|
|
792
|
+
extendObject({
|
|
793
|
+
ref: nodeRef,
|
|
794
|
+
style: finalStyle
|
|
795
|
+
},
|
|
796
|
+
layoutProps,
|
|
797
|
+
hoverStyle
|
|
798
|
+
? {
|
|
799
|
+
bindtouchstart: onTouchStart,
|
|
800
|
+
bindtouchend: onTouchEnd
|
|
801
|
+
}
|
|
802
|
+
: {}
|
|
803
|
+
), [
|
|
804
|
+
'hover-start-time',
|
|
805
|
+
'hover-stay-time',
|
|
806
|
+
'hover-style',
|
|
807
|
+
'hover-class'
|
|
808
|
+
], {
|
|
809
|
+
layoutRef
|
|
805
810
|
})
|
|
806
|
-
}, [
|
|
807
|
-
'hover-start-time',
|
|
808
|
-
'hover-stay-time',
|
|
809
|
-
'hover-style',
|
|
810
|
-
'hover-class'
|
|
811
|
-
], {
|
|
812
|
-
layoutRef
|
|
813
|
-
})
|
|
814
811
|
|
|
815
812
|
const childNode = wrapWithChildren(props, {
|
|
816
813
|
hasVarDec,
|
|
@@ -822,17 +819,10 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
|
|
|
822
819
|
innerStyle,
|
|
823
820
|
enableFastImage
|
|
824
821
|
})
|
|
822
|
+
|
|
825
823
|
return enableAnimation
|
|
826
|
-
? (
|
|
827
|
-
|
|
828
|
-
>
|
|
829
|
-
{childNode}
|
|
830
|
-
</Animated.View>)
|
|
831
|
-
: (<View
|
|
832
|
-
{...innerProps}
|
|
833
|
-
>
|
|
834
|
-
{childNode}
|
|
835
|
-
</View>)
|
|
824
|
+
? createElement(Animated.View, innerProps, childNode)
|
|
825
|
+
: createElement(View, innerProps, childNode)
|
|
836
826
|
})
|
|
837
827
|
|
|
838
828
|
_View.displayName = 'MpxView'
|