@mpxjs/webpack-plugin 2.9.69 → 2.9.70-alpha.1
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/README.md +1 -1
- package/lib/config.js +14 -0
- package/lib/dependencies/AddEntryDependency.js +24 -0
- package/lib/dependencies/ResolveDependency.js +5 -0
- package/lib/index.js +38 -7
- package/lib/json-compiler/helper.js +3 -3
- package/lib/loader.js +52 -0
- package/lib/platform/template/wx/component-config/button.js +14 -2
- package/lib/platform/template/wx/component-config/image.js +4 -0
- package/lib/platform/template/wx/component-config/input.js +5 -1
- package/lib/platform/template/wx/component-config/rich-text.js +4 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
- package/lib/platform/template/wx/component-config/swiper.js +1 -1
- package/lib/platform/template/wx/component-config/switch.js +4 -0
- package/lib/platform/template/wx/component-config/text.js +4 -0
- package/lib/platform/template/wx/component-config/textarea.js +6 -1
- package/lib/platform/template/wx/component-config/view.js +4 -0
- package/lib/platform/template/wx/index.js +127 -1
- package/lib/react/processTemplate.js +3 -0
- package/lib/resolve-loader.js +4 -1
- package/lib/runtime/components/react/context.ts +4 -0
- package/lib/runtime/components/react/dist/context.js +5 -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/locale-provider.jsx +15 -0
- package/lib/runtime/components/react/dist/mpx-button.jsx +39 -74
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +30 -12
- 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 +295 -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 +14 -14
- 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 -14
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +126 -112
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +32 -29
- package/lib/runtime/components/react/dist/mpx-portal/portal-consumer.jsx +23 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.jsx +124 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +40 -0
- package/lib/runtime/components/react/dist/mpx-portal.jsx +12 -0
- package/lib/runtime/components/react/dist/mpx-provider.jsx +31 -0
- 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 +62 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +7 -5
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +62 -47
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +28 -9
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +613 -0
- 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 +37 -89
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +205 -46
- package/lib/runtime/components/react/dist/pickerFaces.js +12 -6
- package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
- package/lib/runtime/components/react/dist/{pickerOverlay.jsx → pickerViewOverlay.jsx} +5 -3
- package/lib/runtime/components/react/dist/useAnimationHooks.js +50 -12
- package/lib/runtime/components/react/dist/utils.jsx +83 -28
- package/lib/runtime/components/react/getInnerListeners.ts +35 -28
- package/lib/runtime/components/react/mpx-button.tsx +55 -36
- package/lib/runtime/components/react/mpx-canvas/index.tsx +2 -2
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +13 -12
- package/lib/runtime/components/react/mpx-checkbox.tsx +28 -28
- package/lib/runtime/components/react/mpx-form.tsx +10 -8
- package/lib/runtime/components/react/mpx-icon.tsx +10 -15
- package/lib/runtime/components/react/mpx-image.tsx +396 -0
- package/lib/runtime/components/react/mpx-input.tsx +61 -33
- package/lib/runtime/components/react/mpx-label.tsx +14 -13
- package/lib/runtime/components/react/mpx-movable-area.tsx +8 -7
- package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
- 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 +11 -12
- package/lib/runtime/components/react/mpx-radio.tsx +26 -29
- package/lib/runtime/components/react/mpx-scroll-view.tsx +32 -30
- 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 +10 -8
- package/lib/runtime/components/react/mpx-text.tsx +6 -2
- package/lib/runtime/components/react/mpx-view.tsx +37 -45
- package/lib/runtime/components/react/mpx-web-view.tsx +25 -15
- package/lib/runtime/components/react/types/global.d.ts +1 -16
- package/lib/runtime/components/react/utils.tsx +24 -24
- package/lib/runtime/components/tenon/getInnerListeners.js +334 -0
- package/lib/runtime/components/tenon/tenon-button.vue +309 -0
- package/lib/runtime/components/tenon/tenon-image.vue +66 -0
- package/lib/runtime/components/tenon/tenon-input.vue +171 -0
- package/lib/runtime/components/tenon/tenon-rich-text.vue +26 -0
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +127 -0
- package/lib/runtime/components/tenon/tenon-switch.vue +96 -0
- package/lib/runtime/components/tenon/tenon-text.vue +70 -0
- package/lib/runtime/components/tenon/tenon-textarea.vue +86 -0
- package/lib/runtime/components/tenon/tenon-view.vue +93 -0
- 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 +162 -162
- package/lib/runtime/optionProcessor.js +7 -16
- package/lib/runtime/optionProcessor.tenon.js +84 -0
- package/lib/runtime/utils.js +2 -0
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/hm.js +20 -0
- package/lib/template-compiler/bind-this.js +7 -2
- package/lib/template-compiler/compiler.js +67 -40
- package/lib/template-compiler/gen-node-react.js +2 -2
- package/lib/tenon/index.js +112 -0
- package/lib/tenon/processJSON.js +352 -0
- package/lib/tenon/processScript.js +198 -0
- package/lib/tenon/processStyles.js +21 -0
- package/lib/tenon/processTemplate.js +125 -0
- package/lib/tenon/script-helper.js +223 -0
- package/lib/utils/env.js +6 -1
- package/lib/utils/get-relative-path.js +25 -0
- package/package.json +7 -3
- package/LICENSE +0 -433
- 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/dist/mpx-swiper/carouse.jsx +0 -478
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
- package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
- package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
- package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
|
@@ -20,7 +20,7 @@ import { warn } from '@mpxjs/utils'
|
|
|
20
20
|
import { FormContext, FormFieldValue, RadioGroupContext, GroupValue } from './context'
|
|
21
21
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
22
22
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
23
|
-
import { useLayout, useTransformStyle, wrapChildren } from './utils'
|
|
23
|
+
import { useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
|
|
24
24
|
|
|
25
25
|
export interface RadioGroupProps {
|
|
26
26
|
name: string
|
|
@@ -67,10 +67,7 @@ const radioGroup = forwardRef<
|
|
|
67
67
|
flexWrap: 'wrap'
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
const styleObj = {
|
|
71
|
-
...defaultStyle,
|
|
72
|
-
...style
|
|
73
|
-
}
|
|
70
|
+
const styleObj = extendObject({}, defaultStyle, style)
|
|
74
71
|
|
|
75
72
|
const {
|
|
76
73
|
hasSelfPercent,
|
|
@@ -82,7 +79,7 @@ const radioGroup = forwardRef<
|
|
|
82
79
|
} = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
83
80
|
|
|
84
81
|
const nodeRef = useRef(null)
|
|
85
|
-
useNodesRef(props, ref, nodeRef, {
|
|
82
|
+
useNodesRef(props, ref, nodeRef, { style: normalStyle })
|
|
86
83
|
|
|
87
84
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
88
85
|
|
|
@@ -144,12 +141,14 @@ const radioGroup = forwardRef<
|
|
|
144
141
|
|
|
145
142
|
const innerProps = useInnerProps(
|
|
146
143
|
props,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
144
|
+
extendObject(
|
|
145
|
+
{
|
|
146
|
+
ref: nodeRef,
|
|
147
|
+
style: extendObject({}, normalStyle, layoutStyle)
|
|
148
|
+
},
|
|
149
|
+
layoutProps
|
|
150
|
+
),
|
|
151
|
+
['name'],
|
|
153
152
|
{
|
|
154
153
|
layoutRef
|
|
155
154
|
}
|
|
@@ -10,7 +10,7 @@ import { warn } from '@mpxjs/utils'
|
|
|
10
10
|
import { LabelContext, RadioGroupContext } from './context'
|
|
11
11
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
12
12
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
13
|
-
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren } from './utils'
|
|
13
|
+
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
|
|
14
14
|
import Icon from './mpx-icon'
|
|
15
15
|
|
|
16
16
|
export interface RadioProps {
|
|
@@ -27,7 +27,6 @@ export interface RadioProps {
|
|
|
27
27
|
'parent-height'?: number;
|
|
28
28
|
children: ReactNode
|
|
29
29
|
bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
|
|
30
|
-
catchtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
const styles = StyleSheet.create({
|
|
@@ -79,8 +78,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
79
78
|
'parent-font-size': parentFontSize,
|
|
80
79
|
'parent-width': parentWidth,
|
|
81
80
|
'parent-height': parentHeight,
|
|
82
|
-
bindtap
|
|
83
|
-
catchtap
|
|
81
|
+
bindtap
|
|
84
82
|
} = props
|
|
85
83
|
|
|
86
84
|
const [isChecked, setIsChecked] = useState<boolean>(!!checked)
|
|
@@ -91,16 +89,14 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
91
89
|
|
|
92
90
|
const labelContext = useContext(LabelContext)
|
|
93
91
|
|
|
94
|
-
const defaultStyle =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
92
|
+
const defaultStyle = extendObject(
|
|
93
|
+
{},
|
|
94
|
+
styles.wrapper,
|
|
95
|
+
isChecked ? styles.wrapperChecked : {},
|
|
96
|
+
disabled ? styles.wrapperDisabled : {}
|
|
97
|
+
)
|
|
99
98
|
|
|
100
|
-
const styleObj = {
|
|
101
|
-
...styles.container,
|
|
102
|
-
...style
|
|
103
|
-
}
|
|
99
|
+
const styleObj = extendObject({}, styles.container, style)
|
|
104
100
|
|
|
105
101
|
const onChange = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
106
102
|
if (disabled || isChecked) return
|
|
@@ -116,16 +112,10 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
116
112
|
}
|
|
117
113
|
|
|
118
114
|
const onTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
119
|
-
if (disabled) return
|
|
120
115
|
bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props))
|
|
121
116
|
onChange(evt)
|
|
122
117
|
}
|
|
123
118
|
|
|
124
|
-
const catchTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
125
|
-
if (disabled) return
|
|
126
|
-
catchtap && catchtap(getCustomEvent('tap', evt, { layoutRef }, props))
|
|
127
|
-
}
|
|
128
|
-
|
|
129
119
|
const {
|
|
130
120
|
hasSelfPercent,
|
|
131
121
|
normalStyle,
|
|
@@ -135,7 +125,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
135
125
|
setHeight
|
|
136
126
|
} = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
137
127
|
|
|
138
|
-
const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle)
|
|
128
|
+
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
139
129
|
|
|
140
130
|
if (backgroundStyle) {
|
|
141
131
|
warn('Radio does not support background image-related styles!')
|
|
@@ -143,7 +133,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
143
133
|
|
|
144
134
|
const nodeRef = useRef(null)
|
|
145
135
|
useNodesRef(props, ref, nodeRef, {
|
|
146
|
-
defaultStyle,
|
|
136
|
+
style: extendObject({}, defaultStyle, normalStyle),
|
|
147
137
|
change: onChange
|
|
148
138
|
})
|
|
149
139
|
|
|
@@ -160,14 +150,21 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
160
150
|
|
|
161
151
|
const innerProps = useInnerProps(
|
|
162
152
|
props,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
153
|
+
extendObject(
|
|
154
|
+
{
|
|
155
|
+
ref: nodeRef,
|
|
156
|
+
style: extendObject({}, innerStyle, layoutStyle)
|
|
157
|
+
},
|
|
158
|
+
layoutProps,
|
|
159
|
+
{
|
|
160
|
+
bindtap: !disabled && onTap
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
[
|
|
164
|
+
'value',
|
|
165
|
+
'disabled',
|
|
166
|
+
'checked'
|
|
167
|
+
],
|
|
171
168
|
{
|
|
172
169
|
layoutRef
|
|
173
170
|
}
|
|
@@ -38,7 +38,7 @@ import { useAnimatedRef } from 'react-native-reanimated'
|
|
|
38
38
|
import { warn } from '@mpxjs/utils'
|
|
39
39
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
40
40
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
41
|
-
import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, flatGesture, GestureHandler } from './utils'
|
|
41
|
+
import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, extendObject, flatGesture, GestureHandler } from './utils'
|
|
42
42
|
import { IntersectionObserverContext } from './context'
|
|
43
43
|
|
|
44
44
|
interface ScrollViewProps {
|
|
@@ -176,10 +176,11 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
176
176
|
setHeight
|
|
177
177
|
} = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
178
178
|
|
|
179
|
-
const { textStyle, innerStyle } = splitStyle(normalStyle)
|
|
179
|
+
const { textStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
180
180
|
|
|
181
181
|
const scrollViewRef = useAnimatedRef<ScrollView>()
|
|
182
182
|
useNodesRef(props, ref, scrollViewRef, {
|
|
183
|
+
style: normalStyle,
|
|
183
184
|
scrollOffset: scrollOptions,
|
|
184
185
|
node: {
|
|
185
186
|
scrollEnabled: scrollX || scrollY,
|
|
@@ -298,14 +299,13 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
298
299
|
const visibleLength = selectLength(e.nativeEvent.layoutMeasurement)
|
|
299
300
|
const contentLength = selectLength(e.nativeEvent.contentSize)
|
|
300
301
|
const offset = selectOffset(e.nativeEvent.contentOffset)
|
|
301
|
-
scrollOptions.current
|
|
302
|
-
...scrollOptions.current,
|
|
302
|
+
extendObject(scrollOptions.current, {
|
|
303
303
|
contentLength,
|
|
304
304
|
offset,
|
|
305
305
|
scrollLeft: position.scrollLeft,
|
|
306
306
|
scrollTop: position.scrollTop,
|
|
307
307
|
visibleLength
|
|
308
|
-
}
|
|
308
|
+
})
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
function onScroll (e: NativeSyntheticEvent<NativeScrollEvent>) {
|
|
@@ -426,34 +426,36 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
426
426
|
updateScrollOptions(e, { scrollLeft, scrollTop })
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
429
|
+
const scrollAdditionalProps: ScrollAdditionalProps = extendObject(
|
|
430
|
+
{
|
|
431
|
+
style: extendObject({}, innerStyle, layoutStyle),
|
|
432
|
+
pinchGestureEnabled: false,
|
|
433
|
+
horizontal: scrollX && !scrollY,
|
|
434
|
+
scrollEventThrottle: scrollEventThrottle,
|
|
435
|
+
scrollsToTop: enableBackToTop,
|
|
436
|
+
showsHorizontalScrollIndicator: scrollX && showScrollbar,
|
|
437
|
+
showsVerticalScrollIndicator: scrollY && showScrollbar,
|
|
438
|
+
scrollEnabled: scrollX || scrollY,
|
|
439
|
+
ref: scrollViewRef,
|
|
440
|
+
onScroll: onScroll,
|
|
441
|
+
onContentSizeChange: onContentSizeChange,
|
|
442
|
+
bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) && onScrollTouchStart,
|
|
443
|
+
bindtouchmove: ((enhanced && binddragging) || bindtouchend) && onScrollTouchMove,
|
|
444
|
+
bindtouchend: ((enhanced && binddragend) || bindtouchend) && onScrollTouchEnd,
|
|
445
|
+
onScrollBeginDrag: onScrollDrag,
|
|
446
|
+
onScrollEndDrag: onScrollDrag,
|
|
447
|
+
onMomentumScrollEnd: onScrollEnd
|
|
448
|
+
},
|
|
449
|
+
(simultaneousHandlers ? { simultaneousHandlers } : {}),
|
|
450
|
+
(waitForHandlers ? { waitFor: waitForHandlers } : {}),
|
|
451
|
+
layoutProps
|
|
452
|
+
)
|
|
453
|
+
|
|
451
454
|
if (enhanced) {
|
|
452
|
-
scrollAdditionalProps
|
|
453
|
-
...scrollAdditionalProps,
|
|
455
|
+
Object.assign(scrollAdditionalProps, {
|
|
454
456
|
bounces,
|
|
455
457
|
pagingEnabled
|
|
456
|
-
}
|
|
458
|
+
})
|
|
457
459
|
}
|
|
458
460
|
|
|
459
461
|
const innerProps = useInnerProps(props, scrollAdditionalProps, [
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Text, TextProps } from 'react-native'
|
|
2
|
+
import { JSX, createElement } from 'react'
|
|
3
|
+
|
|
4
|
+
import { extendObject } from './utils'
|
|
5
|
+
|
|
6
|
+
const _Text2 = (props: TextProps): JSX.Element => {
|
|
7
|
+
const {
|
|
8
|
+
allowFontScaling = false
|
|
9
|
+
} = props
|
|
10
|
+
|
|
11
|
+
return createElement(Text, extendObject({}, props, {
|
|
12
|
+
allowFontScaling
|
|
13
|
+
}))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
_Text2.displayName = 'MpxSimpleText'
|
|
17
|
+
|
|
18
|
+
export default _Text2
|
|
@@ -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布局信息
|
|
@@ -12,7 +12,7 @@ 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',
|
|
@@ -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,12 +50,15 @@ 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
|
], {
|
|
@@ -12,7 +12,7 @@ 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
16
|
import LinearGradient from 'react-native-linear-gradient'
|
|
17
17
|
|
|
18
18
|
export interface _ViewProps extends ViewProps {
|
|
@@ -236,10 +236,7 @@ function backgroundPosition (imageProps: ImageProps, preImageInfo: PreImageInfo,
|
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
imageProps.style
|
|
240
|
-
...imageProps.style as ImageStyle,
|
|
241
|
-
...style
|
|
242
|
-
}
|
|
239
|
+
extendObject(imageProps.style, style)
|
|
243
240
|
}
|
|
244
241
|
|
|
245
242
|
// background-size 转换
|
|
@@ -292,10 +289,7 @@ function backgroundSize (imageProps: ImageProps, preImageInfo: PreImageInfo, ima
|
|
|
292
289
|
}
|
|
293
290
|
|
|
294
291
|
// 样式合并
|
|
295
|
-
imageProps.style
|
|
296
|
-
...imageProps.style as ImageStyle,
|
|
297
|
-
...dimensions
|
|
298
|
-
}
|
|
292
|
+
extendObject(imageProps.style, dimensions)
|
|
299
293
|
}
|
|
300
294
|
|
|
301
295
|
// background-image转换为source
|
|
@@ -481,10 +475,9 @@ function parseLinearGradient (text: string): LinearInfo | undefined {
|
|
|
481
475
|
return prev
|
|
482
476
|
}, { colors: [], locations: [] })
|
|
483
477
|
|
|
484
|
-
return {
|
|
485
|
-
...linearInfo,
|
|
478
|
+
return extendObject({}, linearInfo, {
|
|
486
479
|
direction: direction.trim()
|
|
487
|
-
}
|
|
480
|
+
})
|
|
488
481
|
}
|
|
489
482
|
|
|
490
483
|
function parseBgImage (text: string): {
|
|
@@ -692,21 +685,16 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
|
|
|
692
685
|
const [isHover, setIsHover] = useState(false)
|
|
693
686
|
|
|
694
687
|
// 默认样式
|
|
695
|
-
const defaultStyle: ExtendedViewStyle =
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
}
|
|
703
|
-
}
|
|
688
|
+
const defaultStyle: ExtendedViewStyle = style.display === 'flex'
|
|
689
|
+
? {
|
|
690
|
+
flexDirection: 'row',
|
|
691
|
+
flexBasis: 'auto',
|
|
692
|
+
flexShrink: 1,
|
|
693
|
+
flexWrap: 'nowrap'
|
|
694
|
+
}
|
|
695
|
+
: {}
|
|
704
696
|
|
|
705
|
-
const styleObj: ExtendedViewStyle = {
|
|
706
|
-
...defaultStyle,
|
|
707
|
-
...style,
|
|
708
|
-
...(isHover ? hoverStyle : null)
|
|
709
|
-
}
|
|
697
|
+
const styleObj: ExtendedViewStyle = extendObject({}, defaultStyle, style, isHover ? hoverStyle as ExtendedViewStyle : {})
|
|
710
698
|
|
|
711
699
|
const {
|
|
712
700
|
normalStyle,
|
|
@@ -723,7 +711,7 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
|
|
|
723
711
|
parentHeight
|
|
724
712
|
})
|
|
725
713
|
|
|
726
|
-
const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle)
|
|
714
|
+
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
727
715
|
|
|
728
716
|
enableBackground = enableBackground || !!backgroundStyle
|
|
729
717
|
const enableBackgroundRef = useRef(enableBackground)
|
|
@@ -733,7 +721,7 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
|
|
|
733
721
|
|
|
734
722
|
const nodeRef = useRef(null)
|
|
735
723
|
useNodesRef<View, _ViewProps>(props, ref, nodeRef, {
|
|
736
|
-
|
|
724
|
+
style: normalStyle
|
|
737
725
|
})
|
|
738
726
|
|
|
739
727
|
const dataRef = useRef<{
|
|
@@ -781,7 +769,7 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
|
|
|
781
769
|
layoutProps
|
|
782
770
|
} = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
783
771
|
|
|
784
|
-
const viewStyle =
|
|
772
|
+
const viewStyle = extendObject({}, innerStyle, layoutStyle)
|
|
785
773
|
|
|
786
774
|
enableAnimation = enableAnimation || !!animation
|
|
787
775
|
const enableAnimationRef = useRef(enableAnimation)
|
|
@@ -794,23 +782,27 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
|
|
|
794
782
|
style: viewStyle
|
|
795
783
|
})
|
|
796
784
|
: viewStyle
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
785
|
+
const innerProps = useInnerProps(
|
|
786
|
+
props,
|
|
787
|
+
extendObject({
|
|
788
|
+
ref: nodeRef,
|
|
789
|
+
style: finalStyle
|
|
790
|
+
},
|
|
791
|
+
layoutProps,
|
|
792
|
+
hoverStyle
|
|
793
|
+
? {
|
|
794
|
+
bindtouchstart: onTouchStart,
|
|
795
|
+
bindtouchend: onTouchEnd
|
|
796
|
+
}
|
|
797
|
+
: {}
|
|
798
|
+
), [
|
|
799
|
+
'hover-start-time',
|
|
800
|
+
'hover-stay-time',
|
|
801
|
+
'hover-style',
|
|
802
|
+
'hover-class'
|
|
803
|
+
], {
|
|
804
|
+
layoutRef
|
|
805
805
|
})
|
|
806
|
-
}, [
|
|
807
|
-
'hover-start-time',
|
|
808
|
-
'hover-stay-time',
|
|
809
|
-
'hover-style',
|
|
810
|
-
'hover-class'
|
|
811
|
-
], {
|
|
812
|
-
layoutRef
|
|
813
|
-
})
|
|
814
806
|
|
|
815
807
|
const childNode = wrapWithChildren(props, {
|
|
816
808
|
hasVarDec,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { forwardRef, JSX, useEffect, useRef, useContext, useMemo } from 'react'
|
|
2
2
|
import { noop, warn } from '@mpxjs/utils'
|
|
3
|
+
import { View } from 'react-native'
|
|
3
4
|
import { Portal } from '@ant-design/react-native'
|
|
4
5
|
import { getCustomEvent } from './getInnerListeners'
|
|
5
6
|
import { promisify, redirectTo, navigateTo, navigateBack, reLaunch, switchTab } from '@mpxjs/api-proxy'
|
|
6
7
|
import { WebView } from 'react-native-webview'
|
|
7
8
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
8
|
-
import { getCurrentPage } from './utils'
|
|
9
|
+
import { getCurrentPage, extendObject } from './utils'
|
|
9
10
|
import { WebViewNavigationEvent, WebViewErrorEvent, WebViewMessageEvent, WebViewNavigation } from 'react-native-webview/lib/WebViewTypes'
|
|
10
11
|
import { RouteContext } from './context'
|
|
11
12
|
|
|
@@ -39,17 +40,11 @@ type MessageData = {
|
|
|
39
40
|
callbackId?: number
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
interface NativeEvent {
|
|
43
|
-
url: string,
|
|
44
|
-
data: string
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface FormRef {
|
|
48
|
-
postMessage: (value: any) => void;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
43
|
const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((props, ref): JSX.Element => {
|
|
52
|
-
const { src
|
|
44
|
+
const { src, bindmessage = noop, bindload = noop, binderror = noop } = props
|
|
45
|
+
if (!src) {
|
|
46
|
+
return (<View></View>)
|
|
47
|
+
}
|
|
53
48
|
if (props.style) {
|
|
54
49
|
warn('The web-view component does not support the style prop.')
|
|
55
50
|
}
|
|
@@ -66,7 +61,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
|
|
|
66
61
|
|
|
67
62
|
const webViewRef = useRef<WebView>(null)
|
|
68
63
|
useNodesRef<WebView, WebViewProps>(props, ref, webViewRef, {
|
|
69
|
-
|
|
64
|
+
style: defaultWebViewStyle
|
|
70
65
|
})
|
|
71
66
|
|
|
72
67
|
const _messageList = useRef<any[]>([])
|
|
@@ -165,14 +160,29 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
|
|
|
165
160
|
}
|
|
166
161
|
})
|
|
167
162
|
}
|
|
163
|
+
const events = {}
|
|
164
|
+
|
|
165
|
+
if (bindload) {
|
|
166
|
+
extendObject(events, {
|
|
167
|
+
onLoad: _load
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
if (binderror) {
|
|
171
|
+
extendObject(events, {
|
|
172
|
+
onError: _error
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
if (bindmessage) {
|
|
176
|
+
extendObject(events, {
|
|
177
|
+
onMessage: _message
|
|
178
|
+
})
|
|
179
|
+
}
|
|
168
180
|
return (<Portal>
|
|
169
181
|
<WebView
|
|
170
182
|
style={defaultWebViewStyle}
|
|
171
183
|
source={{ uri: src }}
|
|
172
184
|
ref={webViewRef}
|
|
173
|
-
|
|
174
|
-
onError={_error}
|
|
175
|
-
onMessage={_message}
|
|
185
|
+
{...events}
|
|
176
186
|
onNavigationStateChange={_changeUrl}
|
|
177
187
|
javaScriptEnabled={true}
|
|
178
188
|
></WebView>
|
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
declare module 'react-native-svg/css' {
|
|
2
|
-
import type { ImageSourcePropType, StyleProp, ImageStyle } from 'react-native'
|
|
3
|
-
import type { SvgProps as SvgCssUriProps } from 'react-native-svg'
|
|
4
|
-
|
|
5
|
-
export const SvgCssUri: React.ComponentType<SvgCssUriProps & { uri?: string }>
|
|
6
|
-
|
|
7
|
-
export interface WithLocalSvgProps {
|
|
8
|
-
asset: ImageSourcePropType
|
|
9
|
-
style?: StyleProp<ImageStyle>
|
|
10
|
-
width?: string | number
|
|
11
|
-
height?: string | number
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const WithLocalSvg: React.ComponentType<WithLocalSvgProps>
|
|
15
|
-
}
|
|
16
|
-
|
|
17
1
|
declare module '@mpxjs/utils' {
|
|
18
2
|
export function isEmptyObject (obj: Object): boolean
|
|
19
3
|
export function isFunction (fn: unknown): boolean
|
|
4
|
+
export function isNumber (num: unknown): boolean
|
|
20
5
|
export function hasOwn (obj: Object, key: string): boolean
|
|
21
6
|
export function noop (...arg: any): void
|
|
22
7
|
export function diffAndCloneA<A, B> (a: A, b?: B): {
|