@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.
Files changed (77) hide show
  1. package/lib/dependencies/RecordGlobalComponentsDependency.js +11 -12
  2. package/lib/dependencies/RecordRuntimeInfoDependency.js +1 -1
  3. package/lib/index.js +23 -7
  4. package/lib/json-compiler/index.js +2 -11
  5. package/lib/loader.js +24 -45
  6. package/lib/native-loader.js +49 -64
  7. package/lib/platform/json/wx/index.js +3 -10
  8. package/lib/platform/style/wx/index.js +15 -10
  9. package/lib/react/index.js +4 -3
  10. package/lib/react/processJSON.js +5 -13
  11. package/lib/react/processMainScript.js +7 -3
  12. package/lib/react/processScript.js +3 -4
  13. package/lib/react/processTemplate.js +2 -2
  14. package/lib/resolver/AddModePlugin.js +17 -4
  15. package/lib/runtime/components/react/dist/mpx-button.jsx +1 -1
  16. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +30 -17
  17. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +1 -1
  18. package/lib/runtime/components/react/dist/mpx-form.jsx +33 -24
  19. package/lib/runtime/components/react/dist/mpx-icon.jsx +1 -1
  20. package/lib/runtime/components/react/dist/mpx-image/index.jsx +1 -1
  21. package/lib/runtime/components/react/dist/mpx-input.jsx +44 -38
  22. package/lib/runtime/components/react/dist/mpx-label.jsx +10 -7
  23. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +10 -17
  24. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +378 -294
  25. package/lib/runtime/components/react/dist/mpx-navigator.jsx +1 -1
  26. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +30 -17
  27. package/lib/runtime/components/react/dist/mpx-radio.jsx +1 -1
  28. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +1 -1
  29. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +49 -29
  30. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +1 -1
  31. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +1 -1
  32. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +1 -1
  33. package/lib/runtime/components/react/dist/mpx-switch.jsx +8 -1
  34. package/lib/runtime/components/react/dist/mpx-text.jsx +1 -1
  35. package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -1
  36. package/lib/runtime/components/react/dist/mpx-view.jsx +1 -1
  37. package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
  38. package/lib/runtime/components/react/dist/useAnimationHooks.js +96 -8
  39. package/lib/runtime/components/react/dist/utils.jsx +12 -3
  40. package/lib/runtime/components/react/getInnerListeners.ts +1 -0
  41. package/lib/runtime/components/react/mpx-button.tsx +1 -1
  42. package/lib/runtime/components/react/mpx-checkbox-group.tsx +52 -29
  43. package/lib/runtime/components/react/mpx-checkbox.tsx +1 -1
  44. package/lib/runtime/components/react/mpx-form.tsx +42 -34
  45. package/lib/runtime/components/react/mpx-icon.tsx +1 -1
  46. package/lib/runtime/components/react/mpx-image/index.tsx +2 -3
  47. package/lib/runtime/components/react/mpx-input.tsx +68 -66
  48. package/lib/runtime/components/react/mpx-label.tsx +11 -8
  49. package/lib/runtime/components/react/mpx-movable-area.tsx +11 -19
  50. package/lib/runtime/components/react/mpx-movable-view.tsx +456 -334
  51. package/lib/runtime/components/react/mpx-navigator.tsx +1 -1
  52. package/lib/runtime/components/react/mpx-radio-group.tsx +55 -29
  53. package/lib/runtime/components/react/mpx-radio.tsx +1 -1
  54. package/lib/runtime/components/react/mpx-root-portal.tsx +1 -1
  55. package/lib/runtime/components/react/mpx-scroll-view.tsx +81 -36
  56. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +2 -2
  57. package/lib/runtime/components/react/mpx-swiper/index.tsx +2 -1
  58. package/lib/runtime/components/react/mpx-swiper-item.tsx +1 -1
  59. package/lib/runtime/components/react/mpx-switch.tsx +10 -2
  60. package/lib/runtime/components/react/mpx-text.tsx +1 -1
  61. package/lib/runtime/components/react/mpx-textarea.tsx +1 -1
  62. package/lib/runtime/components/react/mpx-view.tsx +1 -1
  63. package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
  64. package/lib/runtime/components/react/useAnimationHooks.ts +97 -13
  65. package/lib/runtime/components/react/useNodesRef.ts +1 -0
  66. package/lib/runtime/components/react/utils.tsx +18 -3
  67. package/lib/runtime/optionProcessorReact.js +0 -15
  68. package/lib/runtime/swanHelper.wxs +1 -1
  69. package/lib/style-compiler/index.js +1 -1
  70. package/lib/style-compiler/plugins/scope-id.js +1 -0
  71. package/lib/template-compiler/compiler.js +46 -16
  72. package/lib/template-compiler/index.js +4 -4
  73. package/lib/utils/pre-process-json.js +113 -0
  74. package/lib/web/index.js +5 -4
  75. package/lib/web/processJSON.js +5 -13
  76. package/lib/web/processTemplate.js +2 -2
  77. package/package.json +4 -4
@@ -62,6 +62,6 @@ const _Navigator = forwardRef<View, _NavigatorProps>((props, ref): JSX.Element =
62
62
  )
63
63
  })
64
64
 
65
- _Navigator.displayName = 'mpx-navigator'
65
+ _Navigator.displayName = 'MpxNavigator'
66
66
 
67
67
  export default _Navigator
@@ -1,9 +1,22 @@
1
1
  /**
2
2
  * ✔ bindchange
3
3
  */
4
- import { JSX, useRef, forwardRef, ReactNode, useContext } from 'react'
5
- import { View, NativeSyntheticEvent, ViewStyle } from 'react-native'
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 getSelectionValue = (): string | undefined => {
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
- const notifyChange = (
101
- evt: NativeSyntheticEvent<TouchEvent>
102
- ) => {
103
- bindchange &&
104
- bindchange(
105
- getCustomEvent(
106
- 'tap',
107
- evt,
108
- {
109
- layoutRef,
110
- detail: {
111
- value: getSelectionValue()
112
- }
113
- },
114
- props
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={{ groupValue, notifyChange }}>
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 = 'mpx-radio-group'
175
+ radioGroup.displayName = 'MpxRadioGroup'
150
176
 
151
177
  export default radioGroup
@@ -226,6 +226,6 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
226
226
  }
227
227
  )
228
228
 
229
- Radio.displayName = 'mpx-radio'
229
+ Radio.displayName = 'MpxRadio'
230
230
 
231
231
  export default Radio
@@ -22,6 +22,6 @@ const _RootPortal = (props: RootPortalProps) => {
22
22
  : <>{children}</>
23
23
  }
24
24
 
25
- _RootPortal.displayName = 'mpx-root-portal'
25
+ _RootPortal.displayName = 'MpxRootPortal'
26
26
 
27
27
  export default _RootPortal
@@ -5,7 +5,7 @@
5
5
  * ✔ lower-threshold
6
6
  * ✔ scroll-top
7
7
  * ✔ scroll-left
8
- * scroll-into-view
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 !== props['scroll-top'] ||
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(snapScrollLeft.current, snapScrollTop.current)
206
+ scrollToOffset(scrollLeft, scrollTop)
187
207
  }, 0)
188
208
 
189
209
  return () => {
190
210
  initialTimeout.current && clearTimeout(initialTimeout.current)
191
211
  }
192
212
  }
193
- }, [props['scroll-top'], props['scroll-left']])
213
+ }, [scrollTop, scrollLeft])
194
214
 
195
215
  useEffect(() => {
196
- if (refreshing !== props['refresher-triggered']) {
197
- setRefreshing(!!props['refresher-triggered'])
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
- }, [props['refresher-triggered']])
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 { binddragstart, bindtouchstart, enhanced } = props
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 onScrollEndDrag (e: NativeSyntheticEvent<NativeScrollEvent>) {
370
- const { binddragend, enhanced } = props
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
- onScrollEndDrag,
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
- <RefreshControl
453
- progressBackgroundColor={refresherBackground}
454
- refreshing={refreshing}
455
- onRefresh={onRefresh}
456
- {...(refresherDefaultStyle && refresherDefaultStyle !== 'none' ? { colors: refreshColor[refresherDefaultStyle] } : {})}
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 = 'mpx-scroll-view'
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={ 'page' + i}>
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 = '_Carouse'
523
+ _Carouse.displayName = 'MpxCarouse'
524
524
 
525
525
  export default _Carouse
@@ -74,6 +74,7 @@ const _SwiperWrapper = forwardRef<HandlerRef<ScrollView, SwiperProps>, SwiperPro
74
74
  {children}
75
75
  </Carouse>
76
76
  })
77
- _SwiperWrapper.displayName = 'mpx-swiper'
77
+
78
+ _SwiperWrapper.displayName = 'MpxSwiper'
78
79
 
79
80
  export default _SwiperWrapper
@@ -73,6 +73,6 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp
73
73
  )
74
74
  })
75
75
 
76
- _SwiperItem.displayName = 'mpx-swiper-item'
76
+ _SwiperItem.displayName = 'MpxSwiperItem'
77
77
 
78
78
  export default _SwiperItem
@@ -4,7 +4,7 @@
4
4
  * ✔ disabled
5
5
  * ✔ color
6
6
  */
7
- import { Switch, SwitchProps, ViewStyle, NativeSyntheticEvent, LayoutChangeEvent } from 'react-native'
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 = 'mpx-switch'
155
+ _Switch.displayName = 'MpxSwitch'
148
156
 
149
157
  export default _Switch
@@ -78,6 +78,6 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
78
78
  )
79
79
  })
80
80
 
81
- _Text.displayName = 'mpx-text'
81
+ _Text.displayName = 'MpxText'
82
82
 
83
83
  export default _Text
@@ -41,6 +41,6 @@ const Textarea = forwardRef<HandlerRef<TextInput, TextareProps>, TextareProps>(
41
41
  }
42
42
  )
43
43
 
44
- Textarea.displayName = 'mpx-textarea'
44
+ Textarea.displayName = 'MpxTextarea'
45
45
 
46
46
  export default Textarea
@@ -805,6 +805,6 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
805
805
  </View>)
806
806
  })
807
807
 
808
- _View.displayName = 'mpx-view'
808
+ _View.displayName = 'MpxView'
809
809
 
810
810
  export default _View
@@ -162,6 +162,6 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
162
162
  </Portal>)
163
163
  })
164
164
 
165
- _WebView.displayName = 'mpx-web-view'
165
+ _WebView.displayName = 'MpxWebview'
166
166
 
167
167
  export default _WebView