@mpxjs/webpack-plugin 2.9.69 → 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/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/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/processTemplate.js +3 -0
- package/lib/runtime/components/react/context.ts +4 -0
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/event.config.js +24 -24
- package/lib/runtime/components/react/dist/getInnerListeners.js +183 -166
- package/lib/runtime/components/react/dist/mpx-button.jsx +35 -42
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +2 -4
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +35 -13
- 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.jsx +3 -1
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +5 -3
- 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/carouse.jsx +4 -2
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
- 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 +34 -46
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +105 -42
- package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -10
- package/lib/runtime/components/react/dist/utils.jsx +107 -82
- package/lib/runtime/components/react/event.config.ts +25 -26
- package/lib/runtime/components/react/getInnerListeners.ts +238 -188
- package/lib/runtime/components/react/mpx-button.tsx +64 -50
- package/lib/runtime/components/react/mpx-canvas/html.ts +2 -4
- package/lib/runtime/components/react/mpx-canvas/index.tsx +46 -48
- 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 +4 -1
- package/lib/runtime/components/react/mpx-picker-view.tsx +7 -1
- 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 +55 -65
- package/lib/runtime/components/react/mpx-web-view.tsx +108 -63
- package/lib/runtime/components/react/types/global.d.ts +3 -17
- package/lib/runtime/components/react/useAnimationHooks.ts +36 -12
- package/lib/runtime/components/react/utils.tsx +113 -82
- 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 +77 -46
- package/lib/template-compiler/gen-node-react.js +2 -2
- package/lib/utils/pre-process-json.js +9 -5
- package/package.json +5 -4
- 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/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
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* ✔ bindlongtap
|
|
10
10
|
* ✔ binderror
|
|
11
11
|
*/
|
|
12
|
-
import React, { useRef, useState, useCallback, useEffect, forwardRef, JSX, TouchEvent, MutableRefObject } from 'react'
|
|
12
|
+
import React, { createElement, useRef, useState, useCallback, useEffect, forwardRef, JSX, TouchEvent, MutableRefObject } from 'react'
|
|
13
13
|
import { View, Platform, StyleSheet, NativeSyntheticEvent } from 'react-native'
|
|
14
14
|
import { WebView } from 'react-native-webview'
|
|
15
15
|
import useNodesRef, { HandlerRef } from '../useNodesRef'
|
|
@@ -73,7 +73,7 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
|
|
|
73
73
|
hasSelfPercent,
|
|
74
74
|
setWidth,
|
|
75
75
|
setHeight
|
|
76
|
-
} = useTransformStyle(extendObject(style, stylesheet.container), {
|
|
76
|
+
} = useTransformStyle(extendObject({}, style, stylesheet.container), {
|
|
77
77
|
enableVar,
|
|
78
78
|
externalVarContext,
|
|
79
79
|
parentFontSize,
|
|
@@ -93,7 +93,7 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
|
|
|
93
93
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
94
94
|
const innerProps = useInnerProps(props, {
|
|
95
95
|
ref: nodeRef,
|
|
96
|
-
style: extendObject(normalStyle, layoutStyle, { opacity: isLoaded ? 1 : 0 }),
|
|
96
|
+
style: extendObject({}, normalStyle, layoutStyle, { opacity: isLoaded ? 1 : 0 }),
|
|
97
97
|
...layoutProps
|
|
98
98
|
}, [], {
|
|
99
99
|
layoutRef
|
|
@@ -106,7 +106,11 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
|
|
|
106
106
|
useEffect(() => {
|
|
107
107
|
const webviewPostMessage = (message: WebviewMessage) => {
|
|
108
108
|
if (canvasRef.current.webview) {
|
|
109
|
-
|
|
109
|
+
const jsCode = `
|
|
110
|
+
window.mpxWebviewMessageCallback(${JSON.stringify(message)});
|
|
111
|
+
true;
|
|
112
|
+
`
|
|
113
|
+
canvasRef.current.webview.injectJavaScript(jsCode)
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
116
|
|
|
@@ -249,54 +253,48 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
|
|
|
249
253
|
|
|
250
254
|
if (Platform.OS === 'android') {
|
|
251
255
|
const isAndroid9 = Platform.Version >= 28
|
|
252
|
-
return (
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (canvasRef.current) {
|
|
257
|
-
canvasRef.current.webview = element
|
|
258
|
-
}
|
|
259
|
-
}}
|
|
260
|
-
style={[
|
|
261
|
-
isAndroid9 ? stylesheet.webviewAndroid9 : stylesheet.webview,
|
|
262
|
-
{ height, width }
|
|
263
|
-
]}
|
|
264
|
-
source={{ html }}
|
|
265
|
-
originWhitelist={originWhitelist}
|
|
266
|
-
onMessage={onMessage}
|
|
267
|
-
onLoad={onLoad}
|
|
268
|
-
overScrollMode="never"
|
|
269
|
-
mixedContentMode="always"
|
|
270
|
-
scalesPageToFit={false}
|
|
271
|
-
javaScriptEnabled
|
|
272
|
-
domStorageEnabled
|
|
273
|
-
thirdPartyCookiesEnabled
|
|
274
|
-
allowUniversalAccessFromFileURLs
|
|
275
|
-
/>
|
|
276
|
-
</View>
|
|
277
|
-
)
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return (
|
|
281
|
-
<View
|
|
282
|
-
{...innerProps}
|
|
283
|
-
>
|
|
284
|
-
<WebView
|
|
285
|
-
ref={(element) => {
|
|
256
|
+
return createElement(View, innerProps, createElement(
|
|
257
|
+
WebView,
|
|
258
|
+
{
|
|
259
|
+
ref: (element) => {
|
|
286
260
|
if (canvasRef.current) {
|
|
287
261
|
canvasRef.current.webview = element
|
|
288
262
|
}
|
|
289
|
-
}
|
|
290
|
-
style
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
263
|
+
},
|
|
264
|
+
style: [
|
|
265
|
+
isAndroid9 ? stylesheet.webviewAndroid9 : stylesheet.webview,
|
|
266
|
+
{ height, width }
|
|
267
|
+
],
|
|
268
|
+
source: { html },
|
|
269
|
+
originWhitelist: originWhitelist,
|
|
270
|
+
onMessage: onMessage,
|
|
271
|
+
onLoad: onLoad,
|
|
272
|
+
overScrollMode: 'never',
|
|
273
|
+
mixedContentMode: 'always',
|
|
274
|
+
scalesPageToFit: false,
|
|
275
|
+
javaScriptEnabled: true,
|
|
276
|
+
domStorageEnabled: true,
|
|
277
|
+
thirdPartyCookiesEnabled: true,
|
|
278
|
+
allowUniversalAccessFromFileURLs: true
|
|
279
|
+
})
|
|
280
|
+
)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return createElement(View, innerProps, createElement(WebView, {
|
|
284
|
+
ref: (element) => {
|
|
285
|
+
if (canvasRef.current) {
|
|
286
|
+
canvasRef.current.webview = element
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
style: [stylesheet.webview, { height, width }],
|
|
290
|
+
source: { html },
|
|
291
|
+
originWhitelist: originWhitelist,
|
|
292
|
+
onMessage: onMessage,
|
|
293
|
+
onLoad: onLoad,
|
|
294
|
+
scrollEnabled: false
|
|
295
|
+
}))
|
|
299
296
|
})
|
|
297
|
+
|
|
300
298
|
_Canvas.displayName = 'mpxCanvas'
|
|
301
299
|
|
|
302
300
|
export default _Canvas
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
ReactNode,
|
|
9
9
|
useContext,
|
|
10
10
|
useMemo,
|
|
11
|
-
useEffect
|
|
11
|
+
useEffect,
|
|
12
|
+
createElement
|
|
12
13
|
} from 'react'
|
|
13
14
|
import {
|
|
14
15
|
View,
|
|
@@ -19,7 +20,7 @@ import { warn } from '@mpxjs/utils'
|
|
|
19
20
|
import { FormContext, FormFieldValue, CheckboxGroupContext, GroupValue } from './context'
|
|
20
21
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
21
22
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
22
|
-
import { useLayout, useTransformStyle, wrapChildren } from './utils'
|
|
23
|
+
import { useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
|
|
23
24
|
|
|
24
25
|
export interface CheckboxGroupProps {
|
|
25
26
|
name: string
|
|
@@ -64,10 +65,7 @@ const CheckboxGroup = forwardRef<
|
|
|
64
65
|
flexWrap: 'wrap'
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
const styleObj = {
|
|
68
|
-
...defaultStyle,
|
|
69
|
-
...style
|
|
70
|
-
}
|
|
68
|
+
const styleObj = extendObject({}, defaultStyle, style)
|
|
71
69
|
|
|
72
70
|
const {
|
|
73
71
|
hasSelfPercent,
|
|
@@ -80,7 +78,7 @@ const CheckboxGroup = forwardRef<
|
|
|
80
78
|
|
|
81
79
|
const nodeRef = useRef(null)
|
|
82
80
|
|
|
83
|
-
useNodesRef(props, ref, nodeRef, {
|
|
81
|
+
useNodesRef(props, ref, nodeRef, { style: normalStyle })
|
|
84
82
|
|
|
85
83
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
86
84
|
|
|
@@ -119,12 +117,16 @@ const CheckboxGroup = forwardRef<
|
|
|
119
117
|
|
|
120
118
|
const innerProps = useInnerProps(
|
|
121
119
|
props,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
120
|
+
extendObject(
|
|
121
|
+
{
|
|
122
|
+
ref: nodeRef,
|
|
123
|
+
style: extendObject({}, normalStyle, layoutStyle)
|
|
124
|
+
},
|
|
125
|
+
layoutProps
|
|
126
|
+
),
|
|
127
|
+
[
|
|
128
|
+
'name'
|
|
129
|
+
],
|
|
128
130
|
{
|
|
129
131
|
layoutRef
|
|
130
132
|
}
|
|
@@ -155,20 +157,21 @@ const CheckboxGroup = forwardRef<
|
|
|
155
157
|
notifyChange
|
|
156
158
|
}
|
|
157
159
|
}, [])
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
|
|
161
|
+
return createElement(
|
|
162
|
+
View,
|
|
163
|
+
innerProps,
|
|
164
|
+
createElement(
|
|
165
|
+
CheckboxGroupContext.Provider,
|
|
166
|
+
{ value: contextValue },
|
|
167
|
+
wrapChildren(
|
|
168
|
+
props,
|
|
161
169
|
{
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
{
|
|
165
|
-
hasVarDec,
|
|
166
|
-
varContext: varContextRef.current
|
|
167
|
-
}
|
|
168
|
-
)
|
|
170
|
+
hasVarDec,
|
|
171
|
+
varContext: varContextRef.current
|
|
169
172
|
}
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
)
|
|
174
|
+
)
|
|
172
175
|
)
|
|
173
176
|
})
|
|
174
177
|
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
ReactNode,
|
|
14
14
|
useContext,
|
|
15
15
|
Dispatch,
|
|
16
|
-
SetStateAction
|
|
16
|
+
SetStateAction,
|
|
17
|
+
createElement
|
|
17
18
|
} from 'react'
|
|
18
19
|
import {
|
|
19
20
|
View,
|
|
@@ -25,7 +26,7 @@ import { warn } from '@mpxjs/utils'
|
|
|
25
26
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
26
27
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
27
28
|
import Icon from './mpx-icon'
|
|
28
|
-
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren } from './utils'
|
|
29
|
+
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
|
|
29
30
|
import { CheckboxGroupContext, LabelContext } from './context'
|
|
30
31
|
|
|
31
32
|
interface Selection {
|
|
@@ -46,7 +47,7 @@ export interface CheckboxProps extends Selection {
|
|
|
46
47
|
'parent-height'?: number;
|
|
47
48
|
children?: ReactNode
|
|
48
49
|
bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
|
|
49
|
-
|
|
50
|
+
_onChange?: (evt: NativeSyntheticEvent<TouchEvent> | unknown, { checked }: { checked: boolean }) => void
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
const styles = StyleSheet.create({
|
|
@@ -92,7 +93,7 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
92
93
|
'parent-width': parentWidth,
|
|
93
94
|
'parent-height': parentHeight,
|
|
94
95
|
bindtap,
|
|
95
|
-
|
|
96
|
+
_onChange
|
|
96
97
|
} = props
|
|
97
98
|
|
|
98
99
|
const [isChecked, setIsChecked] = useState<boolean>(!!checked)
|
|
@@ -101,15 +102,13 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
101
102
|
let groupValue: { [key: string]: { checked: boolean; setValue: Dispatch<SetStateAction<boolean>>; } } | undefined
|
|
102
103
|
let notifyChange: (evt: NativeSyntheticEvent<TouchEvent>) => void | undefined
|
|
103
104
|
|
|
104
|
-
const defaultStyle =
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
const defaultStyle = extendObject(
|
|
106
|
+
{},
|
|
107
|
+
styles.wrapper,
|
|
108
|
+
disabled ? styles.wrapperDisabled : null
|
|
109
|
+
)
|
|
108
110
|
|
|
109
|
-
const styleObj = {
|
|
110
|
-
...styles.container,
|
|
111
|
-
...style
|
|
112
|
-
}
|
|
111
|
+
const styleObj = extendObject({}, styles.container, style)
|
|
113
112
|
|
|
114
113
|
const onChange = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
115
114
|
if (disabled) return
|
|
@@ -119,20 +118,15 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
119
118
|
groupValue[value].checked = checked
|
|
120
119
|
}
|
|
121
120
|
notifyChange && notifyChange(evt)
|
|
121
|
+
// Called when the switch type attribute is checkbox
|
|
122
|
+
_onChange && _onChange(evt, { checked })
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
const onTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
125
|
-
if (disabled) return
|
|
126
126
|
bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props))
|
|
127
127
|
onChange(evt)
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
const catchTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
131
|
-
if (disabled) return
|
|
132
|
-
catchtap && catchtap(getCustomEvent('tap', evt, { layoutRef }, props))
|
|
133
|
-
onChange(evt)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
130
|
const {
|
|
137
131
|
hasSelfPercent,
|
|
138
132
|
normalStyle,
|
|
@@ -145,13 +139,13 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
145
139
|
const nodeRef = useRef(null)
|
|
146
140
|
|
|
147
141
|
useNodesRef(props, ref, nodeRef, {
|
|
148
|
-
defaultStyle,
|
|
142
|
+
style: extendObject({}, defaultStyle, normalStyle),
|
|
149
143
|
change: onChange
|
|
150
144
|
})
|
|
151
145
|
|
|
152
146
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
153
147
|
|
|
154
|
-
const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle)
|
|
148
|
+
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
155
149
|
|
|
156
150
|
if (backgroundStyle) {
|
|
157
151
|
warn('Checkbox does not support background image-related styles!')
|
|
@@ -170,14 +164,21 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
170
164
|
|
|
171
165
|
const innerProps = useInnerProps(
|
|
172
166
|
props,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
167
|
+
extendObject(
|
|
168
|
+
{
|
|
169
|
+
ref: nodeRef,
|
|
170
|
+
style: extendObject({}, innerStyle, layoutStyle)
|
|
171
|
+
},
|
|
172
|
+
layoutProps,
|
|
173
|
+
{
|
|
174
|
+
bindtap: !disabled && onTap
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
[
|
|
178
|
+
'value',
|
|
179
|
+
'disabled',
|
|
180
|
+
'checked'
|
|
181
|
+
],
|
|
181
182
|
{
|
|
182
183
|
layoutRef
|
|
183
184
|
}
|
|
@@ -206,28 +207,26 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
|
|
|
206
207
|
}
|
|
207
208
|
}, [checked])
|
|
208
209
|
|
|
209
|
-
return (
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
210
|
+
return createElement(View, innerProps,
|
|
211
|
+
createElement(
|
|
212
|
+
View,
|
|
213
|
+
{ style: defaultStyle },
|
|
214
|
+
createElement(Icon, {
|
|
215
|
+
type: 'success_no_circle',
|
|
216
|
+
size: 18,
|
|
217
|
+
color: disabled ? '#ADADAD' : color,
|
|
218
|
+
style: isChecked ? styles.iconChecked : styles.icon
|
|
219
|
+
})
|
|
220
|
+
),
|
|
221
|
+
wrapChildren(
|
|
222
|
+
props,
|
|
219
223
|
{
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
varContext: varContextRef.current,
|
|
225
|
-
textStyle,
|
|
226
|
-
textProps
|
|
227
|
-
}
|
|
228
|
-
)
|
|
224
|
+
hasVarDec,
|
|
225
|
+
varContext: varContextRef.current,
|
|
226
|
+
textStyle,
|
|
227
|
+
textProps
|
|
229
228
|
}
|
|
230
|
-
|
|
229
|
+
)
|
|
231
230
|
)
|
|
232
231
|
}
|
|
233
232
|
)
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* ✔ bindreset
|
|
6
6
|
*/
|
|
7
7
|
import { View } from 'react-native'
|
|
8
|
-
import { JSX, useRef, forwardRef, ReactNode, useMemo,
|
|
8
|
+
import { JSX, useRef, forwardRef, ReactNode, useMemo, createElement } from 'react'
|
|
9
9
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
10
10
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
11
11
|
import { FormContext } from './context'
|
|
12
|
-
import { useTransformStyle, splitProps, splitStyle, useLayout, wrapChildren } from './utils'
|
|
12
|
+
import { useTransformStyle, splitProps, splitStyle, useLayout, wrapChildren, extendObject } from './utils'
|
|
13
13
|
interface FormProps {
|
|
14
14
|
style?: Record<string, any>;
|
|
15
15
|
children?: ReactNode;
|
|
@@ -47,21 +47,23 @@ const _Form = forwardRef<HandlerRef<View, FormProps>, FormProps>((fromProps: For
|
|
|
47
47
|
setHeight
|
|
48
48
|
} = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
49
49
|
|
|
50
|
-
const { textStyle, innerStyle } = splitStyle(normalStyle)
|
|
50
|
+
const { textStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
51
51
|
|
|
52
52
|
const formRef = useRef(null)
|
|
53
|
-
useNodesRef(props, ref, formRef
|
|
53
|
+
useNodesRef(props, ref, formRef, {
|
|
54
|
+
style: normalStyle
|
|
55
|
+
})
|
|
54
56
|
|
|
55
57
|
const propsRef = useRef<FormProps>({})
|
|
56
58
|
propsRef.current = props
|
|
57
59
|
|
|
58
60
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: formRef })
|
|
59
61
|
|
|
60
|
-
const innerProps = useInnerProps(props, {
|
|
61
|
-
style: {
|
|
62
|
-
ref: formRef
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const innerProps = useInnerProps(props, extendObject({
|
|
63
|
+
style: extendObject({}, innerStyle, layoutStyle),
|
|
64
|
+
ref: formRef
|
|
65
|
+
}, layoutProps)
|
|
66
|
+
, [
|
|
65
67
|
'bindsubmit',
|
|
66
68
|
'bindreset'
|
|
67
69
|
], { layoutRef })
|
|
@@ -100,25 +102,20 @@ const _Form = forwardRef<HandlerRef<View, FormProps>, FormProps>((fromProps: For
|
|
|
100
102
|
reset
|
|
101
103
|
}
|
|
102
104
|
}, [])
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
)
|
|
118
|
-
}
|
|
119
|
-
</FormContext.Provider>
|
|
120
|
-
</View>
|
|
121
|
-
)
|
|
105
|
+
|
|
106
|
+
return createElement(View, innerProps, createElement(
|
|
107
|
+
FormContext.Provider,
|
|
108
|
+
{ value: contextValue },
|
|
109
|
+
wrapChildren(
|
|
110
|
+
props,
|
|
111
|
+
{
|
|
112
|
+
hasVarDec,
|
|
113
|
+
varContext: varContextRef.current,
|
|
114
|
+
textStyle,
|
|
115
|
+
textProps
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
))
|
|
122
119
|
})
|
|
123
120
|
|
|
124
121
|
_Form.displayName = 'MpxForm'
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* ✔ size
|
|
4
4
|
* ✔ color
|
|
5
5
|
*/
|
|
6
|
-
import { JSX, forwardRef, useRef } from 'react'
|
|
6
|
+
import { JSX, forwardRef, useRef, createElement } from 'react'
|
|
7
7
|
import { Text, TextStyle, Image } from 'react-native'
|
|
8
8
|
import useInnerProps from './getInnerListeners'
|
|
9
9
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
10
|
-
import { useLayout, useTransformStyle } from './utils'
|
|
10
|
+
import { useLayout, useTransformStyle, extendObject } from './utils'
|
|
11
11
|
|
|
12
12
|
export type IconType =
|
|
13
13
|
| 'success'
|
|
@@ -63,10 +63,7 @@ const Icon = forwardRef<HandlerRef<Text, IconProps>, IconProps>(
|
|
|
63
63
|
|
|
64
64
|
const defaultStyle = { width: ~~size, height: ~~size }
|
|
65
65
|
|
|
66
|
-
const styleObj = {
|
|
67
|
-
...defaultStyle,
|
|
68
|
-
...style
|
|
69
|
-
}
|
|
66
|
+
const styleObj = extendObject({}, defaultStyle, style)
|
|
70
67
|
|
|
71
68
|
const {
|
|
72
69
|
hasSelfPercent,
|
|
@@ -76,29 +73,27 @@ const Icon = forwardRef<HandlerRef<Text, IconProps>, IconProps>(
|
|
|
76
73
|
} = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
77
74
|
|
|
78
75
|
const nodeRef = useRef(null)
|
|
79
|
-
useNodesRef(props, ref, nodeRef, {
|
|
76
|
+
useNodesRef(props, ref, nodeRef, { style: normalStyle })
|
|
80
77
|
|
|
81
78
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
82
79
|
|
|
83
80
|
const innerProps = useInnerProps(
|
|
84
81
|
props,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
tintColor: color
|
|
82
|
+
extendObject(
|
|
83
|
+
{
|
|
84
|
+
ref: nodeRef,
|
|
85
|
+
source: { uri },
|
|
86
|
+
style: extendObject({}, normalStyle, layoutStyle, { tintColor: color })
|
|
91
87
|
},
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
},
|
|
88
|
+
layoutProps
|
|
89
|
+
),
|
|
95
90
|
[],
|
|
96
91
|
{
|
|
97
92
|
layoutRef
|
|
98
93
|
}
|
|
99
94
|
)
|
|
100
95
|
|
|
101
|
-
return
|
|
96
|
+
return createElement(Image, innerProps)
|
|
102
97
|
}
|
|
103
98
|
)
|
|
104
99
|
|