@mpxjs/webpack-plugin 2.10.16-beta.6 → 2.10.16-perf.1

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 (254) hide show
  1. package/lib/config.js +0 -60
  2. package/lib/dependencies/AppEntryDependency.js +2 -2
  3. package/lib/dependencies/ResolveDependency.js +1 -1
  4. package/lib/file-loader.js +3 -13
  5. package/lib/helpers.js +0 -2
  6. package/lib/index.js +15 -40
  7. package/lib/json-compiler/helper.js +2 -72
  8. package/lib/json-compiler/index.js +56 -16
  9. package/lib/json-compiler/plugin.js +2 -2
  10. package/lib/loader.js +4 -10
  11. package/lib/native-loader.js +3 -6
  12. package/lib/platform/json/wx/index.js +29 -30
  13. package/lib/platform/style/wx/index.js +1 -8
  14. package/lib/platform/template/wx/component-config/ad.js +0 -5
  15. package/lib/platform/template/wx/component-config/button.js +5 -21
  16. package/lib/platform/template/wx/component-config/camera.js +3 -25
  17. package/lib/platform/template/wx/component-config/canvas.js +1 -8
  18. package/lib/platform/template/wx/component-config/component.js +33 -31
  19. package/lib/platform/template/wx/component-config/cover-image.js +2 -7
  20. package/lib/platform/template/wx/component-config/cover-view.js +1 -3
  21. package/lib/platform/template/wx/component-config/fix-component-name.js +2 -2
  22. package/lib/platform/template/wx/component-config/form.js +2 -27
  23. package/lib/platform/template/wx/component-config/image.js +0 -5
  24. package/lib/platform/template/wx/component-config/input.js +0 -10
  25. package/lib/platform/template/wx/component-config/label.js +2 -10
  26. package/lib/platform/template/wx/component-config/map.js +0 -11
  27. package/lib/platform/template/wx/component-config/movable-area.js +1 -4
  28. package/lib/platform/template/wx/component-config/movable-view.js +2 -17
  29. package/lib/platform/template/wx/component-config/navigator.js +0 -26
  30. package/lib/platform/template/wx/component-config/picker-view.js +0 -12
  31. package/lib/platform/template/wx/component-config/picker.js +1 -3
  32. package/lib/platform/template/wx/component-config/progress.js +1 -11
  33. package/lib/platform/template/wx/component-config/rich-text.js +0 -5
  34. package/lib/platform/template/wx/component-config/scroll-view.js +1 -12
  35. package/lib/platform/template/wx/component-config/slider.js +0 -8
  36. package/lib/platform/template/wx/component-config/swiper-item.js +2 -5
  37. package/lib/platform/template/wx/component-config/swiper.js +0 -10
  38. package/lib/platform/template/wx/component-config/text.js +0 -5
  39. package/lib/platform/template/wx/component-config/textarea.js +2 -19
  40. package/lib/platform/template/wx/component-config/unsupported.js +1 -10
  41. package/lib/platform/template/wx/component-config/video.js +0 -10
  42. package/lib/platform/template/wx/index.js +1 -21
  43. package/lib/react/index.js +0 -2
  44. package/lib/react/processJSON.js +71 -39
  45. package/lib/react/processStyles.js +2 -3
  46. package/lib/react/processTemplate.js +6 -8
  47. package/lib/react/script-helper.js +16 -6
  48. package/lib/react/style-helper.js +2 -10
  49. package/lib/runtime/components/react/context.ts +6 -12
  50. package/lib/runtime/components/react/dist/context.js +0 -1
  51. package/lib/runtime/components/react/dist/mpx-image.jsx +62 -100
  52. package/lib/runtime/components/react/dist/mpx-input.jsx +9 -35
  53. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +50 -58
  54. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +3 -4
  55. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +18 -12
  56. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +11 -8
  57. package/lib/runtime/components/react/dist/mpx-portal/index.jsx +1 -5
  58. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +14 -6
  59. package/lib/runtime/components/react/dist/mpx-text.jsx +5 -33
  60. package/lib/runtime/components/react/dist/mpx-view.jsx +1 -1
  61. package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
  62. package/lib/runtime/components/react/dist/utils.jsx +6 -16
  63. package/lib/runtime/components/react/mpx-image.tsx +82 -123
  64. package/lib/runtime/components/react/mpx-input.tsx +16 -41
  65. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +49 -66
  66. package/lib/runtime/components/react/mpx-picker-view/index.tsx +2 -5
  67. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +21 -26
  68. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +12 -8
  69. package/lib/runtime/components/react/mpx-portal/index.tsx +2 -8
  70. package/lib/runtime/components/react/mpx-scroll-view.tsx +17 -6
  71. package/lib/runtime/components/react/mpx-text.tsx +5 -38
  72. package/lib/runtime/components/react/mpx-view.tsx +1 -1
  73. package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
  74. package/lib/runtime/components/react/types/common.d.ts +0 -19
  75. package/lib/runtime/components/react/utils.tsx +6 -15
  76. package/lib/runtime/stringify.wxs +2 -2
  77. package/lib/script-setup-compiler/index.js +2 -2
  78. package/lib/style-compiler/index.js +2 -3
  79. package/lib/style-compiler/load-postcss-config.js +1 -1
  80. package/lib/style-compiler/plugins/trans-special.js +2 -10
  81. package/lib/style-compiler/strip-conditional-loader.js +15 -178
  82. package/lib/template-compiler/bind-this.js +2 -2
  83. package/lib/template-compiler/compiler.js +72 -270
  84. package/lib/template-compiler/gen-node-react.js +6 -18
  85. package/lib/template-compiler/index.js +10 -12
  86. package/lib/template-compiler/parse-exps.js +1 -1
  87. package/lib/utils/const.js +1 -2
  88. package/lib/utils/dom-tag-config.js +6 -6
  89. package/lib/utils/env.js +1 -6
  90. package/lib/utils/pre-process-json.js +0 -5
  91. package/lib/web/index.js +0 -2
  92. package/lib/web/processJSON.js +16 -44
  93. package/lib/web/processScript.js +1 -1
  94. package/lib/web/processTemplate.js +4 -6
  95. package/lib/web/script-helper.js +9 -19
  96. package/lib/wxs/pre-loader.js +1 -1
  97. package/lib/wxss/loader.js +9 -1
  98. package/package.json +2 -13
  99. package/lib/dependencies/RecordModuleIdMapDependency.js +0 -49
  100. package/lib/runtime/components/react/dist/context.d.ts +0 -75
  101. package/lib/runtime/components/react/dist/context.d.ts.map +0 -1
  102. package/lib/runtime/components/react/dist/event.config.d.ts +0 -8
  103. package/lib/runtime/components/react/dist/event.config.d.ts.map +0 -1
  104. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +0 -8
  105. package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +0 -1
  106. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +0 -13
  107. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +0 -1
  108. package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -69
  109. package/lib/runtime/components/react/dist/mpx-button.d.ts.map +0 -1
  110. package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -28
  111. package/lib/runtime/components/react/dist/mpx-camera.d.ts.map +0 -1
  112. package/lib/runtime/components/react/dist/mpx-camera.jsx +0 -102
  113. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +0 -24
  114. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +0 -1
  115. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +0 -8
  116. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +0 -1
  117. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +0 -7
  118. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +0 -1
  119. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +0 -21
  120. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +0 -1
  121. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +0 -9
  122. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +0 -1
  123. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +0 -11
  124. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +0 -1
  125. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +0 -3
  126. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +0 -1
  127. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -33
  128. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +0 -1
  129. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +0 -53
  130. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +0 -1
  131. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -21
  132. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +0 -1
  133. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -33
  134. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +0 -1
  135. package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -28
  136. package/lib/runtime/components/react/dist/mpx-form.d.ts.map +0 -1
  137. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -19
  138. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +0 -1
  139. package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -22
  140. package/lib/runtime/components/react/dist/mpx-image.d.ts.map +0 -1
  141. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +0 -8
  142. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +0 -1
  143. package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -50
  144. package/lib/runtime/components/react/dist/mpx-input.d.ts.map +0 -1
  145. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +0 -13
  146. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +0 -1
  147. package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -21
  148. package/lib/runtime/components/react/dist/mpx-label.d.ts.map +0 -1
  149. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -21
  150. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +0 -1
  151. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -66
  152. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +0 -1
  153. package/lib/runtime/components/react/dist/mpx-nav.d.ts +0 -9
  154. package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +0 -1
  155. package/lib/runtime/components/react/dist/mpx-nav.jsx +0 -132
  156. package/lib/runtime/components/react/dist/mpx-navigator.d.ts +0 -10
  157. package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +0 -1
  158. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +0 -7
  159. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +0 -1
  160. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +0 -8
  161. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +0 -1
  162. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +0 -7
  163. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +0 -1
  164. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +0 -7
  165. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +0 -1
  166. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +0 -7
  167. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +0 -1
  168. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +0 -3
  169. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +0 -1
  170. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +0 -7
  171. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +0 -1
  172. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +0 -7
  173. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +0 -1
  174. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +0 -107
  175. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +0 -1
  176. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +0 -33
  177. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +0 -1
  178. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -9
  179. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +0 -1
  180. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -24
  181. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +0 -1
  182. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -15
  183. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +0 -1
  184. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -14
  185. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +0 -1
  186. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +0 -20
  187. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +0 -17
  188. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +0 -1
  189. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +0 -13
  190. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +0 -1
  191. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +0 -12
  192. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +0 -1
  193. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +0 -23
  194. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +0 -1
  195. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +0 -17
  196. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +0 -1
  197. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +0 -16
  198. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +0 -1
  199. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +0 -30
  200. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +0 -1
  201. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +0 -10
  202. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +0 -1
  203. package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -24
  204. package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +0 -1
  205. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -21
  206. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +0 -1
  207. package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -27
  208. package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +0 -1
  209. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +0 -2
  210. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +0 -1
  211. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -25
  212. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +0 -1
  213. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +0 -15
  214. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +0 -1
  215. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -55
  216. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +0 -1
  217. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +0 -8
  218. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +0 -1
  219. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -8
  220. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +0 -1
  221. package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -31
  222. package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +0 -1
  223. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -18
  224. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +0 -1
  225. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -16
  226. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +0 -1
  227. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -19
  228. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +0 -1
  229. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +0 -53
  230. package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +0 -1
  231. package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -27
  232. package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +0 -1
  233. package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -23
  234. package/lib/runtime/components/react/dist/mpx-text.d.ts.map +0 -1
  235. package/lib/runtime/components/react/dist/mpx-textarea.d.ts +0 -8
  236. package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +0 -1
  237. package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -102
  238. package/lib/runtime/components/react/dist/mpx-video.d.ts.map +0 -1
  239. package/lib/runtime/components/react/dist/mpx-view.d.ts +0 -35
  240. package/lib/runtime/components/react/dist/mpx-view.d.ts.map +0 -1
  241. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +0 -23
  242. package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +0 -1
  243. package/lib/runtime/components/react/dist/parser.d.ts +0 -40
  244. package/lib/runtime/components/react/dist/parser.d.ts.map +0 -1
  245. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +0 -33
  246. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +0 -1
  247. package/lib/runtime/components/react/dist/useNodesRef.d.ts +0 -12
  248. package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +0 -1
  249. package/lib/runtime/components/react/dist/utils.d.ts +0 -123
  250. package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
  251. package/lib/runtime/components/react/mpx-camera.tsx +0 -167
  252. package/lib/runtime/components/react/mpx-nav.tsx +0 -155
  253. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +0 -55
  254. package/lib/utils/get-build-tag-component.js +0 -35
@@ -1,155 +0,0 @@
1
- /* eslint-disable space-before-function-paren */
2
- import { useState, useMemo, memo } from 'react'
3
- import { useSafeAreaInsets } from 'react-native-safe-area-context'
4
- import { StatusBar, processColor, TouchableWithoutFeedback, Image, View, StyleSheet, Text } from 'react-native'
5
-
6
- function convertToHex(color?: string) {
7
- try {
8
- const intColor = processColor(color) as number | null | undefined
9
- if (intColor === null || intColor === undefined) {
10
- return null
11
- }
12
- // 将32位整数颜色值转换为RGBA
13
- const r = (intColor >> 16) & 255
14
- const g = (intColor >> 8) & 255
15
- const b = intColor & 255
16
- // 转换为十六进制
17
- const hexR = r.toString(16).padStart(2, '0')
18
- const hexG = g.toString(16).padStart(2, '0')
19
- const hexB = b.toString(16).padStart(2, '0')
20
- return `#${hexR}${hexG}${hexB}`
21
- } catch (error) {
22
- return null
23
- }
24
- }
25
-
26
- const titleHeight = 44
27
- export function useInnerHeaderHeight(pageConfig: PageConfig) {
28
- const safeArea = useSafeAreaInsets()
29
- if (pageConfig.navigationStyle === 'custom') {
30
- return 0
31
- } else {
32
- const safeAreaTop = safeArea?.top || 0
33
- const headerHeight = safeAreaTop + titleHeight
34
- return headerHeight
35
- }
36
- }
37
-
38
- const styles = StyleSheet.create({
39
- header: {
40
- elevation: 3
41
- },
42
- headerContent: {
43
- flexDirection: 'row',
44
- alignItems: 'center',
45
- justifyContent: 'center'
46
- },
47
- backButton: {
48
- position: 'absolute',
49
- height: '100%',
50
- width: 40,
51
- left: 0,
52
- top: 0,
53
- alignItems: 'center',
54
- justifyContent: 'center'
55
- },
56
- backButtonImage: {
57
- width: 22,
58
- height: 22
59
- },
60
- title: {
61
- fontSize: 17,
62
- fontWeight: 600,
63
- width: '60%',
64
- textAlign: 'center'
65
- }
66
- })
67
- const NavColor = {
68
- White: '#ffffff',
69
- Black: '#000000'
70
- }
71
- // navigationBarTextStyle 只支持黑白 'white'/'black
72
- const validBarTextStyle = (textStyle?: string) => {
73
- const textStyleColor = convertToHex(textStyle)
74
- if (textStyle && textStyleColor && [NavColor.White, NavColor.Black].includes(textStyleColor)) {
75
- return textStyleColor
76
- } else {
77
- return NavColor.White
78
- }
79
- }
80
-
81
- export interface MpxNavProps {
82
- pageConfig: PageConfig
83
- navigation: any
84
- }
85
-
86
- const BACK_ICON =
87
- 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABICAYAAACqT5alAAAA2UlEQVR4nO3bMQrCUBRE0Yla6AYEN2nnBrTL+izcitW3MRDkEUWSvPzJvfCqgMwhZbAppWhNbbIHzB1g9wATERFRVyvpkj1irlpJ5X326D7WHh1hbdFD2CLpLmmftm7kfsEe09aNHFiBrT+wAlt/YAW2/sAKbP2BFdj6Ayuwy+ufz6XPL893krZ//O6iu2n4LT8kndLWTRTo4EC7BDo40C6BDg60S6CDA+0S6OBAuwQ6uNWiD2nrJmoIfU7cNWkR2hbb1UfbY7uuWhGWiIg+a/iHuHmA3QPs3gu4JW9Gan+OJAAAAABJRU5ErkJggg=='
88
-
89
- const MpxNav = memo(({ pageConfig, navigation }: MpxNavProps) => {
90
- const [innerPageConfig, setPageConfig] = useState<PageConfig>(pageConfig || {})
91
- const safeAreaTop = useSafeAreaInsets()?.top || 0
92
-
93
- navigation.setPageConfig = (config: PageConfig) => {
94
- setPageConfig(Object.assign({}, innerPageConfig, config))
95
- }
96
- const isCustom = innerPageConfig.navigationStyle === 'custom'
97
- const navigationBarTextStyle = useMemo(() => validBarTextStyle(innerPageConfig.navigationBarTextStyle), [innerPageConfig.navigationBarTextStyle])
98
- // 状态栏的颜色
99
- const statusBarElement = (
100
- <StatusBar
101
- translucent
102
- backgroundColor='transparent'
103
- barStyle={navigationBarTextStyle === NavColor.White ? 'light-content' : 'dark-content'}></StatusBar>
104
- )
105
-
106
- if (isCustom) return statusBarElement
107
- // 假设是栈导航,获取栈的长度
108
- const stackLength = navigation.getState()?.routes?.length
109
- const onStackTopBack = mpxGlobal?.__mpx?.config?.rnConfig?.onStackTopBack
110
- const isHandleStackTopBack = typeof onStackTopBack === 'function'
111
-
112
- // 回退按钮与图标
113
- // prettier-ignore
114
- const backElement = stackLength > 1 || isHandleStackTopBack
115
- ? (
116
- <TouchableWithoutFeedback
117
- onPress={() => {
118
- if (stackLength <= 1 && isHandleStackTopBack) {
119
- onStackTopBack()
120
- return
121
- }
122
- navigation.goBack()
123
- }}>
124
- <View style={[styles.backButton]}>
125
- <Image style={[styles.backButtonImage, { tintColor: navigationBarTextStyle }]} source={{ uri: BACK_ICON }}></Image>
126
- </View>
127
- </TouchableWithoutFeedback>
128
- )
129
- : null
130
-
131
- return (
132
- <View
133
- style={[
134
- styles.header,
135
- {
136
- paddingTop: safeAreaTop,
137
- backgroundColor: innerPageConfig.navigationBarBackgroundColor || '#000000'
138
- }
139
- ]}>
140
- {statusBarElement}
141
- {/* TODO: 确定 height 的有效性 */}
142
- {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
143
- {/* @ts-expect-error */}
144
- <View style={styles.headerContent} height={titleHeight}>
145
- {backElement}
146
- <Text style={[styles.title, { color: navigationBarTextStyle }]} numberOfLines={1}>
147
- {innerPageConfig.navigationBarTitleText?.trim() || ''}
148
- </Text>
149
- </View>
150
- </View>
151
- )
152
- })
153
-
154
- MpxNav.displayName = 'MpxNav'
155
- export default MpxNav
@@ -1,55 +0,0 @@
1
- import React from 'react'
2
- import { LayoutChangeEvent, View } from 'react-native'
3
- import { extendObject } from '../utils'
4
- import { usePickerViewStyleContext } from '../mpx-picker-view/pickerVIewContext'
5
-
6
- interface PickerColumnItemProps {
7
- item: React.ReactElement
8
- index: number
9
- itemHeight: number
10
- itemWidth?: number | '100%'
11
- textStyle: Record<string, any>
12
- textProps?: any
13
- onItemLayout?: (e: LayoutChangeEvent) => void
14
- }
15
-
16
- const PickerViewColumnItem: React.FC<PickerColumnItemProps> = ({
17
- item,
18
- index,
19
- itemHeight,
20
- itemWidth = '100%',
21
- textStyle,
22
- textProps,
23
- onItemLayout
24
- }) => {
25
- const textStyleFromAncestor = usePickerViewStyleContext()
26
- const strKey = `picker-column-item-${index}`
27
- const restProps = index === 0 ? { onLayout: onItemLayout } : {}
28
- const itemProps = extendObject(
29
- {
30
- style: extendObject(
31
- { height: itemHeight, width: '100%' },
32
- textStyleFromAncestor,
33
- textStyle,
34
- item.props.style
35
- )
36
- },
37
- textProps,
38
- restProps
39
- )
40
- const realItem = React.cloneElement(item, itemProps)
41
-
42
- return (
43
- <View
44
- key={strKey}
45
- style={[
46
- { height: itemHeight, width: itemWidth, pointerEvents: 'none' }
47
- ]}
48
- >
49
- {realItem}
50
- </View>
51
- )
52
- }
53
-
54
- PickerViewColumnItem.displayName = 'MpxPickerViewColumnItem'
55
- export default PickerViewColumnItem
@@ -1,35 +0,0 @@
1
- const normalize = require('./normalize')
2
- const { isBuildInWebTag, isBuildInReactTag } = require('./dom-tag-config')
3
-
4
- module.exports = function getBuildInTagComponent (mode, tag) {
5
- const aliBuildTag = ['view', 'text'].reduce((obj, name) => {
6
- obj[name] = {
7
- name: `mpx-${name}`,
8
- resource: normalize.lib(`runtime/components/ali/mpx-${name}.mpx`)
9
- }
10
- return obj
11
- }, {})
12
-
13
- switch (mode) {
14
- case 'ali':
15
- return aliBuildTag[tag]
16
- case 'web':
17
- if (isBuildInWebTag(`mpx-${tag}`)) {
18
- return {
19
- name: `mpx-${tag}`,
20
- resource: normalize.lib(`runtime/components/web/mpx-${tag}.vue`)
21
- }
22
- }
23
- return undefined
24
- case 'ios':
25
- case 'android':
26
- case 'harmony':
27
- if (isBuildInReactTag(`mpx-${tag}`)) {
28
- return {
29
- name: `mpx-${tag}`,
30
- resource: normalize.lib(`runtime/components/react/dist/mpx-${tag}.jsx`)
31
- }
32
- }
33
- return undefined
34
- }
35
- }