@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.
Files changed (140) hide show
  1. package/lib/index.js +13 -8
  2. package/lib/platform/json/wx/index.js +21 -8
  3. package/lib/platform/style/wx/index.js +35 -38
  4. package/lib/platform/template/wx/component-config/canvas.js +8 -0
  5. package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
  6. package/lib/platform/template/wx/component-config/index.js +1 -1
  7. package/lib/platform/template/wx/component-config/input.js +1 -1
  8. package/lib/platform/template/wx/component-config/rich-text.js +8 -0
  9. package/lib/platform/template/wx/component-config/swiper.js +1 -1
  10. package/lib/platform/template/wx/component-config/textarea.js +1 -1
  11. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  12. package/lib/react/processStyles.js +14 -4
  13. package/lib/react/processTemplate.js +3 -0
  14. package/lib/resolver/AddModePlugin.js +8 -8
  15. package/lib/runtime/components/react/context.ts +6 -0
  16. package/lib/runtime/components/react/dist/context.js +2 -0
  17. package/lib/runtime/components/react/dist/event.config.js +24 -24
  18. package/lib/runtime/components/react/dist/getInnerListeners.js +183 -174
  19. package/lib/runtime/components/react/dist/mpx-button.jsx +77 -49
  20. package/lib/runtime/components/react/dist/mpx-canvas/Bus.js +60 -0
  21. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.js +15 -0
  22. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.js +84 -0
  23. package/lib/runtime/components/react/dist/mpx-canvas/Image.js +87 -0
  24. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.js +15 -0
  25. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.js +28 -0
  26. package/lib/runtime/components/react/dist/mpx-canvas/html.js +343 -0
  27. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +232 -0
  28. package/lib/runtime/components/react/dist/mpx-canvas/utils.jsx +89 -0
  29. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
  30. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
  31. package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
  32. package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
  33. package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
  34. package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
  35. package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
  36. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
  37. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
  38. package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
  39. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
  40. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
  41. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
  42. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
  43. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
  44. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
  45. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
  46. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +160 -88
  47. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +80 -121
  48. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
  49. package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
  50. package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
  51. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
  52. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
  53. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
  54. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
  55. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
  56. package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
  57. package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
  58. package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
  59. package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
  60. package/lib/runtime/components/react/dist/mpx-view.jsx +65 -61
  61. package/lib/runtime/components/react/dist/mpx-web-view.jsx +112 -35
  62. package/lib/runtime/components/react/dist/pickerFaces.js +81 -0
  63. package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
  64. package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
  65. package/lib/runtime/components/react/dist/pickerViewOverlay.jsx +23 -0
  66. package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -9
  67. package/lib/runtime/components/react/dist/utils.jsx +70 -23
  68. package/lib/runtime/components/react/event.config.ts +25 -26
  69. package/lib/runtime/components/react/getInnerListeners.ts +237 -199
  70. package/lib/runtime/components/react/mpx-button.tsx +104 -57
  71. package/lib/runtime/components/react/mpx-canvas/Bus.ts +70 -0
  72. package/lib/runtime/components/react/mpx-canvas/CanvasGradient.ts +18 -0
  73. package/lib/runtime/components/react/mpx-canvas/CanvasRenderingContext2D.ts +87 -0
  74. package/lib/runtime/components/react/mpx-canvas/Image.ts +102 -0
  75. package/lib/runtime/components/react/mpx-canvas/ImageData.ts +23 -0
  76. package/lib/runtime/components/react/mpx-canvas/constructorsRegistry.ts +38 -0
  77. package/lib/runtime/components/react/mpx-canvas/html.ts +343 -0
  78. package/lib/runtime/components/react/mpx-canvas/index.tsx +296 -0
  79. package/lib/runtime/components/react/mpx-canvas/utils.tsx +150 -0
  80. package/lib/runtime/components/react/mpx-checkbox-group.tsx +28 -25
  81. package/lib/runtime/components/react/mpx-checkbox.tsx +48 -49
  82. package/lib/runtime/components/react/mpx-form.tsx +25 -28
  83. package/lib/runtime/components/react/mpx-icon.tsx +12 -17
  84. package/lib/runtime/components/react/mpx-image.tsx +436 -0
  85. package/lib/runtime/components/react/mpx-input.tsx +77 -57
  86. package/lib/runtime/components/react/mpx-label.tsx +26 -27
  87. package/lib/runtime/components/react/mpx-movable-area.tsx +18 -23
  88. package/lib/runtime/components/react/mpx-movable-view.tsx +21 -25
  89. package/lib/runtime/components/react/mpx-navigator.tsx +2 -8
  90. package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
  91. package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
  92. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
  93. package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
  94. package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
  95. package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
  96. package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
  97. package/lib/runtime/components/react/mpx-picker-view-column.tsx +236 -104
  98. package/lib/runtime/components/react/mpx-picker-view.tsx +132 -122
  99. package/lib/runtime/components/react/mpx-radio-group.tsx +24 -27
  100. package/lib/runtime/components/react/mpx-radio.tsx +45 -54
  101. package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
  102. package/lib/runtime/components/react/mpx-rich-text/index.tsx +121 -0
  103. package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
  104. package/lib/runtime/components/react/mpx-scroll-view.tsx +72 -71
  105. package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
  106. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
  107. package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
  108. package/lib/runtime/components/react/mpx-switch.tsx +29 -23
  109. package/lib/runtime/components/react/mpx-text.tsx +14 -18
  110. package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
  111. package/lib/runtime/components/react/mpx-view.tsx +92 -76
  112. package/lib/runtime/components/react/mpx-web-view.tsx +116 -54
  113. package/lib/runtime/components/react/pickerFaces.ts +104 -0
  114. package/lib/runtime/components/react/pickerOverlay.tsx +32 -0
  115. package/lib/runtime/components/react/types/common.ts +2 -0
  116. package/lib/runtime/components/react/types/global.d.ts +5 -17
  117. package/lib/runtime/components/react/useAnimationHooks.ts +36 -11
  118. package/lib/runtime/components/react/utils.tsx +99 -28
  119. package/lib/runtime/components/web/getInnerListeners.js +6 -6
  120. package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
  121. package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
  122. package/lib/runtime/components/web/mpx-picker.vue +382 -385
  123. package/lib/runtime/components/web/mpx-web-view.vue +175 -161
  124. package/lib/runtime/optionProcessor.js +7 -38
  125. package/lib/runtime/utils.js +2 -0
  126. package/lib/style-compiler/plugins/scope-id.js +30 -2
  127. package/lib/template-compiler/bind-this.js +7 -2
  128. package/lib/template-compiler/compiler.js +79 -47
  129. package/lib/template-compiler/gen-node-react.js +3 -3
  130. package/lib/utils/pre-process-json.js +9 -5
  131. package/package.json +6 -4
  132. package/LICENSE +0 -433
  133. package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
  134. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
  135. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -478
  136. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
  137. package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
  138. package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
  139. package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
  140. package/lib/runtime/components/web/event.js +0 -105
@@ -0,0 +1,150 @@
1
+ import { useEffect, useRef } from 'react'
2
+ import { WebView } from 'react-native-webview'
3
+ import Bus from './Bus'
4
+
5
+ export const WEBVIEW_TARGET = '@@WEBVIEW_TARGET'
6
+
7
+ export const constructors: Record<string, any> = {}
8
+
9
+ export const ID = () => Math.random().toString(32).slice(2)
10
+
11
+ const SPECIAL_CONSTRUCTOR: Record<string, { className: string, paramNum: number }> = {
12
+ ImageData: {
13
+ className: 'Uint8ClampedArray',
14
+ paramNum: 0
15
+ }
16
+ }
17
+
18
+ export interface Instance {
19
+ postMessage: (...args: any[]) => void;
20
+ [WEBVIEW_TARGET]?: string;
21
+ [key: string]: any;
22
+ }
23
+
24
+ export interface WebviewConstructor {
25
+ new (...args: any[]): Instance;
26
+ constructLocally?: (...args: unknown[]) => Instance;
27
+ }
28
+
29
+ export interface WebviewMessage {
30
+ type: 'set' | 'exec' | 'listen' | 'event' | 'construct'
31
+ payload: {
32
+ target?: string | { [key: string]: any }
33
+ key?: string
34
+ value?: any
35
+ method?: string
36
+ args?: any[]
37
+ types?: string[]
38
+ type?: string
39
+ constructor?: string | Function
40
+ id?: string
41
+ }
42
+ }
43
+
44
+ export interface CanvasInstance {
45
+ webview: WebView | null;
46
+ bus: Bus | null;
47
+ context2D: CanvasRenderingContext2D;
48
+ getContext: (contextType: string) => CanvasRenderingContext2D | null;
49
+ createImage: (width?: number, height?: number) => any;
50
+ postMessage: (message: WebviewMessage) => Promise<any>;
51
+ listeners: Array<(payload: any) => void>;
52
+ addMessageListener: (listener: (payload: any) => void) => () => void;
53
+ removeMessageListener: (listener: (payload: any) => void) => void;
54
+ createImageData: (dataArray: number[], width?: number, height?: number) => any;
55
+ }
56
+
57
+ export const registerWebviewTarget = (instance: Instance, targetName: string): void => {
58
+ instance[WEBVIEW_TARGET] = targetName
59
+ }
60
+
61
+ export const registerWebviewProperties = (instance: Instance, properties: Record<string, any>): void => {
62
+ Object.entries(properties).forEach(([key, initialValue]) => {
63
+ const privateKey = `__${key}__`
64
+ instance[privateKey] = initialValue
65
+ Object.defineProperty(instance, key, {
66
+ configurable: true,
67
+ enumerable: true,
68
+ get () {
69
+ return instance[privateKey]
70
+ },
71
+ set (value) {
72
+ instance.postMessage({
73
+ type: 'set',
74
+ payload: {
75
+ target: instance[WEBVIEW_TARGET],
76
+ key,
77
+ value
78
+ }
79
+ })
80
+
81
+ if (instance.forceUpdate) {
82
+ instance.forceUpdate()
83
+ }
84
+ return (instance[privateKey] = value)
85
+ }
86
+ })
87
+ })
88
+ }
89
+
90
+ export const registerWebviewMethods = (instance: Instance, methods: string[]): void => {
91
+ methods.forEach(method => {
92
+ instance[method] = (...args: any[]) => {
93
+ return instance.postMessage({
94
+ type: 'exec',
95
+ payload: {
96
+ target: instance[WEBVIEW_TARGET],
97
+ method,
98
+ args
99
+ }
100
+ })
101
+ }
102
+ })
103
+ }
104
+
105
+ export const registerWebviewConstructor = (constructor: WebviewConstructor, constructorName: string): void => {
106
+ constructors[constructorName] = constructor
107
+ constructor.constructLocally = function (...args: unknown[]): Instance {
108
+ return new (constructor as any)(...args, true)
109
+ }
110
+
111
+ constructor.prototype.onConstruction = function (...args: any[]): void {
112
+ if (SPECIAL_CONSTRUCTOR[constructorName] !== undefined) {
113
+ const { className, paramNum } = SPECIAL_CONSTRUCTOR[constructorName]
114
+ args[paramNum] = { className, classArgs: [args[paramNum]] }
115
+ }
116
+ this[WEBVIEW_TARGET] = ID()
117
+ this.postMessage({
118
+ type: 'construct',
119
+ payload: {
120
+ constructor: constructorName,
121
+ id: this[WEBVIEW_TARGET],
122
+ args
123
+ }
124
+ })
125
+ }
126
+ constructor.prototype.toJSON = function () {
127
+ return { __ref__: this[WEBVIEW_TARGET] }
128
+ }
129
+ }
130
+ export const useWebviewBinding = ({
131
+ targetName,
132
+ properties = {},
133
+ methods = []
134
+ }: {
135
+ targetName: string;
136
+ properties?: Record<string, any>;
137
+ methods?: string[]
138
+ }) => {
139
+ const instanceRef = useRef({})
140
+
141
+ useEffect(() => {
142
+ if (instanceRef.current) {
143
+ registerWebviewTarget(instanceRef.current as Instance, targetName)
144
+ registerWebviewProperties(instanceRef.current as Instance, properties)
145
+ registerWebviewMethods(instanceRef.current as Instance, methods)
146
+ }
147
+ }, [])
148
+
149
+ return instanceRef
150
+ }
@@ -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, { defaultStyle })
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
- ref: nodeRef,
124
- style: { ...normalStyle, ...layoutStyle },
125
- ...layoutProps
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
- return (
159
- <View {...innerProps}>
160
- <CheckboxGroupContext.Provider value={contextValue}>
160
+
161
+ return createElement(
162
+ View,
163
+ innerProps,
164
+ createElement(
165
+ CheckboxGroupContext.Provider,
166
+ { value: contextValue },
167
+ wrapChildren(
168
+ props,
161
169
  {
162
- wrapChildren(
163
- props,
164
- {
165
- hasVarDec,
166
- varContext: varContextRef.current
167
- }
168
- )
170
+ hasVarDec,
171
+ varContext: varContextRef.current
169
172
  }
170
- </CheckboxGroupContext.Provider>
171
- </View>
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
- catchtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
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
- catchtap
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
- ...styles.wrapper,
106
- ...(disabled && styles.wrapperDisabled)
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
- ref: nodeRef,
175
- style: { ...innerStyle, ...layoutStyle },
176
- ...layoutProps,
177
- bindtap: onTap,
178
- catchtap: catchTap
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
- <View {...innerProps}>
211
- <View style={defaultStyle}>
212
- <Icon
213
- type='success_no_circle'
214
- size={18}
215
- color={disabled ? '#ADADAD' : color}
216
- style={isChecked ? styles.iconChecked : styles.icon}
217
- />
218
- </View>
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
- wrapChildren(
221
- props,
222
- {
223
- hasVarDec,
224
- varContext: varContextRef.current,
225
- textStyle,
226
- textProps
227
- }
228
- )
224
+ hasVarDec,
225
+ varContext: varContextRef.current,
226
+ textStyle,
227
+ textProps
229
228
  }
230
- </View>
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, useCallback } from 'react'
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: { ...innerStyle, ...layoutStyle },
62
- ref: formRef,
63
- ...layoutProps
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
- return (
104
- <View
105
- {...innerProps}
106
- >
107
- <FormContext.Provider value={contextValue}>
108
- {
109
- wrapChildren(
110
- props,
111
- {
112
- hasVarDec,
113
- varContext: varContextRef.current,
114
- textStyle,
115
- textProps
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, { defaultStyle })
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
- ref: nodeRef,
87
- style: {
88
- ...normalStyle,
89
- ...layoutStyle,
90
- tintColor: color
82
+ extendObject(
83
+ {
84
+ ref: nodeRef,
85
+ source: { uri },
86
+ style: extendObject({}, normalStyle, layoutStyle, { tintColor: color })
91
87
  },
92
- source: { uri },
93
- ...layoutProps
94
- },
88
+ layoutProps
89
+ ),
95
90
  [],
96
91
  {
97
92
  layoutRef
98
93
  }
99
94
  )
100
95
 
101
- return <Image {...innerProps} />
96
+ return createElement(Image, innerProps)
102
97
  }
103
98
  )
104
99