@mpxjs/webpack-plugin 2.9.69 → 2.9.70-alpha.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 (138) hide show
  1. package/README.md +1 -1
  2. package/lib/config.js +14 -0
  3. package/lib/dependencies/AddEntryDependency.js +24 -0
  4. package/lib/dependencies/ResolveDependency.js +5 -0
  5. package/lib/index.js +38 -7
  6. package/lib/json-compiler/helper.js +3 -3
  7. package/lib/loader.js +53 -0
  8. package/lib/platform/template/wx/component-config/button.js +14 -2
  9. package/lib/platform/template/wx/component-config/image.js +4 -0
  10. package/lib/platform/template/wx/component-config/input.js +5 -1
  11. package/lib/platform/template/wx/component-config/rich-text.js +4 -0
  12. package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
  13. package/lib/platform/template/wx/component-config/swiper.js +1 -1
  14. package/lib/platform/template/wx/component-config/switch.js +4 -0
  15. package/lib/platform/template/wx/component-config/text.js +4 -0
  16. package/lib/platform/template/wx/component-config/textarea.js +6 -1
  17. package/lib/platform/template/wx/component-config/view.js +4 -0
  18. package/lib/platform/template/wx/index.js +127 -1
  19. package/lib/react/processTemplate.js +3 -0
  20. package/lib/resolve-loader.js +4 -1
  21. package/lib/runtime/components/react/context.ts +4 -0
  22. package/lib/runtime/components/react/dist/context.js +1 -0
  23. package/lib/runtime/components/react/dist/event.config.js +24 -24
  24. package/lib/runtime/components/react/dist/getInnerListeners.js +183 -165
  25. package/lib/runtime/components/react/dist/mpx-button.jsx +35 -42
  26. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +30 -12
  27. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
  28. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
  29. package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
  30. package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
  31. package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
  32. package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
  33. package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
  34. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
  35. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
  36. package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
  37. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
  38. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
  39. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
  40. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
  41. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
  42. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
  43. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
  44. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +110 -97
  45. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +32 -29
  46. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
  47. package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
  48. package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
  49. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
  50. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
  51. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
  52. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
  53. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
  54. package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
  55. package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
  56. package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
  57. package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
  58. package/lib/runtime/components/react/dist/mpx-view.jsx +29 -44
  59. package/lib/runtime/components/react/dist/mpx-web-view.jsx +105 -42
  60. package/lib/runtime/components/react/dist/pickerFaces.js +12 -6
  61. package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
  62. package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
  63. package/lib/runtime/components/react/dist/{pickerOverlay.jsx → pickerViewOverlay.jsx} +5 -3
  64. package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -9
  65. package/lib/runtime/components/react/dist/utils.jsx +20 -24
  66. package/lib/runtime/components/react/getInnerListeners.ts +35 -28
  67. package/lib/runtime/components/react/mpx-button.tsx +55 -36
  68. package/lib/runtime/components/react/mpx-canvas/index.tsx +2 -2
  69. package/lib/runtime/components/react/mpx-checkbox-group.tsx +13 -12
  70. package/lib/runtime/components/react/mpx-checkbox.tsx +28 -28
  71. package/lib/runtime/components/react/mpx-form.tsx +10 -8
  72. package/lib/runtime/components/react/mpx-icon.tsx +10 -15
  73. package/lib/runtime/components/react/mpx-image.tsx +396 -0
  74. package/lib/runtime/components/react/mpx-input.tsx +61 -33
  75. package/lib/runtime/components/react/mpx-label.tsx +14 -13
  76. package/lib/runtime/components/react/mpx-movable-area.tsx +8 -7
  77. package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
  78. package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
  79. package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
  80. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
  81. package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
  82. package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
  83. package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
  84. package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
  85. package/lib/runtime/components/react/mpx-picker-view-column.tsx +4 -1
  86. package/lib/runtime/components/react/mpx-picker-view.tsx +7 -1
  87. package/lib/runtime/components/react/mpx-radio-group.tsx +11 -12
  88. package/lib/runtime/components/react/mpx-radio.tsx +26 -29
  89. package/lib/runtime/components/react/mpx-scroll-view.tsx +32 -30
  90. package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
  91. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
  92. package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
  93. package/lib/runtime/components/react/mpx-switch.tsx +10 -8
  94. package/lib/runtime/components/react/mpx-text.tsx +6 -2
  95. package/lib/runtime/components/react/mpx-view.tsx +37 -45
  96. package/lib/runtime/components/react/mpx-web-view.tsx +25 -15
  97. package/lib/runtime/components/react/types/global.d.ts +1 -16
  98. package/lib/runtime/components/react/utils.tsx +24 -24
  99. package/lib/runtime/components/tenon/getInnerListeners.js +334 -0
  100. package/lib/runtime/components/tenon/tenon-button.vue +309 -0
  101. package/lib/runtime/components/tenon/tenon-image.vue +66 -0
  102. package/lib/runtime/components/tenon/tenon-input.vue +171 -0
  103. package/lib/runtime/components/tenon/tenon-rich-text.vue +26 -0
  104. package/lib/runtime/components/tenon/tenon-scroll-view.vue +127 -0
  105. package/lib/runtime/components/tenon/tenon-switch.vue +96 -0
  106. package/lib/runtime/components/tenon/tenon-text.vue +70 -0
  107. package/lib/runtime/components/tenon/tenon-textarea.vue +86 -0
  108. package/lib/runtime/components/tenon/tenon-view.vue +93 -0
  109. package/lib/runtime/components/web/getInnerListeners.js +6 -6
  110. package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
  111. package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
  112. package/lib/runtime/components/web/mpx-picker.vue +382 -385
  113. package/lib/runtime/components/web/mpx-web-view.vue +162 -162
  114. package/lib/runtime/optionProcessor.js +7 -16
  115. package/lib/runtime/optionProcessor.tenon.js +84 -0
  116. package/lib/runtime/utils.js +2 -0
  117. package/lib/style-compiler/index.js +1 -1
  118. package/lib/style-compiler/plugins/hm.js +20 -0
  119. package/lib/template-compiler/bind-this.js +7 -2
  120. package/lib/template-compiler/compiler.js +67 -40
  121. package/lib/template-compiler/gen-node-react.js +2 -2
  122. package/lib/tenon/index.js +117 -0
  123. package/lib/tenon/processJSON.js +352 -0
  124. package/lib/tenon/processScript.js +203 -0
  125. package/lib/tenon/processStyles.js +21 -0
  126. package/lib/tenon/processTemplate.js +126 -0
  127. package/lib/tenon/script-helper.js +223 -0
  128. package/lib/utils/env.js +6 -1
  129. package/lib/utils/get-relative-path.js +25 -0
  130. package/package.json +7 -3
  131. package/LICENSE +0 -433
  132. package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
  133. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
  134. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -478
  135. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
  136. package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
  137. package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
  138. package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
@@ -32,10 +32,11 @@ import { FormContext, FormFieldValue } from '../context'
32
32
  */
33
33
 
34
34
  const _Picker = forwardRef<HandlerRef<View, PickerProps>, PickerProps>((props: PickerProps, ref): React.JSX.Element => {
35
- const { mode = 'selector', value, bindcancel, bindchange, children, bindcolumnchange } = props
35
+ const { mode = 'selector', value, bindcancel, bindchange, children, bindcolumnchange, style } = props
36
36
  const innerLayout = useRef({})
37
37
  const nodeRef = useRef(null)
38
38
  useNodesRef<View, PickerProps>(props, ref, nodeRef, {
39
+ style
39
40
  })
40
41
  const innerProps = useInnerProps(props, {
41
42
  ref: nodeRef
@@ -92,7 +93,7 @@ const _Picker = forwardRef<HandlerRef<View, PickerProps>, PickerProps>((props: P
92
93
  bindcolumnchange && bindcolumnchange(eventData)
93
94
  }
94
95
  const commonProps = {
95
- ...{ innerProps },
96
+ ...innerProps,
96
97
  mode,
97
98
  children,
98
99
  bindchange: onChange,
@@ -80,7 +80,7 @@ function getColumnIndexByValue (range: any[] = [], column: number, value: any[]
80
80
  }
81
81
 
82
82
  const _MultiSelectorPicker = forwardRef<HandlerRef<View, MultiSelectorProps>, MultiSelectorProps>((props: MultiSelectorProps, ref): React.JSX.Element => {
83
- const { range, value, disabled, bindchange, bindcancel, children, bindcolumnchange } = props
83
+ const { range, value, disabled, bindchange, bindcancel, children, bindcolumnchange, style } = props
84
84
  const formatRange = formatRangeFun(range, props['range-key'])
85
85
  const initValue = getInnerValueByIndex(formatRange, value)
86
86
  // 选中的索引值
@@ -90,7 +90,9 @@ const _MultiSelectorPicker = forwardRef<HandlerRef<View, MultiSelectorProps>, Mu
90
90
  // 存储layout布局信息
91
91
  const layoutRef = useRef({})
92
92
  const viewRef = useRef<View>(null)
93
- useNodesRef<View, MultiSelectorProps>(props, ref, viewRef, {
93
+ const nodeRef = useRef<View>(null)
94
+ useNodesRef<View, MultiSelectorProps>(props, ref, nodeRef, {
95
+ style
94
96
  })
95
97
 
96
98
  useEffect(() => {
@@ -126,6 +128,7 @@ const _MultiSelectorPicker = forwardRef<HandlerRef<View, MultiSelectorProps>, Mu
126
128
  }
127
129
 
128
130
  const antPickerProps = {
131
+ ref: nodeRef,
129
132
  data,
130
133
  value: selected,
131
134
  cols: range.length,
@@ -38,14 +38,16 @@ function formateRegionData (clObj: RegionObj[] = [], customItem?: string, depth
38
38
  }
39
39
 
40
40
  const _RegionPicker = forwardRef<HandlerRef<View, RegionProps>, RegionProps>((props: RegionProps, ref): React.JSX.Element => {
41
- const { children, value, bindchange, bindcancel, disabled } = props
41
+ const { children, value, bindchange, bindcancel, disabled, style } = props
42
42
  const formatRegionData = formateRegionData(regionData, props['custom-item'])
43
43
 
44
44
  const [regionvalue, setRegionValue] = useState(value)
45
45
  // 存储layout布局信息
46
46
  const layoutRef = useRef({})
47
47
  const viewRef = useRef<View>(null)
48
- useNodesRef<View, RegionProps>(props, ref, viewRef, {
48
+ const nodeRef = useRef(null)
49
+ useNodesRef<View, RegionProps>(props, ref, nodeRef, {
50
+ style
49
51
  })
50
52
 
51
53
  const onChange = (value: string[]): void => {
@@ -83,6 +85,7 @@ const _RegionPicker = forwardRef<HandlerRef<View, RegionProps>, RegionProps>((pr
83
85
  }
84
86
 
85
87
  const regionProps = {
88
+ ref: nodeRef,
86
89
  data: formatRegionData,
87
90
  value: regionvalue,
88
91
  onChange,
@@ -22,7 +22,7 @@ const formatRangeFun = (range: Array<RangeItemType>, rangeKey = ''): any => {
22
22
  }
23
23
 
24
24
  const _SelectorPicker = forwardRef<HandlerRef<View, SelectorProps>, SelectorProps>((props: SelectorProps, ref): React.JSX.Element => {
25
- const { range, children, value, disabled, bindchange, bindcancel } = props
25
+ const { range, children, value, disabled, bindchange, bindcancel, style } = props
26
26
  // 格式化数据为Array<*>
27
27
  const formatRange: PickerColumn = formatRangeFun(range, props['range-key'])
28
28
  // 选中的索引值
@@ -32,7 +32,9 @@ const _SelectorPicker = forwardRef<HandlerRef<View, SelectorProps>, SelectorProp
32
32
  // 存储layout布局信息
33
33
  const layoutRef = useRef({})
34
34
  const viewRef = useRef<View>(null)
35
- useNodesRef<View, SelectorProps>(props, ref, viewRef, {
35
+ const nodeRef = useRef(null)
36
+ useNodesRef<View, SelectorProps>(props, ref, nodeRef, {
37
+ style
36
38
  })
37
39
 
38
40
  useEffect(() => {
@@ -62,6 +64,7 @@ const _SelectorPicker = forwardRef<HandlerRef<View, SelectorProps>, SelectorProp
62
64
  }
63
65
 
64
66
  const antPickerProps = {
67
+ ref: nodeRef,
65
68
  data,
66
69
  value: [selected],
67
70
  cols: 1,
@@ -1,5 +1,5 @@
1
1
  import { View, Text, Modal, TouchableWithoutFeedback } from 'react-native'
2
- import { PickerView } from '@ant-design/react-native'
2
+ import { PickerView, Portal } from '@ant-design/react-native'
3
3
  import React, { forwardRef, useState, useRef, useEffect } from 'react'
4
4
  import useNodesRef, { HandlerRef } from '../useNodesRef' // 引入辅助函数
5
5
  import { TimeProps } from './type'
@@ -13,8 +13,8 @@ const styles: { [key: string]: Object } = {
13
13
  showModal: {
14
14
  backgroundColor: 'black',
15
15
  opacity: 0.5,
16
- position: 'absolute',
17
- width: '100%'
16
+ width: '100%',
17
+ height: '100%'
18
18
  },
19
19
  hideModal: {
20
20
  opacity: 1,
@@ -125,7 +125,7 @@ function checkSelectedIsValid (strStart: string, strEnd: string, selected: numbe
125
125
  // start="02:10" end = 23:01
126
126
 
127
127
  const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: TimeProps, ref): React.JSX.Element => {
128
- const { children, start, end, value, bindchange, bindcancel, disabled } = props
128
+ const { children, start, end, value, bindchange, bindcancel, style } = props
129
129
  const defaultProps = {
130
130
  start: '00:10',
131
131
  end: '23:59'
@@ -135,11 +135,11 @@ const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: T
135
135
  // 存储layout布局信息
136
136
  const layoutRef = useRef({})
137
137
  const viewRef = useRef<View>(null)
138
- useNodesRef<View, TimeProps>(props, ref, viewRef, {})
138
+ const nodeRef = useRef<View>(null)
139
+ useNodesRef<View, TimeProps>(props, ref, nodeRef, { style })
139
140
  // 存储modal的布局信息
140
141
  const modalLayoutRef = useRef({})
141
142
  const modalRef = useRef<View>(null)
142
- useNodesRef<View, TimeProps>(props, ref, modalRef, {})
143
143
  const [visible, setVisible] = useState(false)
144
144
  const columnData = generateColumns()
145
145
  const [data, setData] = useState(columnData)
@@ -188,12 +188,6 @@ const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: T
188
188
  } else {
189
189
  // [9, 13]
190
190
  setTimeValue(date)
191
- const strDate = formatStr(date)
192
- bindchange && bindchange({
193
- detail: {
194
- value: strDate
195
- }
196
- })
197
191
  }
198
192
  }
199
193
 
@@ -213,6 +207,7 @@ const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: T
213
207
 
214
208
  const renderModalChildren = () => {
215
209
  const pickerProps = {
210
+ ref: nodeRef,
216
211
  data,
217
212
  value: timevalue,
218
213
  defaultValue: timevalue,
@@ -249,12 +244,11 @@ const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: T
249
244
  </TouchableWithoutFeedback>
250
245
  </View>
251
246
  }
252
- const strStyle = visible ? styles.showModal : styles.hideModal
253
- const mheight = Math.floor(offsetTop)
254
247
 
255
248
  // Animated.View
256
249
  return (<>
257
- <View style={{ ...strStyle, height: visible ? mheight : 0, bottom: 0 }}>
250
+ <Portal>
251
+ <View style={visible ? styles.showModal : styles.hideModal}>
258
252
  <Modal
259
253
  animationType="slide"
260
254
  transparent={true}
@@ -263,6 +257,7 @@ const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: T
263
257
  {renderModalChildren()}
264
258
  </Modal>
265
259
  </View>
260
+ </Portal>
266
261
  {renderChildren()}
267
262
  </>)
268
263
  })
@@ -3,87 +3,92 @@ import { PickerValue } from '@ant-design/react-native'
3
3
 
4
4
  export type Obj = Record<string, any>
5
5
  export type SelectorProps = {
6
- mode: string,
6
+ mode: string
7
7
  // 表示选择了 range 中的第几个(下标从 0 开始)
8
8
  value: PickerValue
9
- disabled?: boolean,
10
- children: ReactNode,
11
- bindcancel?: Function,
12
- bindchange: Function,
9
+ disabled?: boolean
10
+ children: ReactNode
11
+ bindcancel?: Function
12
+ bindchange: Function
13
13
  // mode 为 selector 或 multiSelector 时,range 有效
14
- range: Array<number|string|Obj>,
14
+ range: Array<number|string|Obj>
15
15
  // 当 range 是一个 Object Array 时,通过 range-key 来指定 Object 中 key 的值作为选择器《显示内容》 对象中的属性
16
- 'range-key': string,
16
+ 'range-key': string
17
17
  getInnerLayout: Function
18
+ style?: Record<string, any>
18
19
  // bindcolumnchange?: Function
19
20
  }
20
21
 
21
22
  export type MultiSelectorProps = {
22
- mode: string,
23
+ mode: string
23
24
  // 表示选择了 range 中的第几个(下标从 0 开始)
24
- value: Array<number>,
25
- disabled?: boolean,
26
- children: ReactNode,
27
- bindcancel?: Function,
28
- bindchange: Function,
29
- bindcolumnchange?: Function,
25
+ value: Array<number>
26
+ disabled?: boolean
27
+ children: ReactNode
28
+ bindcancel?: Function
29
+ bindchange: Function
30
+ bindcolumnchange?: Function
30
31
  // mode 为 selector 或 multiSelector 时,range 有效
31
- range: Array<Array<any>>,
32
+ range: Array<Array<any>>
32
33
  // 当 range 是一个 Object Array 时,通过 range-key 来指定 Object 中 key 的值作为选择器《显示内容》 对象中的属性
33
- 'range-key': string,
34
+ 'range-key': string
34
35
  getInnerLayout: Function
36
+ style?: Record<string, any>
35
37
  }
36
38
 
37
39
  export type TimeProps = {
38
- mode: string,
40
+ mode: string
39
41
  // 表示选择了 range 中的第几个(下标从 0 开始)
40
- value: string,
41
- disabled?: boolean,
42
- children: ReactNode,
43
- bindcancel?: Function,
44
- bindchange: Function,
45
- start: string,
46
- end: string,
42
+ value: string
43
+ disabled?: boolean
44
+ children: ReactNode
45
+ bindcancel?: Function
46
+ bindchange: Function
47
+ start: string
48
+ end: string
47
49
  getInnerLayout: Function
50
+ style?: Record<string, any>
48
51
  }
49
52
 
50
53
  export type DateProps = {
51
- mode: string,
54
+ mode: string
52
55
  // 表示选择了 range 中的第几个(下标从 0 开始)
53
- value: string,
54
- fields?: 'day' | 'month' | 'year',
55
- disabled?: boolean,
56
- children: ReactNode,
57
- bindcancel?: Function,
58
- bindchange: Function,
59
- start: string,
60
- end: string,
56
+ value: string
57
+ fields?: 'day' | 'month' | 'year'
58
+ disabled?: boolean
59
+ children: ReactNode
60
+ bindcancel?: Function
61
+ bindchange: Function
62
+ start: string
63
+ end: string
61
64
  getInnerLayout: Function
65
+ style?: Record<string, any>
62
66
  }
63
67
 
64
68
  export type RegionProps = {
65
- mode: string,
69
+ mode: string
66
70
  // 表示选择了 range 中的第几个(下标从 0 开始)
67
- value: Array<string>,
71
+ value: Array<string>
68
72
  level: 'province' | 'city' | 'region' | 'sub-district'
69
- 'custom-item'?: string,
70
- disabled?: boolean,
71
- children: ReactNode,
72
- bindcancel?: Function,
73
- bindchange: Function,
73
+ 'custom-item'?: string
74
+ disabled?: boolean
75
+ children: ReactNode
76
+ bindcancel?: Function
77
+ bindchange: Function
74
78
  getInnerLayout: Function
79
+ style?: Record<string, any>
75
80
  }
76
81
 
77
82
  export type RegionObj = {
78
- value: string,
83
+ value: string
79
84
  code: string
80
85
  postcode?: string
81
86
  children?: RegionObj[]
82
87
  }
83
88
 
84
89
  export type PickerData = {
85
- value: string,
86
- label: string,
90
+ value: string
91
+ label: string
87
92
  children?: Array<Object>
88
93
  }
89
94
 
@@ -57,7 +57,10 @@ const _PickerViewColumn = forwardRef<HandlerRef<ScrollView & View, ColumnProps>,
57
57
  const { textStyle } = splitStyle(normalStyle)
58
58
  const { textProps } = splitProps(props)
59
59
  const scrollViewRef = useRef<ScrollView>(null)
60
- useNodesRef(props, ref, scrollViewRef, {})
60
+
61
+ useNodesRef(props, ref, scrollViewRef, {
62
+ style: normalStyle
63
+ })
61
64
 
62
65
  const { height: pickerH, itemHeight = DefaultPickerItemH } = wrapperStyle
63
66
  const [itemRawH, setItemRawH] = useState(0) // 单个选项真实渲染高度
@@ -90,7 +90,11 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
90
90
  setWidth,
91
91
  setHeight
92
92
  } = useTransformStyle(style, { enableVar, externalVarContext })
93
- useNodesRef<View, PickerViewProps>(props, ref, nodeRef, {})
93
+
94
+ useNodesRef<View, PickerViewProps>(props, ref, nodeRef, {
95
+ style: normalStyle
96
+ })
97
+
94
98
  const {
95
99
  // 存储layout布局信息
96
100
  layoutRef,
@@ -134,6 +138,7 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
134
138
  extendObject({
135
139
  ref: nodeRef,
136
140
  style: extendObject(
141
+ {},
137
142
  normalStyle,
138
143
  layoutStyle,
139
144
  {
@@ -151,6 +156,7 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
151
156
  const extraProps = {}
152
157
  const childProps = child?.props || {}
153
158
  const wrappedProps = extendObject(
159
+ {},
154
160
  childProps,
155
161
  {
156
162
  columnData,
@@ -20,7 +20,7 @@ import { warn } from '@mpxjs/utils'
20
20
  import { FormContext, FormFieldValue, RadioGroupContext, GroupValue } from './context'
21
21
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
22
22
  import useNodesRef, { HandlerRef } from './useNodesRef'
23
- import { useLayout, useTransformStyle, wrapChildren } from './utils'
23
+ import { useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
24
24
 
25
25
  export interface RadioGroupProps {
26
26
  name: string
@@ -67,10 +67,7 @@ const radioGroup = forwardRef<
67
67
  flexWrap: 'wrap'
68
68
  }
69
69
 
70
- const styleObj = {
71
- ...defaultStyle,
72
- ...style
73
- }
70
+ const styleObj = extendObject({}, defaultStyle, style)
74
71
 
75
72
  const {
76
73
  hasSelfPercent,
@@ -82,7 +79,7 @@ const radioGroup = forwardRef<
82
79
  } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
83
80
 
84
81
  const nodeRef = useRef(null)
85
- useNodesRef(props, ref, nodeRef, { defaultStyle })
82
+ useNodesRef(props, ref, nodeRef, { style: normalStyle })
86
83
 
87
84
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
88
85
 
@@ -144,12 +141,14 @@ const radioGroup = forwardRef<
144
141
 
145
142
  const innerProps = useInnerProps(
146
143
  props,
147
- {
148
- ref: nodeRef,
149
- style: { ...normalStyle, ...layoutStyle },
150
- ...layoutProps
151
- },
152
- [],
144
+ extendObject(
145
+ {
146
+ ref: nodeRef,
147
+ style: extendObject({}, normalStyle, layoutStyle)
148
+ },
149
+ layoutProps
150
+ ),
151
+ ['name'],
153
152
  {
154
153
  layoutRef
155
154
  }
@@ -10,7 +10,7 @@ import { warn } from '@mpxjs/utils'
10
10
  import { LabelContext, RadioGroupContext } from './context'
11
11
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
12
12
  import useNodesRef, { HandlerRef } from './useNodesRef'
13
- import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren } from './utils'
13
+ import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
14
14
  import Icon from './mpx-icon'
15
15
 
16
16
  export interface RadioProps {
@@ -27,7 +27,6 @@ export interface RadioProps {
27
27
  'parent-height'?: number;
28
28
  children: ReactNode
29
29
  bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
30
- catchtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
31
30
  }
32
31
 
33
32
  const styles = StyleSheet.create({
@@ -79,8 +78,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
79
78
  'parent-font-size': parentFontSize,
80
79
  'parent-width': parentWidth,
81
80
  'parent-height': parentHeight,
82
- bindtap,
83
- catchtap
81
+ bindtap
84
82
  } = props
85
83
 
86
84
  const [isChecked, setIsChecked] = useState<boolean>(!!checked)
@@ -91,16 +89,14 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
91
89
 
92
90
  const labelContext = useContext(LabelContext)
93
91
 
94
- const defaultStyle = {
95
- ...styles.wrapper,
96
- ...(isChecked && styles.wrapperChecked),
97
- ...(disabled && styles.wrapperDisabled)
98
- }
92
+ const defaultStyle = extendObject(
93
+ {},
94
+ styles.wrapper,
95
+ isChecked ? styles.wrapperChecked : {},
96
+ disabled ? styles.wrapperDisabled : {}
97
+ )
99
98
 
100
- const styleObj = {
101
- ...styles.container,
102
- ...style
103
- }
99
+ const styleObj = extendObject({}, styles.container, style)
104
100
 
105
101
  const onChange = (evt: NativeSyntheticEvent<TouchEvent>) => {
106
102
  if (disabled || isChecked) return
@@ -116,16 +112,10 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
116
112
  }
117
113
 
118
114
  const onTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
119
- if (disabled) return
120
115
  bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props))
121
116
  onChange(evt)
122
117
  }
123
118
 
124
- const catchTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
125
- if (disabled) return
126
- catchtap && catchtap(getCustomEvent('tap', evt, { layoutRef }, props))
127
- }
128
-
129
119
  const {
130
120
  hasSelfPercent,
131
121
  normalStyle,
@@ -135,7 +125,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
135
125
  setHeight
136
126
  } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
137
127
 
138
- const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle)
128
+ const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
139
129
 
140
130
  if (backgroundStyle) {
141
131
  warn('Radio does not support background image-related styles!')
@@ -143,7 +133,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
143
133
 
144
134
  const nodeRef = useRef(null)
145
135
  useNodesRef(props, ref, nodeRef, {
146
- defaultStyle,
136
+ style: extendObject({}, defaultStyle, normalStyle),
147
137
  change: onChange
148
138
  })
149
139
 
@@ -160,14 +150,21 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
160
150
 
161
151
  const innerProps = useInnerProps(
162
152
  props,
163
- {
164
- ref: nodeRef,
165
- style: { ...innerStyle, ...layoutStyle },
166
- ...layoutProps,
167
- bindtap: onTap,
168
- catchtap: catchTap
169
- },
170
- [],
153
+ extendObject(
154
+ {
155
+ ref: nodeRef,
156
+ style: extendObject({}, innerStyle, layoutStyle)
157
+ },
158
+ layoutProps,
159
+ {
160
+ bindtap: !disabled && onTap
161
+ }
162
+ ),
163
+ [
164
+ 'value',
165
+ 'disabled',
166
+ 'checked'
167
+ ],
171
168
  {
172
169
  layoutRef
173
170
  }
@@ -38,7 +38,7 @@ 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 {
@@ -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,
@@ -298,14 +299,13 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
298
299
  const visibleLength = selectLength(e.nativeEvent.layoutMeasurement)
299
300
  const contentLength = selectLength(e.nativeEvent.contentSize)
300
301
  const offset = selectOffset(e.nativeEvent.contentOffset)
301
- scrollOptions.current = {
302
- ...scrollOptions.current,
302
+ extendObject(scrollOptions.current, {
303
303
  contentLength,
304
304
  offset,
305
305
  scrollLeft: position.scrollLeft,
306
306
  scrollTop: position.scrollTop,
307
307
  visibleLength
308
- }
308
+ })
309
309
  }
310
310
 
311
311
  function onScroll (e: NativeSyntheticEvent<NativeScrollEvent>) {
@@ -426,34 +426,36 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
426
426
  updateScrollOptions(e, { scrollLeft, scrollTop })
427
427
  }
428
428
 
429
- let scrollAdditionalProps: ScrollAdditionalProps = {
430
- style: { ...innerStyle, ...layoutStyle },
431
- pinchGestureEnabled: false,
432
- horizontal: scrollX && !scrollY,
433
- scrollEventThrottle: scrollEventThrottle,
434
- scrollsToTop: enableBackToTop,
435
- showsHorizontalScrollIndicator: scrollX && showScrollbar,
436
- showsVerticalScrollIndicator: scrollY && showScrollbar,
437
- scrollEnabled: scrollX || scrollY,
438
- ref: scrollViewRef,
439
- onScroll: onScroll,
440
- onContentSizeChange: onContentSizeChange,
441
- bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) ? onScrollTouchStart : undefined,
442
- bindtouchmove: ((enhanced && binddragging) || bindtouchend) ? onScrollTouchMove : undefined,
443
- bindtouchend: ((enhanced && binddragend) || bindtouchend) ? onScrollTouchEnd : undefined,
444
- onScrollBeginDrag: onScrollDrag,
445
- onScrollEndDrag: onScrollDrag,
446
- onMomentumScrollEnd: onScrollEnd,
447
- ...layoutProps,
448
- ...(simultaneousHandlers ? { simultaneousHandlers } : {}),
449
- ...(waitForHandlers ? { waitFor: waitForHandlers } : {})
450
- }
429
+ const scrollAdditionalProps: ScrollAdditionalProps = extendObject(
430
+ {
431
+ style: extendObject({}, innerStyle, layoutStyle),
432
+ pinchGestureEnabled: false,
433
+ horizontal: scrollX && !scrollY,
434
+ scrollEventThrottle: scrollEventThrottle,
435
+ scrollsToTop: enableBackToTop,
436
+ showsHorizontalScrollIndicator: scrollX && showScrollbar,
437
+ showsVerticalScrollIndicator: scrollY && showScrollbar,
438
+ scrollEnabled: scrollX || scrollY,
439
+ ref: scrollViewRef,
440
+ onScroll: onScroll,
441
+ onContentSizeChange: onContentSizeChange,
442
+ bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) && onScrollTouchStart,
443
+ bindtouchmove: ((enhanced && binddragging) || bindtouchend) && onScrollTouchMove,
444
+ bindtouchend: ((enhanced && binddragend) || bindtouchend) && onScrollTouchEnd,
445
+ onScrollBeginDrag: onScrollDrag,
446
+ onScrollEndDrag: onScrollDrag,
447
+ onMomentumScrollEnd: onScrollEnd
448
+ },
449
+ (simultaneousHandlers ? { simultaneousHandlers } : {}),
450
+ (waitForHandlers ? { waitFor: waitForHandlers } : {}),
451
+ layoutProps
452
+ )
453
+
451
454
  if (enhanced) {
452
- scrollAdditionalProps = {
453
- ...scrollAdditionalProps,
455
+ Object.assign(scrollAdditionalProps, {
454
456
  bounces,
455
457
  pagingEnabled
456
- }
458
+ })
457
459
  }
458
460
 
459
461
  const innerProps = useInnerProps(props, scrollAdditionalProps, [
@@ -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
- // 计算transfrom之类的
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,