@mpxjs/webpack-plugin 2.9.69-beta.2 → 2.9.69-beta.3
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/index.js +1 -17
- package/lib/platform/style/wx/index.js +18 -18
- package/lib/platform/template/wx/component-config/movable-view.js +1 -8
- package/lib/platform/template/wx/component-config/scroll-view.js +1 -1
- package/lib/resolver/AddEnvPlugin.js +0 -1
- package/lib/resolver/AddModePlugin.js +0 -1
- package/lib/runtime/components/react/context.ts +0 -8
- package/lib/runtime/components/react/getInnerListeners.ts +5 -3
- package/lib/runtime/components/react/mpx-input.tsx +1 -1
- package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +159 -177
- package/lib/runtime/components/react/mpx-picker-view.tsx +37 -35
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +18 -12
- package/lib/runtime/components/react/mpx-scroll-view.tsx +13 -30
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +527 -0
- package/lib/runtime/components/react/mpx-swiper/index.tsx +80 -0
- package/lib/runtime/components/react/mpx-swiper/type.ts +87 -0
- package/lib/runtime/components/react/mpx-swiper-item.tsx +10 -38
- package/lib/runtime/components/react/mpx-view.tsx +51 -11
- package/lib/runtime/components/react/mpx-web-view.tsx +13 -57
- package/lib/runtime/components/react/pickerFaces.ts +7 -15
- package/lib/runtime/components/react/{pickerViewOverlay.tsx → pickerOverlay.tsx} +3 -5
- package/lib/runtime/components/react/types/global.d.ts +1 -3
- package/lib/runtime/components/react/useAnimationHooks.ts +1 -1
- package/lib/runtime/components/react/utils.tsx +5 -75
- package/lib/style-compiler/index.js +4 -3
- package/lib/template-compiler/compiler.js +14 -9
- package/lib/utils/hump-dash.js +1 -1
- package/lib/utils/pre-process-json.js +9 -5
- package/package.json +1 -1
- package/lib/runtime/components/react/mpx-picker-view-column-item.tsx +0 -88
- package/lib/runtime/components/react/mpx-swiper.tsx +0 -690
- package/lib/runtime/components/react/pickerVIewContext.ts +0 -18
- package/lib/runtime/components/react/pickerViewMask.tsx +0 -30
- package/lib/style-compiler/strip-conditional-loader.js +0 -118
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { View } from 'react-native'
|
|
2
|
-
import React, { forwardRef, useRef } from 'react'
|
|
2
|
+
import React, { forwardRef, useState, useRef } from 'react'
|
|
3
3
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
4
4
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
5
5
|
import {
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
wrapChildren,
|
|
10
10
|
parseInlineStyle,
|
|
11
11
|
useTransformStyle,
|
|
12
|
+
useDebounceCallback,
|
|
13
|
+
useStableCallback,
|
|
12
14
|
extendObject
|
|
13
15
|
} from './utils'
|
|
14
16
|
import type { AnyFunc } from './types/common'
|
|
@@ -19,21 +21,21 @@ import type { AnyFunc } from './types/common'
|
|
|
19
21
|
* ✘ bindpickend
|
|
20
22
|
* ✘ mask-class
|
|
21
23
|
* ✔ indicator-style: 优先级indicator-style.height > pick-view-column中的子元素设置的height
|
|
22
|
-
* WebView Only:
|
|
23
24
|
* ✘ indicator-class
|
|
24
|
-
*
|
|
25
|
+
* ✘ mask-style
|
|
25
26
|
* ✘ immediate-change
|
|
26
27
|
*/
|
|
27
28
|
|
|
28
29
|
interface PickerViewProps {
|
|
29
30
|
children: React.ReactNode
|
|
31
|
+
// 初始的defaultValue数组中的数字依次表示 picker-view 内的 picker-view-column 选择的第几项(下标从 0 开始),
|
|
32
|
+
// 数字大于 picker-view-column 可选项长度时,选择最后一项。
|
|
30
33
|
value?: Array<number>
|
|
31
34
|
bindchange?: AnyFunc
|
|
32
35
|
style: {
|
|
33
36
|
[key: string]: any
|
|
34
37
|
}
|
|
35
38
|
'indicator-style'?: string
|
|
36
|
-
'mask-style'?: string
|
|
37
39
|
'enable-var': boolean
|
|
38
40
|
'external-var-context'?: Record<string, any>,
|
|
39
41
|
'enable-offset': boolean
|
|
@@ -60,8 +62,6 @@ const styles: { [key: string]: Object } = {
|
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
const DefaultPickerItemH = 36
|
|
64
|
-
|
|
65
65
|
const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProps>((props: PickerViewProps, ref) => {
|
|
66
66
|
const {
|
|
67
67
|
children,
|
|
@@ -71,16 +71,16 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
71
71
|
'enable-var': enableVar,
|
|
72
72
|
'external-var-context': externalVarContext
|
|
73
73
|
} = props
|
|
74
|
+
|
|
75
|
+
// indicatorStyle 需要转换为rn的style
|
|
76
|
+
// 微信设置到pick-view上上设置的normalStyle如border等需要转换成RN的style然后进行透传
|
|
74
77
|
const indicatorStyle = parseInlineStyle(props['indicator-style'])
|
|
75
|
-
const pickerMaskStyle = parseInlineStyle(props['mask-style'])
|
|
76
78
|
const { height: indicatorH, ...pickerOverlayStyle } = indicatorStyle
|
|
79
|
+
const [pickMaxH, setPickMaxH] = useState(0)
|
|
77
80
|
const nodeRef = useRef(null)
|
|
78
81
|
const cloneRef = useRef(null)
|
|
79
82
|
const activeValueRef = useRef(value)
|
|
80
83
|
activeValueRef.current = value.slice()
|
|
81
|
-
const snapActiveValueRef = useRef<number[] | null>(null)
|
|
82
|
-
|
|
83
|
-
console.log('[mpx-picker-view] value=', value, Date.now())
|
|
84
84
|
|
|
85
85
|
const {
|
|
86
86
|
normalStyle,
|
|
@@ -96,6 +96,7 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
96
96
|
})
|
|
97
97
|
|
|
98
98
|
const {
|
|
99
|
+
// 存储layout布局信息
|
|
99
100
|
layoutRef,
|
|
100
101
|
layoutProps,
|
|
101
102
|
layoutStyle
|
|
@@ -103,34 +104,33 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
103
104
|
const { textProps } = splitProps(props)
|
|
104
105
|
const { textStyle } = splitStyle(normalStyle)
|
|
105
106
|
|
|
107
|
+
const onColumnItemRawHChange = (height: number) => {
|
|
108
|
+
if (height > pickMaxH) {
|
|
109
|
+
setPickMaxH(height)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const bindchangeDebounce = useDebounceCallback(useStableCallback(bindchange), 300)
|
|
114
|
+
|
|
106
115
|
const onSelectChange = (columnIndex: number, selectedIndex: number) => {
|
|
116
|
+
bindchangeDebounce.clear()
|
|
107
117
|
const activeValue = activeValueRef.current
|
|
108
118
|
activeValue[columnIndex] = selectedIndex
|
|
109
|
-
console.log('[mpx-picker-view], onSelectChange ---> columnIndex=', columnIndex, 'selectedIndex=', selectedIndex, 'activeValue=', activeValue)
|
|
110
119
|
const eventData = getCustomEvent(
|
|
111
120
|
'change',
|
|
112
121
|
{},
|
|
113
122
|
{ detail: { value: activeValue, source: 'change' }, layoutRef }
|
|
114
123
|
)
|
|
115
|
-
|
|
116
|
-
snapActiveValueRef.current = activeValueRef.current
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const hasDiff = (a: number[] = [], b: number[]) => {
|
|
120
|
-
return a.some((v, i) => v !== b[i])
|
|
124
|
+
bindchangeDebounce(eventData)
|
|
121
125
|
}
|
|
122
126
|
|
|
123
|
-
const onInitialChange = (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
)
|
|
131
|
-
bindchange?.(eventData)
|
|
132
|
-
snapActiveValueRef.current = value.slice()
|
|
133
|
-
}
|
|
127
|
+
const onInitialChange = (value: number[]) => {
|
|
128
|
+
const eventData = getCustomEvent(
|
|
129
|
+
'change',
|
|
130
|
+
{},
|
|
131
|
+
{ detail: { value, source: 'change' }, layoutRef }
|
|
132
|
+
)
|
|
133
|
+
bindchange?.(eventData) // immediate
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
const innerProps = useInnerProps(
|
|
@@ -153,6 +153,7 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
153
153
|
)
|
|
154
154
|
|
|
155
155
|
const renderColumn = (child: React.ReactElement, index: number, columnData: React.ReactNode[], initialIndex: number) => {
|
|
156
|
+
const extraProps = {}
|
|
156
157
|
const childProps = child?.props || {}
|
|
157
158
|
const wrappedProps = extendObject(
|
|
158
159
|
{},
|
|
@@ -163,15 +164,15 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
163
164
|
columnIndex: index,
|
|
164
165
|
key: `pick-view-${index}`,
|
|
165
166
|
wrapperStyle: {
|
|
166
|
-
height: normalStyle?.height ||
|
|
167
|
-
itemHeight: indicatorH ||
|
|
167
|
+
height: normalStyle?.height || 0,
|
|
168
|
+
itemHeight: indicatorH || 0
|
|
168
169
|
},
|
|
169
|
-
|
|
170
|
+
onColumnItemRawHChange,
|
|
170
171
|
onSelectChange: onSelectChange.bind(null, index),
|
|
171
172
|
initialIndex,
|
|
172
|
-
pickerOverlayStyle
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
pickerOverlayStyle
|
|
174
|
+
},
|
|
175
|
+
extraProps
|
|
175
176
|
)
|
|
176
177
|
const realElement = React.cloneElement(child, wrappedProps)
|
|
177
178
|
return wrapChildren(
|
|
@@ -214,7 +215,7 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
214
215
|
validValue.push(validIndex)
|
|
215
216
|
renderColumns.push(renderColumn(item, index, columnData, validIndex))
|
|
216
217
|
})
|
|
217
|
-
onInitialChange(
|
|
218
|
+
isInvalid && onInitialChange(validValue)
|
|
218
219
|
return renderColumns
|
|
219
220
|
}
|
|
220
221
|
|
|
@@ -226,4 +227,5 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
|
|
|
226
227
|
})
|
|
227
228
|
|
|
228
229
|
_PickerView.displayName = 'MpxPickerView'
|
|
230
|
+
|
|
229
231
|
export default _PickerView
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* ✔ nodes
|
|
4
4
|
*/
|
|
5
5
|
import { View, ViewProps, ViewStyle } from 'react-native'
|
|
6
|
-
import { useRef, forwardRef, JSX, useState
|
|
6
|
+
import { useRef, forwardRef, JSX, useState } from 'react'
|
|
7
7
|
import useInnerProps from '../getInnerListeners'
|
|
8
8
|
import useNodesRef, { HandlerRef } from '../useNodesRef' // 引入辅助函数
|
|
9
|
-
import { useTransformStyle, useLayout
|
|
9
|
+
import { useTransformStyle, useLayout } from '../utils'
|
|
10
10
|
import { WebView, WebViewMessageEvent } from 'react-native-webview'
|
|
11
11
|
import { generateHTML } from './html'
|
|
12
12
|
|
|
@@ -91,22 +91,28 @@ const _RichText = forwardRef<HandlerRef<View, _RichTextProps>, _RichTextProps>((
|
|
|
91
91
|
layoutRef
|
|
92
92
|
})
|
|
93
93
|
|
|
94
|
-
const innerProps = useInnerProps(props,
|
|
94
|
+
const innerProps = useInnerProps(props, {
|
|
95
95
|
ref: nodeRef,
|
|
96
|
-
style:
|
|
97
|
-
|
|
96
|
+
style: { ...normalStyle, ...layoutStyle },
|
|
97
|
+
...layoutProps
|
|
98
|
+
}, [], {
|
|
98
99
|
layoutRef
|
|
99
100
|
})
|
|
100
101
|
|
|
101
102
|
const html: string = typeof nodes === 'string' ? nodes : jsonToHtmlStr(nodes)
|
|
102
103
|
|
|
103
|
-
return
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
return (
|
|
105
|
+
<View
|
|
106
|
+
{...innerProps}
|
|
107
|
+
>
|
|
108
|
+
<WebView
|
|
109
|
+
source={{ html: generateHTML(html) }}
|
|
110
|
+
onMessage={(event: WebViewMessageEvent) => {
|
|
111
|
+
setWebViewHeight(+event.nativeEvent.data)
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
</WebView>
|
|
115
|
+
</View>
|
|
110
116
|
)
|
|
111
117
|
})
|
|
112
118
|
|
|
@@ -32,14 +32,15 @@
|
|
|
32
32
|
* ✔ bindscroll
|
|
33
33
|
*/
|
|
34
34
|
import { ScrollView } from 'react-native-gesture-handler'
|
|
35
|
-
import { View, RefreshControl, NativeSyntheticEvent, NativeScrollEvent, LayoutChangeEvent, ViewStyle
|
|
36
|
-
import { JSX, ReactNode, RefObject, useRef, useState, useEffect, forwardRef, useContext, createElement
|
|
35
|
+
import { View, RefreshControl, NativeSyntheticEvent, NativeScrollEvent, LayoutChangeEvent, ViewStyle } from 'react-native'
|
|
36
|
+
import { JSX, ReactNode, RefObject, useRef, useState, useEffect, forwardRef, useContext, createElement } from 'react'
|
|
37
37
|
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
41
|
import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, extendObject, flatGesture, GestureHandler } from './utils'
|
|
42
|
-
import { IntersectionObserverContext
|
|
42
|
+
import { IntersectionObserverContext } from './context'
|
|
43
|
+
|
|
43
44
|
interface ScrollViewProps {
|
|
44
45
|
children?: ReactNode;
|
|
45
46
|
enhanced?: boolean;
|
|
@@ -193,12 +194,6 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
193
194
|
gestureRef: scrollViewRef
|
|
194
195
|
})
|
|
195
196
|
|
|
196
|
-
const contextValue = useMemo(() => {
|
|
197
|
-
return {
|
|
198
|
-
gestureRef: scrollViewRef
|
|
199
|
-
}
|
|
200
|
-
}, [])
|
|
201
|
-
|
|
202
197
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: scrollViewRef, onLayout })
|
|
203
198
|
|
|
204
199
|
if (scrollX && scrollY) {
|
|
@@ -318,7 +313,6 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
318
313
|
})
|
|
319
314
|
}
|
|
320
315
|
|
|
321
|
-
const observerTimers: {[key: string]: any} = {}
|
|
322
316
|
function onScroll (e: NativeSyntheticEvent<NativeScrollEvent>) {
|
|
323
317
|
const { bindscroll } = props
|
|
324
318
|
const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset
|
|
@@ -340,15 +334,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
340
334
|
updateScrollOptions(e, { scrollLeft, scrollTop })
|
|
341
335
|
if (enableTriggerIntersectionObserver && intersectionObservers) {
|
|
342
336
|
for (const key in intersectionObservers) {
|
|
343
|
-
|
|
344
|
-
intersectionObservers[key].throttleMeasure();
|
|
345
|
-
} else {
|
|
346
|
-
// TODO: 由于iOS在onScroll滚动的过程中view的计算measureInWindow计算的值不发生变化,所以暂时在ios上加一个延时计算
|
|
347
|
-
observerTimers[key] && clearTimeout(observerTimers[key])
|
|
348
|
-
observerTimers[key] = setTimeout(() => {
|
|
349
|
-
intersectionObservers[key].throttleMeasure();
|
|
350
|
-
}, 300)
|
|
351
|
-
}
|
|
337
|
+
intersectionObservers[key].throttleMeasure()
|
|
352
338
|
}
|
|
353
339
|
}
|
|
354
340
|
}
|
|
@@ -521,17 +507,14 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
521
507
|
}, (refresherDefaultStyle && refresherDefaultStyle !== 'none' ? { colors: refreshColor[refresherDefaultStyle] } : null)))
|
|
522
508
|
: undefined
|
|
523
509
|
}),
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
textProps
|
|
533
|
-
}
|
|
534
|
-
)
|
|
510
|
+
wrapChildren(
|
|
511
|
+
props,
|
|
512
|
+
{
|
|
513
|
+
hasVarDec,
|
|
514
|
+
varContext: varContextRef.current,
|
|
515
|
+
textStyle,
|
|
516
|
+
textProps
|
|
517
|
+
}
|
|
535
518
|
)
|
|
536
519
|
)
|
|
537
520
|
})
|