@mpxjs/webpack-plugin 2.9.67 → 2.9.69-beta.0
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 +13 -8
- package/lib/platform/json/wx/index.js +21 -8
- package/lib/platform/style/wx/index.js +35 -38
- package/lib/platform/template/wx/component-config/canvas.js +8 -0
- package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
- package/lib/platform/template/wx/component-config/index.js +1 -1
- package/lib/platform/template/wx/component-config/input.js +1 -1
- package/lib/platform/template/wx/component-config/rich-text.js +8 -0
- package/lib/platform/template/wx/component-config/swiper.js +1 -1
- package/lib/platform/template/wx/component-config/textarea.js +1 -1
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/react/processStyles.js +14 -4
- package/lib/react/processTemplate.js +3 -0
- package/lib/resolver/AddModePlugin.js +8 -8
- package/lib/runtime/components/react/context.ts +6 -0
- package/lib/runtime/components/react/dist/context.js +2 -0
- package/lib/runtime/components/react/dist/event.config.js +24 -24
- package/lib/runtime/components/react/dist/getInnerListeners.js +183 -174
- package/lib/runtime/components/react/dist/mpx-button.jsx +77 -49
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.js +60 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.js +84 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.js +87 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.js +28 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +343 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +232 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.jsx +89 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
- package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
- package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
- package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
- package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +160 -88
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +80 -121
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
- package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
- package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -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 +65 -61
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +112 -35
- package/lib/runtime/components/react/dist/pickerFaces.js +81 -0
- 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/pickerViewOverlay.jsx +23 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -9
- package/lib/runtime/components/react/dist/utils.jsx +70 -23
- package/lib/runtime/components/react/event.config.ts +25 -26
- package/lib/runtime/components/react/getInnerListeners.ts +237 -199
- package/lib/runtime/components/react/mpx-button.tsx +104 -57
- package/lib/runtime/components/react/mpx-canvas/Bus.ts +70 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasGradient.ts +18 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasRenderingContext2D.ts +87 -0
- package/lib/runtime/components/react/mpx-canvas/Image.ts +102 -0
- package/lib/runtime/components/react/mpx-canvas/ImageData.ts +23 -0
- package/lib/runtime/components/react/mpx-canvas/constructorsRegistry.ts +38 -0
- package/lib/runtime/components/react/mpx-canvas/html.ts +343 -0
- package/lib/runtime/components/react/mpx-canvas/index.tsx +296 -0
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +150 -0
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +28 -25
- package/lib/runtime/components/react/mpx-checkbox.tsx +48 -49
- package/lib/runtime/components/react/mpx-form.tsx +25 -28
- package/lib/runtime/components/react/mpx-icon.tsx +12 -17
- package/lib/runtime/components/react/mpx-image.tsx +436 -0
- package/lib/runtime/components/react/mpx-input.tsx +77 -57
- package/lib/runtime/components/react/mpx-label.tsx +26 -27
- package/lib/runtime/components/react/mpx-movable-area.tsx +18 -23
- package/lib/runtime/components/react/mpx-movable-view.tsx +21 -25
- package/lib/runtime/components/react/mpx-navigator.tsx +2 -8
- package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
- package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +236 -104
- package/lib/runtime/components/react/mpx-picker-view.tsx +132 -122
- package/lib/runtime/components/react/mpx-radio-group.tsx +24 -27
- package/lib/runtime/components/react/mpx-radio.tsx +45 -54
- package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +121 -0
- package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
- package/lib/runtime/components/react/mpx-scroll-view.tsx +72 -71
- package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
- package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
- package/lib/runtime/components/react/mpx-switch.tsx +29 -23
- package/lib/runtime/components/react/mpx-text.tsx +14 -18
- package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
- package/lib/runtime/components/react/mpx-view.tsx +92 -76
- package/lib/runtime/components/react/mpx-web-view.tsx +116 -54
- package/lib/runtime/components/react/pickerFaces.ts +104 -0
- package/lib/runtime/components/react/pickerOverlay.tsx +32 -0
- package/lib/runtime/components/react/types/common.ts +2 -0
- package/lib/runtime/components/react/types/global.d.ts +5 -17
- package/lib/runtime/components/react/useAnimationHooks.ts +36 -11
- package/lib/runtime/components/react/utils.tsx +99 -28
- package/lib/runtime/components/web/getInnerListeners.js +6 -6
- package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
- package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
- package/lib/runtime/components/web/mpx-picker.vue +382 -385
- package/lib/runtime/components/web/mpx-web-view.vue +175 -161
- package/lib/runtime/optionProcessor.js +7 -38
- package/lib/runtime/utils.js +2 -0
- package/lib/style-compiler/plugins/scope-id.js +30 -2
- package/lib/template-compiler/bind-this.js +7 -2
- package/lib/template-compiler/compiler.js +79 -47
- package/lib/template-compiler/gen-node-react.js +3 -3
- package/lib/utils/pre-process-json.js +9 -5
- package/package.json +6 -4
- 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
- package/lib/runtime/components/web/event.js +0 -105
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* ✔ nodes
|
|
4
|
+
*/
|
|
5
|
+
import { View, ViewProps, ViewStyle } from 'react-native'
|
|
6
|
+
import { useRef, forwardRef, JSX, useState } from 'react'
|
|
7
|
+
import useInnerProps from '../getInnerListeners'
|
|
8
|
+
import useNodesRef, { HandlerRef } from '../useNodesRef' // 引入辅助函数
|
|
9
|
+
import { useTransformStyle, useLayout } from '../utils'
|
|
10
|
+
import { WebView, WebViewMessageEvent } from 'react-native-webview'
|
|
11
|
+
import { generateHTML } from './html'
|
|
12
|
+
|
|
13
|
+
type Node = {
|
|
14
|
+
type: 'node' | 'text'
|
|
15
|
+
name?: string
|
|
16
|
+
attrs?: any
|
|
17
|
+
children?: Array<Node>
|
|
18
|
+
text: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface _RichTextProps extends ViewProps {
|
|
22
|
+
style?: ViewStyle
|
|
23
|
+
nodes: string | Array<Node>
|
|
24
|
+
'enable-var'?: boolean
|
|
25
|
+
'external-var-context'?: Record<string, any>
|
|
26
|
+
'parent-font-size'?: number
|
|
27
|
+
'parent-width'?: number
|
|
28
|
+
'parent-height'?: number
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function jsonToHtmlStr (elements: Array<Node>) {
|
|
32
|
+
let htmlStr = ''
|
|
33
|
+
|
|
34
|
+
for (const element of elements) {
|
|
35
|
+
if (element.type === 'text') {
|
|
36
|
+
htmlStr += element.text
|
|
37
|
+
return htmlStr
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const { name, attrs = {}, children = [] } = element
|
|
41
|
+
|
|
42
|
+
let attrStr = ''
|
|
43
|
+
for (const [key, value] of Object.entries(attrs)) attrStr += ` ${key}="${value}"`
|
|
44
|
+
|
|
45
|
+
let childrenStr = ''
|
|
46
|
+
for (const child of children) childrenStr += jsonToHtmlStr([child])
|
|
47
|
+
|
|
48
|
+
htmlStr += `<${name}${attrStr}>${childrenStr}</${name}>`
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return htmlStr
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const _RichText = forwardRef<HandlerRef<View, _RichTextProps>, _RichTextProps>((props, ref): JSX.Element => {
|
|
55
|
+
const {
|
|
56
|
+
style = {},
|
|
57
|
+
nodes,
|
|
58
|
+
'enable-var': enableVar,
|
|
59
|
+
'external-var-context': externalVarContext,
|
|
60
|
+
'parent-font-size': parentFontSize,
|
|
61
|
+
'parent-width': parentWidth,
|
|
62
|
+
'parent-height': parentHeight
|
|
63
|
+
} = props
|
|
64
|
+
|
|
65
|
+
const nodeRef = useRef(null)
|
|
66
|
+
const [webViewHeight, setWebViewHeight] = useState(0)
|
|
67
|
+
|
|
68
|
+
const {
|
|
69
|
+
normalStyle,
|
|
70
|
+
hasSelfPercent,
|
|
71
|
+
setWidth,
|
|
72
|
+
setHeight
|
|
73
|
+
} = useTransformStyle(Object.assign({
|
|
74
|
+
width: '100%',
|
|
75
|
+
height: webViewHeight
|
|
76
|
+
}, style), {
|
|
77
|
+
enableVar,
|
|
78
|
+
externalVarContext,
|
|
79
|
+
parentFontSize,
|
|
80
|
+
parentWidth,
|
|
81
|
+
parentHeight
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const {
|
|
85
|
+
layoutRef,
|
|
86
|
+
layoutStyle,
|
|
87
|
+
layoutProps
|
|
88
|
+
} = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
89
|
+
|
|
90
|
+
useNodesRef<View, _RichTextProps>(props, ref, nodeRef, {
|
|
91
|
+
layoutRef
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
const innerProps = useInnerProps(props, {
|
|
95
|
+
ref: nodeRef,
|
|
96
|
+
style: { ...normalStyle, ...layoutStyle },
|
|
97
|
+
...layoutProps
|
|
98
|
+
}, [], {
|
|
99
|
+
layoutRef
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
const html: string = typeof nodes === 'string' ? nodes : jsonToHtmlStr(nodes)
|
|
103
|
+
|
|
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>
|
|
116
|
+
)
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
_RichText.displayName = 'mpx-rich-text'
|
|
120
|
+
|
|
121
|
+
export default _RichText
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ✔ enable
|
|
3
3
|
*/
|
|
4
|
-
import { ReactNode } from 'react'
|
|
4
|
+
import { ReactNode, createElement, Fragment } from 'react'
|
|
5
5
|
import { Portal } from '@ant-design/react-native'
|
|
6
6
|
import { warn } from '@mpxjs/utils'
|
|
7
7
|
interface RootPortalProps {
|
|
@@ -16,10 +16,8 @@ const _RootPortal = (props: RootPortalProps) => {
|
|
|
16
16
|
warn('The root-portal component does not support the style prop.')
|
|
17
17
|
}
|
|
18
18
|
return enable
|
|
19
|
-
?
|
|
20
|
-
|
|
21
|
-
</Portal>
|
|
22
|
-
: <>{children}</>
|
|
19
|
+
? createElement(Portal, null, children)
|
|
20
|
+
: createElement(Fragment, null, children)
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
_RootPortal.displayName = 'MpxRootPortal'
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
*/
|
|
34
34
|
import { ScrollView } from 'react-native-gesture-handler'
|
|
35
35
|
import { View, RefreshControl, NativeSyntheticEvent, NativeScrollEvent, LayoutChangeEvent, ViewStyle } from 'react-native'
|
|
36
|
-
import { JSX, ReactNode, RefObject, useRef, useState, useEffect, forwardRef, useContext } from 'react'
|
|
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
|
-
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 {
|
|
@@ -165,7 +165,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
165
165
|
const initialTimeout = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
166
166
|
const intersectionObservers = useContext(IntersectionObserverContext)
|
|
167
167
|
|
|
168
|
-
const
|
|
168
|
+
const firstScrollIntoViewChange = useRef<boolean>(false)
|
|
169
169
|
|
|
170
170
|
const {
|
|
171
171
|
normalStyle,
|
|
@@ -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,
|
|
@@ -219,23 +220,28 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
219
220
|
}, [refresherTriggered])
|
|
220
221
|
|
|
221
222
|
useEffect(() => {
|
|
222
|
-
if (scrollIntoView && __selectRef
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
nodeRef.current?.measureLayout(
|
|
229
|
-
scrollViewRef.current,
|
|
230
|
-
(left: number, top:number) => {
|
|
231
|
-
scrollToOffset(left, top)
|
|
232
|
-
}
|
|
233
|
-
)
|
|
234
|
-
}
|
|
235
|
-
})
|
|
223
|
+
if (scrollIntoView && __selectRef) {
|
|
224
|
+
if (!firstScrollIntoViewChange.current) {
|
|
225
|
+
setTimeout(handleScrollIntoView)
|
|
226
|
+
} else {
|
|
227
|
+
handleScrollIntoView()
|
|
228
|
+
}
|
|
236
229
|
}
|
|
230
|
+
firstScrollIntoViewChange.current = true
|
|
237
231
|
}, [scrollIntoView])
|
|
238
232
|
|
|
233
|
+
function handleScrollIntoView () {
|
|
234
|
+
const refs = __selectRef!(`#${scrollIntoView}`, 'node')
|
|
235
|
+
if (!refs) return
|
|
236
|
+
const { nodeRef } = refs.getNodeInstance()
|
|
237
|
+
nodeRef.current?.measureLayout(
|
|
238
|
+
scrollViewRef.current,
|
|
239
|
+
(left: number, top:number) => {
|
|
240
|
+
scrollToOffset(left, top)
|
|
241
|
+
}
|
|
242
|
+
)
|
|
243
|
+
}
|
|
244
|
+
|
|
239
245
|
function selectLength (size: { height: number; width: number }) {
|
|
240
246
|
return !scrollX ? size.height : size.width
|
|
241
247
|
}
|
|
@@ -298,14 +304,13 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
298
304
|
const visibleLength = selectLength(e.nativeEvent.layoutMeasurement)
|
|
299
305
|
const contentLength = selectLength(e.nativeEvent.contentSize)
|
|
300
306
|
const offset = selectOffset(e.nativeEvent.contentOffset)
|
|
301
|
-
scrollOptions.current
|
|
302
|
-
...scrollOptions.current,
|
|
307
|
+
extendObject(scrollOptions.current, {
|
|
303
308
|
contentLength,
|
|
304
309
|
offset,
|
|
305
310
|
scrollLeft: position.scrollLeft,
|
|
306
311
|
scrollTop: position.scrollTop,
|
|
307
312
|
visibleLength
|
|
308
|
-
}
|
|
313
|
+
})
|
|
309
314
|
}
|
|
310
315
|
|
|
311
316
|
function onScroll (e: NativeSyntheticEvent<NativeScrollEvent>) {
|
|
@@ -426,34 +431,36 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
426
431
|
updateScrollOptions(e, { scrollLeft, scrollTop })
|
|
427
432
|
}
|
|
428
433
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
434
|
+
const scrollAdditionalProps: ScrollAdditionalProps = extendObject(
|
|
435
|
+
{
|
|
436
|
+
style: extendObject({}, innerStyle, layoutStyle),
|
|
437
|
+
pinchGestureEnabled: false,
|
|
438
|
+
horizontal: scrollX && !scrollY,
|
|
439
|
+
scrollEventThrottle: scrollEventThrottle,
|
|
440
|
+
scrollsToTop: enableBackToTop,
|
|
441
|
+
showsHorizontalScrollIndicator: scrollX && showScrollbar,
|
|
442
|
+
showsVerticalScrollIndicator: scrollY && showScrollbar,
|
|
443
|
+
scrollEnabled: scrollX || scrollY,
|
|
444
|
+
ref: scrollViewRef,
|
|
445
|
+
onScroll: onScroll,
|
|
446
|
+
onContentSizeChange: onContentSizeChange,
|
|
447
|
+
bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) && onScrollTouchStart,
|
|
448
|
+
bindtouchmove: ((enhanced && binddragging) || bindtouchend) && onScrollTouchMove,
|
|
449
|
+
bindtouchend: ((enhanced && binddragend) || bindtouchend) && onScrollTouchEnd,
|
|
450
|
+
onScrollBeginDrag: onScrollDrag,
|
|
451
|
+
onScrollEndDrag: onScrollDrag,
|
|
452
|
+
onMomentumScrollEnd: onScrollEnd
|
|
453
|
+
},
|
|
454
|
+
(simultaneousHandlers ? { simultaneousHandlers } : {}),
|
|
455
|
+
(waitForHandlers ? { waitFor: waitForHandlers } : {}),
|
|
456
|
+
layoutProps
|
|
457
|
+
)
|
|
458
|
+
|
|
451
459
|
if (enhanced) {
|
|
452
|
-
scrollAdditionalProps
|
|
453
|
-
...scrollAdditionalProps,
|
|
460
|
+
Object.assign(scrollAdditionalProps, {
|
|
454
461
|
bounces,
|
|
455
462
|
pagingEnabled
|
|
456
|
-
}
|
|
463
|
+
})
|
|
457
464
|
}
|
|
458
465
|
|
|
459
466
|
const innerProps = useInnerProps(props, scrollAdditionalProps, [
|
|
@@ -489,32 +496,26 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
489
496
|
white: ['#fff']
|
|
490
497
|
}
|
|
491
498
|
|
|
492
|
-
return (
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
refreshControl
|
|
496
|
-
? (
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
hasVarDec,
|
|
511
|
-
varContext: varContextRef.current,
|
|
512
|
-
textStyle,
|
|
513
|
-
textProps
|
|
514
|
-
}
|
|
515
|
-
)
|
|
499
|
+
return createElement(
|
|
500
|
+
ScrollView,
|
|
501
|
+
extendObject({}, innerProps, {
|
|
502
|
+
refreshControl: refresherEnabled
|
|
503
|
+
? createElement(RefreshControl, extendObject({
|
|
504
|
+
progressBackgroundColor: refresherBackground,
|
|
505
|
+
refreshing: refreshing,
|
|
506
|
+
onRefresh: onRefresh
|
|
507
|
+
}, (refresherDefaultStyle && refresherDefaultStyle !== 'none' ? { colors: refreshColor[refresherDefaultStyle] } : null)))
|
|
508
|
+
: undefined
|
|
509
|
+
}),
|
|
510
|
+
wrapChildren(
|
|
511
|
+
props,
|
|
512
|
+
{
|
|
513
|
+
hasVarDec,
|
|
514
|
+
varContext: varContextRef.current,
|
|
515
|
+
textStyle,
|
|
516
|
+
textProps
|
|
516
517
|
}
|
|
517
|
-
|
|
518
|
+
)
|
|
518
519
|
)
|
|
519
520
|
})
|
|
520
521
|
|
|
@@ -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布局信息
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* ✔ color
|
|
6
6
|
*/
|
|
7
7
|
import { Switch, SwitchProps, ViewStyle, NativeSyntheticEvent } from 'react-native'
|
|
8
|
-
import { useRef, useEffect, forwardRef, JSX, useState, useContext } from 'react'
|
|
8
|
+
import { useRef, useEffect, forwardRef, JSX, useState, useContext, createElement } from 'react'
|
|
9
9
|
import { warn } from '@mpxjs/utils'
|
|
10
10
|
import useNodesRef, { HandlerRef } from './useNodesRef' // 引入辅助函数
|
|
11
11
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
12
12
|
|
|
13
13
|
import CheckBox from './mpx-checkbox'
|
|
14
14
|
import { FormContext, FormFieldValue } from './context'
|
|
15
|
-
import { useTransformStyle, useLayout } from './utils'
|
|
15
|
+
import { useTransformStyle, useLayout, extendObject } from './utils'
|
|
16
16
|
|
|
17
17
|
interface _SwitchProps extends SwitchProps {
|
|
18
18
|
style?: ViewStyle
|
|
@@ -42,7 +42,6 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
|
|
|
42
42
|
'parent-font-size': parentFontSize,
|
|
43
43
|
'parent-width': parentWidth,
|
|
44
44
|
'parent-height': parentHeight,
|
|
45
|
-
|
|
46
45
|
bindchange,
|
|
47
46
|
catchchange
|
|
48
47
|
} = props
|
|
@@ -77,7 +76,9 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
|
|
|
77
76
|
}, [checked])
|
|
78
77
|
|
|
79
78
|
const nodeRef = useRef(null)
|
|
80
|
-
useNodesRef<Switch, _SwitchProps>(props, ref, nodeRef
|
|
79
|
+
useNodesRef<Switch, _SwitchProps>(props, ref, nodeRef, {
|
|
80
|
+
style: normalStyle
|
|
81
|
+
})
|
|
81
82
|
|
|
82
83
|
const {
|
|
83
84
|
layoutRef,
|
|
@@ -119,12 +120,13 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
|
|
|
119
120
|
}
|
|
120
121
|
}, [])
|
|
121
122
|
|
|
122
|
-
const innerProps = useInnerProps(props, {
|
|
123
|
+
const innerProps = useInnerProps(props, extendObject({
|
|
123
124
|
ref: nodeRef,
|
|
124
|
-
style: {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
125
|
+
style: extendObject({}, normalStyle, layoutStyle)
|
|
126
|
+
},
|
|
127
|
+
layoutProps,
|
|
128
|
+
!disabled ? { [type === 'switch' ? 'onValueChange' : '_onChange']: onChange } : {})
|
|
129
|
+
, [
|
|
128
130
|
'checked',
|
|
129
131
|
'disabled',
|
|
130
132
|
'type',
|
|
@@ -134,22 +136,26 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
|
|
|
134
136
|
})
|
|
135
137
|
|
|
136
138
|
if (type === 'checkbox') {
|
|
137
|
-
return
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
return createElement(
|
|
140
|
+
CheckBox,
|
|
141
|
+
extendObject({}, innerProps, {
|
|
142
|
+
color: color,
|
|
143
|
+
style: normalStyle,
|
|
144
|
+
checked: isChecked
|
|
145
|
+
})
|
|
146
|
+
)
|
|
143
147
|
}
|
|
144
148
|
|
|
145
|
-
return
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
return createElement(
|
|
150
|
+
Switch,
|
|
151
|
+
extendObject({}, innerProps, {
|
|
152
|
+
style: normalStyle,
|
|
153
|
+
value: isChecked,
|
|
154
|
+
trackColor: { false: '#FFF', true: color },
|
|
155
|
+
thumbColor: isChecked ? '#FFF' : '#f4f3f4',
|
|
156
|
+
ios_backgroundColor: '#FFF'
|
|
157
|
+
})
|
|
158
|
+
)
|
|
153
159
|
})
|
|
154
160
|
|
|
155
161
|
_Switch.displayName = 'MpxSwitch'
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ✘ decode
|
|
6
6
|
*/
|
|
7
7
|
import { Text, TextStyle, TextProps } from 'react-native'
|
|
8
|
-
import { useRef, forwardRef, ReactNode, JSX } from 'react'
|
|
8
|
+
import { useRef, forwardRef, ReactNode, JSX, createElement } from 'react'
|
|
9
9
|
import useInnerProps from './getInnerListeners'
|
|
10
10
|
import useNodesRef, { HandlerRef } from './useNodesRef' // 引入辅助函数
|
|
11
11
|
import { useTransformStyle, wrapChildren } from './utils'
|
|
@@ -25,6 +25,7 @@ interface _TextProps extends TextProps {
|
|
|
25
25
|
const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref): JSX.Element => {
|
|
26
26
|
const {
|
|
27
27
|
style = {},
|
|
28
|
+
allowFontScaling = false,
|
|
28
29
|
selectable,
|
|
29
30
|
'enable-var': enableVar,
|
|
30
31
|
'external-var-context': externalVarContext,
|
|
@@ -49,33 +50,28 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
|
|
|
49
50
|
})
|
|
50
51
|
|
|
51
52
|
const nodeRef = useRef(null)
|
|
52
|
-
useNodesRef<Text, _TextProps>(props, ref, nodeRef
|
|
53
|
+
useNodesRef<Text, _TextProps>(props, ref, nodeRef, {
|
|
54
|
+
style: normalStyle
|
|
55
|
+
})
|
|
53
56
|
|
|
54
57
|
const innerProps = useInnerProps(props, {
|
|
55
58
|
ref: nodeRef,
|
|
56
59
|
style: normalStyle,
|
|
57
|
-
selectable: !!selectable || !!userSelect
|
|
60
|
+
selectable: !!selectable || !!userSelect,
|
|
61
|
+
allowFontScaling
|
|
58
62
|
}, [
|
|
59
63
|
'user-select'
|
|
60
64
|
], {
|
|
61
65
|
layoutRef
|
|
62
66
|
})
|
|
63
67
|
|
|
64
|
-
return (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
{
|
|
72
|
-
hasVarDec,
|
|
73
|
-
varContext: varContextRef.current
|
|
74
|
-
}
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
</Text>
|
|
78
|
-
)
|
|
68
|
+
return createElement(Text, innerProps, wrapChildren(
|
|
69
|
+
props,
|
|
70
|
+
{
|
|
71
|
+
hasVarDec,
|
|
72
|
+
varContext: varContextRef.current
|
|
73
|
+
}
|
|
74
|
+
))
|
|
79
75
|
})
|
|
80
76
|
|
|
81
77
|
_Text.displayName = 'MpxText'
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
* ✘ show-confirm-bar
|
|
10
10
|
* ✔ bindlinechange: No `heightRpx` info.
|
|
11
11
|
*/
|
|
12
|
-
import { JSX, forwardRef } from 'react'
|
|
12
|
+
import { JSX, forwardRef, createElement } from 'react'
|
|
13
13
|
import { Keyboard, TextInput } from 'react-native'
|
|
14
14
|
import Input, { InputProps, PrivateInputProps } from './mpx-input'
|
|
15
|
-
import { omit } from './utils'
|
|
15
|
+
import { omit, extendObject } from './utils'
|
|
16
16
|
import { HandlerRef } from './useNodesRef'
|
|
17
17
|
|
|
18
18
|
export type TextareProps = Omit<
|
|
@@ -29,14 +29,15 @@ const Textarea = forwardRef<HandlerRef<TextInput, TextareProps>, TextareProps>(
|
|
|
29
29
|
'multiline',
|
|
30
30
|
'confirm-hold'
|
|
31
31
|
])
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
|
|
33
|
+
return createElement(
|
|
34
|
+
Input,
|
|
35
|
+
extendObject({
|
|
36
|
+
ref: ref,
|
|
37
|
+
multiline: true,
|
|
38
|
+
confirmType: 'next',
|
|
39
|
+
bindblur: () => Keyboard.dismiss()
|
|
40
|
+
}, restProps)
|
|
40
41
|
)
|
|
41
42
|
}
|
|
42
43
|
)
|