@mpxjs/webpack-plugin 2.9.66 → 2.9.67
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/RecordGlobalComponentsDependency.js +11 -12
- package/lib/dependencies/RecordRuntimeInfoDependency.js +1 -1
- package/lib/index.js +23 -7
- package/lib/json-compiler/index.js +2 -11
- package/lib/loader.js +24 -45
- package/lib/native-loader.js +49 -64
- package/lib/platform/json/wx/index.js +3 -10
- package/lib/platform/style/wx/index.js +15 -10
- package/lib/react/index.js +4 -3
- package/lib/react/processJSON.js +5 -13
- package/lib/react/processMainScript.js +7 -3
- package/lib/react/processScript.js +3 -4
- package/lib/react/processTemplate.js +2 -2
- package/lib/resolver/AddModePlugin.js +17 -4
- package/lib/runtime/components/react/dist/mpx-button.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +30 -17
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-form.jsx +33 -24
- package/lib/runtime/components/react/dist/mpx-icon.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +44 -38
- package/lib/runtime/components/react/dist/mpx-label.jsx +10 -7
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +10 -17
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +378 -294
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +30 -17
- package/lib/runtime/components/react/dist/mpx-radio.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +49 -29
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-switch.jsx +8 -1
- package/lib/runtime/components/react/dist/mpx-text.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-view.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
- package/lib/runtime/components/react/dist/useAnimationHooks.js +96 -8
- package/lib/runtime/components/react/dist/utils.jsx +12 -3
- package/lib/runtime/components/react/getInnerListeners.ts +1 -0
- package/lib/runtime/components/react/mpx-button.tsx +1 -1
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +52 -29
- package/lib/runtime/components/react/mpx-checkbox.tsx +1 -1
- package/lib/runtime/components/react/mpx-form.tsx +42 -34
- package/lib/runtime/components/react/mpx-icon.tsx +1 -1
- package/lib/runtime/components/react/mpx-image/index.tsx +2 -3
- package/lib/runtime/components/react/mpx-input.tsx +68 -66
- package/lib/runtime/components/react/mpx-label.tsx +11 -8
- package/lib/runtime/components/react/mpx-movable-area.tsx +11 -19
- package/lib/runtime/components/react/mpx-movable-view.tsx +456 -334
- package/lib/runtime/components/react/mpx-navigator.tsx +1 -1
- package/lib/runtime/components/react/mpx-radio-group.tsx +55 -29
- package/lib/runtime/components/react/mpx-radio.tsx +1 -1
- package/lib/runtime/components/react/mpx-root-portal.tsx +1 -1
- package/lib/runtime/components/react/mpx-scroll-view.tsx +81 -36
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +2 -2
- package/lib/runtime/components/react/mpx-swiper/index.tsx +2 -1
- package/lib/runtime/components/react/mpx-swiper-item.tsx +1 -1
- package/lib/runtime/components/react/mpx-switch.tsx +10 -2
- package/lib/runtime/components/react/mpx-text.tsx +1 -1
- package/lib/runtime/components/react/mpx-textarea.tsx +1 -1
- package/lib/runtime/components/react/mpx-view.tsx +1 -1
- package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
- package/lib/runtime/components/react/useAnimationHooks.ts +97 -13
- package/lib/runtime/components/react/useNodesRef.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +18 -3
- package/lib/runtime/optionProcessorReact.js +0 -15
- package/lib/runtime/swanHelper.wxs +1 -1
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/scope-id.js +1 -0
- package/lib/template-compiler/compiler.js +46 -16
- package/lib/template-compiler/index.js +4 -4
- package/lib/utils/pre-process-json.js +113 -0
- package/lib/web/index.js +5 -4
- package/lib/web/processJSON.js +5 -13
- package/lib/web/processTemplate.js +2 -2
- package/package.json +4 -4
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ✔ bindchange
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
JSX,
|
|
6
|
+
useRef,
|
|
7
|
+
forwardRef,
|
|
8
|
+
ReactNode,
|
|
9
|
+
useContext,
|
|
10
|
+
useMemo,
|
|
11
|
+
useEffect
|
|
12
|
+
} from 'react'
|
|
13
|
+
import {
|
|
14
|
+
View,
|
|
15
|
+
NativeSyntheticEvent,
|
|
16
|
+
ViewStyle
|
|
17
|
+
} from 'react-native'
|
|
6
18
|
import { warn } from '@mpxjs/utils'
|
|
19
|
+
|
|
7
20
|
import { FormContext, FormFieldValue, RadioGroupContext, GroupValue } from './context'
|
|
8
21
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
9
22
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
@@ -32,10 +45,13 @@ const radioGroup = forwardRef<
|
|
|
32
45
|
'external-var-context': externalVarContext,
|
|
33
46
|
'parent-font-size': parentFontSize,
|
|
34
47
|
'parent-width': parentWidth,
|
|
35
|
-
'parent-height': parentHeight
|
|
36
|
-
bindchange
|
|
48
|
+
'parent-height': parentHeight
|
|
37
49
|
} = props
|
|
38
50
|
|
|
51
|
+
const propsRef = useRef<any>({})
|
|
52
|
+
|
|
53
|
+
propsRef.current = props
|
|
54
|
+
|
|
39
55
|
const formContext = useContext(FormContext)
|
|
40
56
|
|
|
41
57
|
let formValuesMap: Map<string, FormFieldValue> | undefined
|
|
@@ -70,7 +86,7 @@ const radioGroup = forwardRef<
|
|
|
70
86
|
|
|
71
87
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
72
88
|
|
|
73
|
-
const
|
|
89
|
+
const getValue = (): string | undefined => {
|
|
74
90
|
for (const key in groupValue) {
|
|
75
91
|
if (groupValue[key].checked) {
|
|
76
92
|
return key
|
|
@@ -78,10 +94,6 @@ const radioGroup = forwardRef<
|
|
|
78
94
|
}
|
|
79
95
|
}
|
|
80
96
|
|
|
81
|
-
const getValue = () => {
|
|
82
|
-
return getSelectionValue()
|
|
83
|
-
}
|
|
84
|
-
|
|
85
97
|
const resetValue = () => {
|
|
86
98
|
Object.keys(groupValue).forEach((key) => {
|
|
87
99
|
groupValue[key].checked = false
|
|
@@ -96,25 +108,39 @@ const radioGroup = forwardRef<
|
|
|
96
108
|
formValuesMap.set(props.name, { getValue, resetValue })
|
|
97
109
|
}
|
|
98
110
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
return () => {
|
|
113
|
+
if (formValuesMap && props.name) {
|
|
114
|
+
formValuesMap.delete(props.name)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}, [])
|
|
118
|
+
|
|
119
|
+
const contextValue = useMemo(() => {
|
|
120
|
+
const notifyChange = (
|
|
121
|
+
evt: NativeSyntheticEvent<TouchEvent>
|
|
122
|
+
) => {
|
|
123
|
+
const { bindchange } = propsRef.current
|
|
124
|
+
bindchange &&
|
|
125
|
+
bindchange(
|
|
126
|
+
getCustomEvent(
|
|
127
|
+
'tap',
|
|
128
|
+
evt,
|
|
129
|
+
{
|
|
130
|
+
layoutRef,
|
|
131
|
+
detail: {
|
|
132
|
+
value: getValue()
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
propsRef.current
|
|
136
|
+
)
|
|
115
137
|
)
|
|
116
|
-
|
|
117
|
-
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
groupValue,
|
|
141
|
+
notifyChange
|
|
142
|
+
}
|
|
143
|
+
}, [])
|
|
118
144
|
|
|
119
145
|
const innerProps = useInnerProps(
|
|
120
146
|
props,
|
|
@@ -131,7 +157,7 @@ const radioGroup = forwardRef<
|
|
|
131
157
|
|
|
132
158
|
return (
|
|
133
159
|
<View {...innerProps}>
|
|
134
|
-
<RadioGroupContext.Provider value={
|
|
160
|
+
<RadioGroupContext.Provider value={contextValue}>
|
|
135
161
|
{
|
|
136
162
|
wrapChildren(
|
|
137
163
|
props,
|
|
@@ -146,6 +172,6 @@ const radioGroup = forwardRef<
|
|
|
146
172
|
)
|
|
147
173
|
})
|
|
148
174
|
|
|
149
|
-
radioGroup.displayName = '
|
|
175
|
+
radioGroup.displayName = 'MpxRadioGroup'
|
|
150
176
|
|
|
151
177
|
export default radioGroup
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ✔ lower-threshold
|
|
6
6
|
* ✔ scroll-top
|
|
7
7
|
* ✔ scroll-left
|
|
8
|
-
*
|
|
8
|
+
* ✔ scroll-into-view
|
|
9
9
|
* ✔ scroll-with-animation
|
|
10
10
|
* ✔ enable-back-to-top
|
|
11
11
|
* ✘ enable-passive
|
|
@@ -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 } from './utils'
|
|
41
|
+
import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, flatGesture, GestureHandler } from './utils'
|
|
42
42
|
import { IntersectionObserverContext } from './context'
|
|
43
43
|
|
|
44
44
|
interface ScrollViewProps {
|
|
@@ -61,12 +61,15 @@ interface ScrollViewProps {
|
|
|
61
61
|
'scroll-top'?: number;
|
|
62
62
|
'scroll-left'?: number;
|
|
63
63
|
'enable-offset'?: boolean;
|
|
64
|
+
'scroll-into-view'?: string;
|
|
64
65
|
'enable-trigger-intersection-observer'?: boolean;
|
|
65
66
|
'enable-var'?: boolean;
|
|
66
67
|
'external-var-context'?: Record<string, any>;
|
|
67
68
|
'parent-font-size'?: number;
|
|
68
69
|
'parent-width'?: number;
|
|
69
70
|
'parent-height'?: number;
|
|
71
|
+
'wait-for'?: Array<GestureHandler>;
|
|
72
|
+
'simultaneous-handlers'?: Array<GestureHandler>;
|
|
70
73
|
bindscrolltoupper?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
71
74
|
bindscrolltolower?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
72
75
|
bindscroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
@@ -78,6 +81,7 @@ interface ScrollViewProps {
|
|
|
78
81
|
bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
79
82
|
bindtouchend?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
80
83
|
bindscrollend?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
84
|
+
__selectRef?: (selector: string, nodeType: 'node' | 'component', all?: boolean) => HandlerRef<any, any>
|
|
81
85
|
}
|
|
82
86
|
type ScrollAdditionalProps = {
|
|
83
87
|
pinchGestureEnabled: boolean;
|
|
@@ -97,6 +101,7 @@ type ScrollAdditionalProps = {
|
|
|
97
101
|
bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
98
102
|
bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
99
103
|
bindtouchend?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
104
|
+
onScrollBeginDrag?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
100
105
|
onScrollEndDrag?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
101
106
|
onMomentumScrollEnd?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
102
107
|
};
|
|
@@ -106,6 +111,12 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
106
111
|
enhanced = false,
|
|
107
112
|
bounces = true,
|
|
108
113
|
style = {},
|
|
114
|
+
binddragstart,
|
|
115
|
+
binddragging,
|
|
116
|
+
binddragend,
|
|
117
|
+
bindtouchstart,
|
|
118
|
+
bindtouchmove,
|
|
119
|
+
bindtouchend,
|
|
109
120
|
'scroll-x': scrollX = false,
|
|
110
121
|
'scroll-y': scrollY = false,
|
|
111
122
|
'enable-back-to-top': enableBackToTop = false,
|
|
@@ -118,13 +129,23 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
118
129
|
'refresher-default-style': refresherDefaultStyle,
|
|
119
130
|
'refresher-background': refresherBackground,
|
|
120
131
|
'show-scrollbar': showScrollbar = true,
|
|
132
|
+
'scroll-into-view': scrollIntoView = '',
|
|
133
|
+
'scroll-top': scrollTop = 0,
|
|
134
|
+
'scroll-left': scrollLeft = 0,
|
|
135
|
+
'refresher-triggered': refresherTriggered,
|
|
121
136
|
'enable-var': enableVar,
|
|
122
137
|
'external-var-context': externalVarContext,
|
|
123
138
|
'parent-font-size': parentFontSize,
|
|
124
139
|
'parent-width': parentWidth,
|
|
125
|
-
'parent-height': parentHeight
|
|
140
|
+
'parent-height': parentHeight,
|
|
141
|
+
'simultaneous-handlers': originSimultaneousHandlers,
|
|
142
|
+
'wait-for': waitFor,
|
|
143
|
+
__selectRef
|
|
126
144
|
} = props
|
|
127
145
|
|
|
146
|
+
const simultaneousHandlers = flatGesture(originSimultaneousHandlers)
|
|
147
|
+
const waitForHandlers = flatGesture(waitFor)
|
|
148
|
+
|
|
128
149
|
const [refreshing, setRefreshing] = useState(true)
|
|
129
150
|
|
|
130
151
|
const snapScrollTop = useRef(0)
|
|
@@ -144,6 +165,8 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
144
165
|
const initialTimeout = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
145
166
|
const intersectionObservers = useContext(IntersectionObserverContext)
|
|
146
167
|
|
|
168
|
+
const snapScrollIntoView = useRef<string>('')
|
|
169
|
+
|
|
147
170
|
const {
|
|
148
171
|
normalStyle,
|
|
149
172
|
hasVarDec,
|
|
@@ -166,7 +189,8 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
166
189
|
fastDeceleration: false,
|
|
167
190
|
decelerationDisabled: false,
|
|
168
191
|
scrollTo: scrollToOffset
|
|
169
|
-
}
|
|
192
|
+
},
|
|
193
|
+
gestureRef: scrollViewRef
|
|
170
194
|
})
|
|
171
195
|
|
|
172
196
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: scrollViewRef, onLayout })
|
|
@@ -176,27 +200,41 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
176
200
|
}
|
|
177
201
|
useEffect(() => {
|
|
178
202
|
if (
|
|
179
|
-
snapScrollTop.current !==
|
|
180
|
-
snapScrollLeft.current !== props['scroll-left']
|
|
203
|
+
snapScrollTop.current !== scrollTop || snapScrollLeft.current !== scrollLeft
|
|
181
204
|
) {
|
|
182
|
-
snapScrollTop.current = props['scroll-top'] || 0
|
|
183
|
-
snapScrollLeft.current = props['scroll-left'] || 0
|
|
184
|
-
|
|
185
205
|
initialTimeout.current = setTimeout(() => {
|
|
186
|
-
scrollToOffset(
|
|
206
|
+
scrollToOffset(scrollLeft, scrollTop)
|
|
187
207
|
}, 0)
|
|
188
208
|
|
|
189
209
|
return () => {
|
|
190
210
|
initialTimeout.current && clearTimeout(initialTimeout.current)
|
|
191
211
|
}
|
|
192
212
|
}
|
|
193
|
-
}, [
|
|
213
|
+
}, [scrollTop, scrollLeft])
|
|
194
214
|
|
|
195
215
|
useEffect(() => {
|
|
196
|
-
if (refreshing !==
|
|
197
|
-
setRefreshing(!!
|
|
216
|
+
if (refreshing !== refresherTriggered) {
|
|
217
|
+
setRefreshing(!!refresherTriggered)
|
|
218
|
+
}
|
|
219
|
+
}, [refresherTriggered])
|
|
220
|
+
|
|
221
|
+
useEffect(() => {
|
|
222
|
+
if (scrollIntoView && __selectRef && snapScrollIntoView.current !== scrollIntoView) {
|
|
223
|
+
snapScrollIntoView.current = scrollIntoView || ''
|
|
224
|
+
setTimeout(() => {
|
|
225
|
+
const refs = __selectRef(`#${scrollIntoView}`, 'node')
|
|
226
|
+
if (refs) {
|
|
227
|
+
const { nodeRef } = refs.getNodeInstance()
|
|
228
|
+
nodeRef.current?.measureLayout(
|
|
229
|
+
scrollViewRef.current,
|
|
230
|
+
(left: number, top:number) => {
|
|
231
|
+
scrollToOffset(left, top)
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
})
|
|
198
236
|
}
|
|
199
|
-
}, [
|
|
237
|
+
}, [scrollIntoView])
|
|
200
238
|
|
|
201
239
|
function selectLength (size: { height: number; width: number }) {
|
|
202
240
|
return !scrollX ? size.height : size.width
|
|
@@ -322,6 +360,8 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
322
360
|
scrollViewRef.current.scrollTo({ x, y, animated: !!scrollWithAnimation })
|
|
323
361
|
scrollOptions.current.scrollLeft = x
|
|
324
362
|
scrollOptions.current.scrollTop = y
|
|
363
|
+
snapScrollLeft.current = x
|
|
364
|
+
snapScrollTop.current = y
|
|
325
365
|
}
|
|
326
366
|
}
|
|
327
367
|
|
|
@@ -334,7 +374,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
334
374
|
}
|
|
335
375
|
|
|
336
376
|
function onScrollTouchStart (e: NativeSyntheticEvent<TouchEvent>) {
|
|
337
|
-
const {
|
|
377
|
+
const { bindtouchstart } = props
|
|
338
378
|
bindtouchstart && bindtouchstart(e)
|
|
339
379
|
if (enhanced) {
|
|
340
380
|
binddragstart &&
|
|
@@ -350,7 +390,6 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
350
390
|
}
|
|
351
391
|
}
|
|
352
392
|
function onScrollTouchMove (e: NativeSyntheticEvent<TouchEvent>) {
|
|
353
|
-
const { binddragging, bindtouchmove, enhanced } = props
|
|
354
393
|
bindtouchmove && bindtouchmove(e)
|
|
355
394
|
if (enhanced) {
|
|
356
395
|
binddragging &&
|
|
@@ -366,27 +405,27 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
366
405
|
}
|
|
367
406
|
}
|
|
368
407
|
|
|
369
|
-
function
|
|
370
|
-
|
|
408
|
+
function onScrollTouchEnd (e: NativeSyntheticEvent<TouchEvent>) {
|
|
409
|
+
bindtouchend && bindtouchend(e)
|
|
371
410
|
if (enhanced) {
|
|
372
|
-
const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset
|
|
373
|
-
const { width: scrollWidth, height: scrollHeight } = e.nativeEvent.contentSize
|
|
374
411
|
binddragend &&
|
|
375
412
|
binddragend(
|
|
376
413
|
getCustomEvent('dragend', e, {
|
|
377
414
|
detail: {
|
|
378
|
-
scrollLeft: scrollLeft,
|
|
379
|
-
scrollTop: scrollTop
|
|
380
|
-
scrollHeight,
|
|
381
|
-
scrollWidth
|
|
415
|
+
scrollLeft: scrollOptions.current.scrollLeft || 0,
|
|
416
|
+
scrollTop: scrollOptions.current.scrollTop || 0
|
|
382
417
|
},
|
|
383
418
|
layoutRef
|
|
384
419
|
}, props)
|
|
385
420
|
)
|
|
386
|
-
updateScrollOptions(e, { scrollLeft, scrollTop })
|
|
387
421
|
}
|
|
388
422
|
}
|
|
389
423
|
|
|
424
|
+
function onScrollDrag (e: NativeSyntheticEvent<NativeScrollEvent>) {
|
|
425
|
+
const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset
|
|
426
|
+
updateScrollOptions(e, { scrollLeft, scrollTop })
|
|
427
|
+
}
|
|
428
|
+
|
|
390
429
|
let scrollAdditionalProps: ScrollAdditionalProps = {
|
|
391
430
|
style: { ...innerStyle, ...layoutStyle },
|
|
392
431
|
pinchGestureEnabled: false,
|
|
@@ -399,11 +438,15 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
399
438
|
ref: scrollViewRef,
|
|
400
439
|
onScroll: onScroll,
|
|
401
440
|
onContentSizeChange: onContentSizeChange,
|
|
402
|
-
bindtouchstart: onScrollTouchStart,
|
|
403
|
-
bindtouchmove: onScrollTouchMove,
|
|
404
|
-
|
|
441
|
+
bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) ? onScrollTouchStart : undefined,
|
|
442
|
+
bindtouchmove: ((enhanced && binddragging) || bindtouchend) ? onScrollTouchMove : undefined,
|
|
443
|
+
bindtouchend: ((enhanced && binddragend) || bindtouchend) ? onScrollTouchEnd : undefined,
|
|
444
|
+
onScrollBeginDrag: onScrollDrag,
|
|
445
|
+
onScrollEndDrag: onScrollDrag,
|
|
405
446
|
onMomentumScrollEnd: onScrollEnd,
|
|
406
|
-
...layoutProps
|
|
447
|
+
...layoutProps,
|
|
448
|
+
...(simultaneousHandlers ? { simultaneousHandlers } : {}),
|
|
449
|
+
...(waitForHandlers ? { waitFor: waitForHandlers } : {})
|
|
407
450
|
}
|
|
408
451
|
if (enhanced) {
|
|
409
452
|
scrollAdditionalProps = {
|
|
@@ -412,7 +455,9 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
412
455
|
pagingEnabled
|
|
413
456
|
}
|
|
414
457
|
}
|
|
458
|
+
|
|
415
459
|
const innerProps = useInnerProps(props, scrollAdditionalProps, [
|
|
460
|
+
'id',
|
|
416
461
|
'scroll-x',
|
|
417
462
|
'scroll-y',
|
|
418
463
|
'enable-back-to-top',
|
|
@@ -449,12 +494,12 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
449
494
|
{...innerProps}
|
|
450
495
|
refreshControl={refresherEnabled
|
|
451
496
|
? (
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
497
|
+
<RefreshControl
|
|
498
|
+
progressBackgroundColor={refresherBackground}
|
|
499
|
+
refreshing={refreshing}
|
|
500
|
+
onRefresh={onRefresh}
|
|
501
|
+
{...(refresherDefaultStyle && refresherDefaultStyle !== 'none' ? { colors: refreshColor[refresherDefaultStyle] } : {})}
|
|
502
|
+
/>
|
|
458
503
|
)
|
|
459
504
|
: undefined}
|
|
460
505
|
>
|
|
@@ -473,6 +518,6 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
473
518
|
)
|
|
474
519
|
})
|
|
475
520
|
|
|
476
|
-
_ScrollView.displayName = '
|
|
521
|
+
_ScrollView.displayName = 'MpxScrollView'
|
|
477
522
|
|
|
478
523
|
export default _ScrollView
|
|
@@ -488,7 +488,7 @@ const _Carouse = forwardRef<HandlerRef<ScrollView & View, CarouseProps>, Carouse
|
|
|
488
488
|
} else if (i === pages.length - 1 && typeof width === 'number') {
|
|
489
489
|
nextMargin && (extraStyle.marginRight = nextMargin)
|
|
490
490
|
}
|
|
491
|
-
return (<View style={[pageStyle, styles.slide, extraStyle]} key={
|
|
491
|
+
return (<View style={[pageStyle, styles.slide, extraStyle]} key={'page' + i}>
|
|
492
492
|
{wrapChildren(
|
|
493
493
|
{
|
|
494
494
|
children: children[+page]
|
|
@@ -520,6 +520,6 @@ const _Carouse = forwardRef<HandlerRef<ScrollView & View, CarouseProps>, Carouse
|
|
|
520
520
|
</View>)
|
|
521
521
|
})
|
|
522
522
|
|
|
523
|
-
_Carouse.displayName = '
|
|
523
|
+
_Carouse.displayName = 'MpxCarouse'
|
|
524
524
|
|
|
525
525
|
export default _Carouse
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* ✔ disabled
|
|
5
5
|
* ✔ color
|
|
6
6
|
*/
|
|
7
|
-
import { Switch, SwitchProps, ViewStyle, NativeSyntheticEvent
|
|
7
|
+
import { Switch, SwitchProps, ViewStyle, NativeSyntheticEvent } from 'react-native'
|
|
8
8
|
import { useRef, useEffect, forwardRef, JSX, useState, useContext } from 'react'
|
|
9
9
|
import { warn } from '@mpxjs/utils'
|
|
10
10
|
import useNodesRef, { HandlerRef } from './useNodesRef' // 引入辅助函数
|
|
@@ -111,6 +111,14 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
return () => {
|
|
116
|
+
if (formValuesMap && props.name) {
|
|
117
|
+
formValuesMap.delete(props.name)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}, [])
|
|
121
|
+
|
|
114
122
|
const innerProps = useInnerProps(props, {
|
|
115
123
|
ref: nodeRef,
|
|
116
124
|
style: { ...normalStyle, ...layoutStyle },
|
|
@@ -144,6 +152,6 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
|
|
|
144
152
|
/>
|
|
145
153
|
})
|
|
146
154
|
|
|
147
|
-
_Switch.displayName = '
|
|
155
|
+
_Switch.displayName = 'MpxSwitch'
|
|
148
156
|
|
|
149
157
|
export default _Switch
|