@mpxjs/webpack-plugin 2.9.70-alpha.0 → 2.9.70
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/LICENSE +433 -0
- package/README.md +1 -1
- package/lib/config.js +0 -14
- package/lib/dependencies/ResolveDependency.js +0 -5
- package/lib/index.js +7 -38
- package/lib/json-compiler/helper.js +3 -3
- package/lib/loader.js +0 -53
- package/lib/parser.js +1 -1
- package/lib/platform/json/wx/index.js +21 -8
- package/lib/platform/style/wx/index.js +51 -54
- package/lib/platform/template/wx/component-config/button.js +2 -14
- package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
- package/lib/platform/template/wx/component-config/image.js +0 -4
- package/lib/platform/template/wx/component-config/index.js +1 -1
- package/lib/platform/template/wx/component-config/input.js +0 -4
- package/lib/platform/template/wx/component-config/rich-text.js +6 -2
- package/lib/platform/template/wx/component-config/scroll-view.js +0 -4
- package/lib/platform/template/wx/component-config/switch.js +0 -4
- package/lib/platform/template/wx/component-config/text.js +0 -4
- package/lib/platform/template/wx/component-config/textarea.js +0 -5
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/platform/template/wx/component-config/view.js +0 -4
- package/lib/platform/template/wx/index.js +1 -127
- package/lib/resolve-loader.js +1 -4
- package/lib/runtime/components/react/dist/getInnerListeners.js +5 -6
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +2 -4
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +5 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +96 -107
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +26 -27
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +480 -0
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +68 -0
- package/lib/runtime/components/react/dist/mpx-swiper/type.js +1 -0
- package/lib/runtime/components/react/dist/mpx-view.jsx +6 -3
- package/lib/runtime/components/react/dist/pickerFaces.js +6 -12
- package/lib/runtime/components/react/dist/{pickerViewOverlay.jsx → pickerOverlay.jsx} +3 -5
- package/lib/runtime/components/react/dist/useAnimationHooks.js +7 -8
- package/lib/runtime/components/react/dist/utils.jsx +89 -60
- package/lib/runtime/components/react/event.config.ts +25 -26
- package/lib/runtime/components/react/getInnerListeners.ts +212 -169
- package/lib/runtime/components/react/mpx-button.tsx +9 -14
- package/lib/runtime/components/react/mpx-canvas/html.ts +2 -4
- package/lib/runtime/components/react/mpx-canvas/index.tsx +44 -46
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +15 -13
- package/lib/runtime/components/react/mpx-checkbox.tsx +20 -21
- package/lib/runtime/components/react/mpx-form.tsx +15 -20
- package/lib/runtime/components/react/mpx-icon.tsx +2 -2
- package/lib/runtime/components/react/mpx-image.tsx +87 -47
- package/lib/runtime/components/react/mpx-input.tsx +24 -32
- package/lib/runtime/components/react/mpx-label.tsx +12 -14
- package/lib/runtime/components/react/mpx-movable-area.tsx +10 -16
- package/lib/runtime/components/react/mpx-movable-view.tsx +20 -24
- package/lib/runtime/components/react/mpx-navigator.tsx +2 -8
- package/lib/runtime/components/react/mpx-radio-group.tsx +13 -15
- package/lib/runtime/components/react/mpx-radio.tsx +19 -25
- 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 +40 -41
- package/lib/runtime/components/react/mpx-switch.tsx +19 -15
- package/lib/runtime/components/react/mpx-text.tsx +8 -16
- package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
- package/lib/runtime/components/react/mpx-view.tsx +18 -20
- package/lib/runtime/components/react/mpx-web-view.tsx +94 -59
- package/lib/runtime/components/react/types/global.d.ts +2 -1
- package/lib/runtime/components/react/useAnimationHooks.ts +36 -12
- package/lib/runtime/components/react/utils.tsx +91 -60
- package/lib/runtime/components/web/mpx-web-view.vue +34 -20
- package/lib/runtime/optionProcessor.js +0 -22
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/scope-id.js +30 -2
- package/lib/template-compiler/compiler.js +30 -26
- package/lib/utils/env.js +1 -6
- package/lib/utils/pre-process-json.js +9 -5
- package/package.json +4 -7
- package/lib/dependencies/AddEntryDependency.js +0 -24
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +0 -39
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +0 -606
- package/lib/runtime/components/react/dist/pickerVIewContext.js +0 -9
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +0 -18
- package/lib/runtime/components/tenon/getInnerListeners.js +0 -334
- package/lib/runtime/components/tenon/tenon-button.vue +0 -309
- package/lib/runtime/components/tenon/tenon-image.vue +0 -66
- package/lib/runtime/components/tenon/tenon-input.vue +0 -171
- package/lib/runtime/components/tenon/tenon-rich-text.vue +0 -26
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +0 -127
- package/lib/runtime/components/tenon/tenon-switch.vue +0 -96
- package/lib/runtime/components/tenon/tenon-text.vue +0 -70
- package/lib/runtime/components/tenon/tenon-textarea.vue +0 -86
- package/lib/runtime/components/tenon/tenon-view.vue +0 -93
- package/lib/runtime/components/web/event.js +0 -105
- package/lib/runtime/optionProcessor.tenon.js +0 -84
- package/lib/style-compiler/plugins/hm.js +0 -20
- package/lib/tenon/index.js +0 -117
- package/lib/tenon/processJSON.js +0 -352
- package/lib/tenon/processScript.js +0 -203
- package/lib/tenon/processStyles.js +0 -21
- package/lib/tenon/processTemplate.js +0 -126
- package/lib/tenon/script-helper.js +0 -223
- package/lib/utils/get-relative-path.js +0 -25
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* ✔ checked
|
|
5
5
|
* ✔ color
|
|
6
6
|
*/
|
|
7
|
-
import { JSX, useRef, useState, forwardRef, useEffect, ReactNode, useContext, Dispatch, SetStateAction } from 'react'
|
|
7
|
+
import { JSX, useRef, useState, forwardRef, useEffect, ReactNode, useContext, Dispatch, SetStateAction, createElement } from 'react'
|
|
8
8
|
import { View, StyleSheet, ViewStyle, NativeSyntheticEvent } from 'react-native'
|
|
9
9
|
import { warn } from '@mpxjs/utils'
|
|
10
10
|
import { LabelContext, RadioGroupContext } from './context'
|
|
@@ -193,32 +193,26 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
|
|
|
193
193
|
}
|
|
194
194
|
}, [checked])
|
|
195
195
|
|
|
196
|
-
return (
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
</View>
|
|
196
|
+
return createElement(View, innerProps,
|
|
197
|
+
createElement(
|
|
198
|
+
View,
|
|
199
|
+
{ style: defaultStyle },
|
|
200
|
+
createElement(Icon, {
|
|
201
|
+
type: 'success',
|
|
202
|
+
size: 24,
|
|
203
|
+
color: disabled ? '#E1E1E1' : color,
|
|
204
|
+
style: extendObject({}, styles.icon, isChecked && styles.iconChecked, disabled && styles.iconDisabled)
|
|
205
|
+
})
|
|
206
|
+
),
|
|
207
|
+
wrapChildren(
|
|
208
|
+
props,
|
|
210
209
|
{
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
varContext: varContextRef.current,
|
|
216
|
-
textStyle,
|
|
217
|
-
textProps
|
|
218
|
-
}
|
|
219
|
-
)
|
|
210
|
+
hasVarDec,
|
|
211
|
+
varContext: varContextRef.current,
|
|
212
|
+
textStyle,
|
|
213
|
+
textProps
|
|
220
214
|
}
|
|
221
|
-
|
|
215
|
+
)
|
|
222
216
|
)
|
|
223
217
|
}
|
|
224
218
|
)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
export const generateHTML = (html: string) => {
|
|
3
|
+
return `<html><head>
|
|
4
|
+
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scaleable=no" name="viewport">
|
|
5
|
+
<style>
|
|
6
|
+
html {
|
|
7
|
+
-ms-content-zooming: none;
|
|
8
|
+
-ms-touch-action: pan-x pan-y;
|
|
9
|
+
}
|
|
10
|
+
body {
|
|
11
|
+
position: fixed;
|
|
12
|
+
top: 0;
|
|
13
|
+
right: 0;
|
|
14
|
+
bottom: 0;
|
|
15
|
+
left: 0;
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
}
|
|
18
|
+
html,body {
|
|
19
|
+
margin: 0;
|
|
20
|
+
padding: 0;
|
|
21
|
+
}
|
|
22
|
+
* {
|
|
23
|
+
user-select: none;
|
|
24
|
+
-ms-user-select: none;
|
|
25
|
+
-moz-user-select: none;
|
|
26
|
+
-webkit-user-select: none;
|
|
27
|
+
}
|
|
28
|
+
</style>
|
|
29
|
+
</head>
|
|
30
|
+
<body><div id="rich-text">${html}</div>
|
|
31
|
+
<script>
|
|
32
|
+
function sendHeight() {
|
|
33
|
+
const dom = document.getElementById('rich-text')
|
|
34
|
+
window.ReactNativeWebView.postMessage(dom.scrollHeight);
|
|
35
|
+
}
|
|
36
|
+
window.onload = sendHeight;
|
|
37
|
+
</script>
|
|
38
|
+
</body
|
|
39
|
+
></html>`
|
|
40
|
+
}
|
|
@@ -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,7 +33,7 @@
|
|
|
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'
|
|
@@ -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,
|
|
@@ -220,23 +220,28 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
220
220
|
}, [refresherTriggered])
|
|
221
221
|
|
|
222
222
|
useEffect(() => {
|
|
223
|
-
if (scrollIntoView && __selectRef
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
nodeRef.current?.measureLayout(
|
|
230
|
-
scrollViewRef.current,
|
|
231
|
-
(left: number, top:number) => {
|
|
232
|
-
scrollToOffset(left, top)
|
|
233
|
-
}
|
|
234
|
-
)
|
|
235
|
-
}
|
|
236
|
-
})
|
|
223
|
+
if (scrollIntoView && __selectRef) {
|
|
224
|
+
if (!firstScrollIntoViewChange.current) {
|
|
225
|
+
setTimeout(handleScrollIntoView)
|
|
226
|
+
} else {
|
|
227
|
+
handleScrollIntoView()
|
|
228
|
+
}
|
|
237
229
|
}
|
|
230
|
+
firstScrollIntoViewChange.current = true
|
|
238
231
|
}, [scrollIntoView])
|
|
239
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
|
+
|
|
240
245
|
function selectLength (size: { height: number; width: number }) {
|
|
241
246
|
return !scrollX ? size.height : size.width
|
|
242
247
|
}
|
|
@@ -491,32 +496,26 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
491
496
|
white: ['#fff']
|
|
492
497
|
}
|
|
493
498
|
|
|
494
|
-
return (
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
refreshControl
|
|
498
|
-
? (
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
hasVarDec,
|
|
513
|
-
varContext: varContextRef.current,
|
|
514
|
-
textStyle,
|
|
515
|
-
textProps
|
|
516
|
-
}
|
|
517
|
-
)
|
|
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
|
|
518
517
|
}
|
|
519
|
-
|
|
518
|
+
)
|
|
520
519
|
)
|
|
521
520
|
})
|
|
522
521
|
|
|
@@ -5,7 +5,7 @@
|
|
|
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'
|
|
@@ -136,22 +136,26 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
|
|
|
136
136
|
})
|
|
137
137
|
|
|
138
138
|
if (type === 'checkbox') {
|
|
139
|
-
return
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
139
|
+
return createElement(
|
|
140
|
+
CheckBox,
|
|
141
|
+
extendObject({}, innerProps, {
|
|
142
|
+
color: color,
|
|
143
|
+
style: normalStyle,
|
|
144
|
+
checked: isChecked
|
|
145
|
+
})
|
|
146
|
+
)
|
|
145
147
|
}
|
|
146
148
|
|
|
147
|
-
return
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
+
)
|
|
155
159
|
})
|
|
156
160
|
|
|
157
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'
|
|
@@ -65,21 +65,13 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
|
|
|
65
65
|
layoutRef
|
|
66
66
|
})
|
|
67
67
|
|
|
68
|
-
return (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
{
|
|
76
|
-
hasVarDec,
|
|
77
|
-
varContext: varContextRef.current
|
|
78
|
-
}
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
</Text>
|
|
82
|
-
)
|
|
68
|
+
return createElement(Text, innerProps, wrapChildren(
|
|
69
|
+
props,
|
|
70
|
+
{
|
|
71
|
+
hasVarDec,
|
|
72
|
+
varContext: varContextRef.current
|
|
73
|
+
}
|
|
74
|
+
))
|
|
83
75
|
})
|
|
84
76
|
|
|
85
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
|
)
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ✔ hover-stay-time
|
|
6
6
|
*/
|
|
7
7
|
import { View, TextStyle, NativeSyntheticEvent, ViewProps, ImageStyle, StyleSheet, Image, LayoutChangeEvent } from 'react-native'
|
|
8
|
-
import { useRef, useState, useEffect, forwardRef, ReactNode, JSX } from 'react'
|
|
8
|
+
import { useRef, useState, useEffect, forwardRef, ReactNode, JSX, createElement } from 'react'
|
|
9
9
|
import useInnerProps from './getInnerListeners'
|
|
10
10
|
import Animated from 'react-native-reanimated'
|
|
11
11
|
import useAnimationHooks from './useAnimationHooks'
|
|
@@ -13,6 +13,7 @@ import type { AnimationProp } from './useAnimationHooks'
|
|
|
13
13
|
import { ExtendedViewStyle } from './types/common'
|
|
14
14
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
15
15
|
import { parseUrl, PERCENT_REGEX, splitStyle, splitProps, useTransformStyle, wrapChildren, useLayout, renderImage, pickStyle, extendObject } from './utils'
|
|
16
|
+
import { error } from '@mpxjs/utils'
|
|
16
17
|
import LinearGradient from 'react-native-linear-gradient'
|
|
17
18
|
|
|
18
19
|
export interface _ViewProps extends ViewProps {
|
|
@@ -550,7 +551,7 @@ function inheritStyle (innerStyle: ExtendedViewStyle = {}) {
|
|
|
550
551
|
: undefined)
|
|
551
552
|
}
|
|
552
553
|
|
|
553
|
-
function
|
|
554
|
+
function useWrapImage (imageStyle?: ExtendedViewStyle, innerStyle?: Record<string, any>, enableFastImage?: boolean) {
|
|
554
555
|
// 预处理数据
|
|
555
556
|
const preImageInfo: PreImageInfo = preParseImage(imageStyle)
|
|
556
557
|
// 预解析
|
|
@@ -659,7 +660,8 @@ function wrapWithChildren (props: _ViewProps, { hasVarDec, enableBackground, tex
|
|
|
659
660
|
})
|
|
660
661
|
|
|
661
662
|
return [
|
|
662
|
-
|
|
663
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
664
|
+
enableBackground ? useWrapImage(backgroundStyle, innerStyle, enableFastImage) : null,
|
|
663
665
|
children
|
|
664
666
|
]
|
|
665
667
|
}
|
|
@@ -716,7 +718,7 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
|
|
|
716
718
|
enableBackground = enableBackground || !!backgroundStyle
|
|
717
719
|
const enableBackgroundRef = useRef(enableBackground)
|
|
718
720
|
if (enableBackgroundRef.current !== enableBackground) {
|
|
719
|
-
|
|
721
|
+
error('[Mpx runtime error]: background use should be stable in the component lifecycle, or you can set [enable-background] with true.')
|
|
720
722
|
}
|
|
721
723
|
|
|
722
724
|
const nodeRef = useRef(null)
|
|
@@ -774,13 +776,16 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
|
|
|
774
776
|
enableAnimation = enableAnimation || !!animation
|
|
775
777
|
const enableAnimationRef = useRef(enableAnimation)
|
|
776
778
|
if (enableAnimationRef.current !== enableAnimation) {
|
|
777
|
-
|
|
779
|
+
error('[Mpx runtime error]: animation use should be stable in the component lifecycle, or you can set [enable-animation] with true.')
|
|
778
780
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
781
|
+
|
|
782
|
+
const finalStyle = enableAnimationRef.current
|
|
783
|
+
? [viewStyle,
|
|
784
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
785
|
+
useAnimationHooks({
|
|
786
|
+
animation,
|
|
787
|
+
style: viewStyle
|
|
788
|
+
})]
|
|
784
789
|
: viewStyle
|
|
785
790
|
const innerProps = useInnerProps(
|
|
786
791
|
props,
|
|
@@ -814,17 +819,10 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
|
|
|
814
819
|
innerStyle,
|
|
815
820
|
enableFastImage
|
|
816
821
|
})
|
|
822
|
+
|
|
817
823
|
return enableAnimation
|
|
818
|
-
? (
|
|
819
|
-
|
|
820
|
-
>
|
|
821
|
-
{childNode}
|
|
822
|
-
</Animated.View>)
|
|
823
|
-
: (<View
|
|
824
|
-
{...innerProps}
|
|
825
|
-
>
|
|
826
|
-
{childNode}
|
|
827
|
-
</View>)
|
|
824
|
+
? createElement(Animated.View, innerProps, childNode)
|
|
825
|
+
: createElement(View, innerProps, childNode)
|
|
828
826
|
})
|
|
829
827
|
|
|
830
828
|
_View.displayName = 'MpxView'
|