@mpxjs/webpack-plugin 2.10.16-beta.9 → 2.10.16-xp.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 (256) 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 -13
  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 +11 -37
  53. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +50 -61
  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-swiper.jsx +9 -5
  60. package/lib/runtime/components/react/dist/mpx-text.jsx +5 -33
  61. package/lib/runtime/components/react/dist/mpx-view.jsx +1 -1
  62. package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
  63. package/lib/runtime/components/react/dist/utils.jsx +6 -16
  64. package/lib/runtime/components/react/mpx-image.tsx +82 -123
  65. package/lib/runtime/components/react/mpx-input.tsx +17 -44
  66. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +49 -69
  67. package/lib/runtime/components/react/mpx-picker-view/index.tsx +2 -5
  68. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +21 -26
  69. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +12 -8
  70. package/lib/runtime/components/react/mpx-portal/index.tsx +2 -8
  71. package/lib/runtime/components/react/mpx-scroll-view.tsx +17 -6
  72. package/lib/runtime/components/react/mpx-swiper.tsx +9 -5
  73. package/lib/runtime/components/react/mpx-text.tsx +5 -38
  74. package/lib/runtime/components/react/mpx-view.tsx +1 -1
  75. package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
  76. package/lib/runtime/components/react/types/common.d.ts +0 -19
  77. package/lib/runtime/components/react/utils.tsx +6 -15
  78. package/lib/runtime/stringify.wxs +2 -2
  79. package/lib/script-setup-compiler/index.js +2 -2
  80. package/lib/style-compiler/index.js +2 -3
  81. package/lib/style-compiler/load-postcss-config.js +1 -1
  82. package/lib/style-compiler/plugins/trans-special.js +2 -10
  83. package/lib/style-compiler/strip-conditional-loader.js +15 -178
  84. package/lib/template-compiler/bind-this.js +2 -2
  85. package/lib/template-compiler/compiler.js +71 -267
  86. package/lib/template-compiler/gen-node-react.js +6 -18
  87. package/lib/template-compiler/index.js +10 -12
  88. package/lib/template-compiler/parse-exps.js +1 -1
  89. package/lib/utils/const.js +1 -2
  90. package/lib/utils/dom-tag-config.js +6 -6
  91. package/lib/utils/env.js +1 -6
  92. package/lib/utils/pre-process-json.js +0 -5
  93. package/lib/web/index.js +0 -2
  94. package/lib/web/processJSON.js +16 -44
  95. package/lib/web/processScript.js +1 -1
  96. package/lib/web/processTemplate.js +4 -6
  97. package/lib/web/script-helper.js +9 -19
  98. package/lib/wxs/pre-loader.js +1 -1
  99. package/lib/wxss/loader.js +9 -1
  100. package/package.json +4 -15
  101. package/lib/dependencies/RecordModuleIdMapDependency.js +0 -49
  102. package/lib/runtime/components/react/dist/context.d.ts +0 -76
  103. package/lib/runtime/components/react/dist/context.d.ts.map +0 -1
  104. package/lib/runtime/components/react/dist/event.config.d.ts +0 -8
  105. package/lib/runtime/components/react/dist/event.config.d.ts.map +0 -1
  106. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +0 -8
  107. package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +0 -1
  108. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +0 -13
  109. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +0 -1
  110. package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -69
  111. package/lib/runtime/components/react/dist/mpx-button.d.ts.map +0 -1
  112. package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -27
  113. package/lib/runtime/components/react/dist/mpx-camera.d.ts.map +0 -1
  114. package/lib/runtime/components/react/dist/mpx-camera.jsx +0 -197
  115. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +0 -24
  116. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +0 -1
  117. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +0 -8
  118. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +0 -1
  119. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +0 -7
  120. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +0 -1
  121. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +0 -21
  122. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +0 -1
  123. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +0 -9
  124. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +0 -1
  125. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +0 -11
  126. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +0 -1
  127. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +0 -3
  128. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +0 -1
  129. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -33
  130. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +0 -1
  131. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +0 -53
  132. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +0 -1
  133. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -21
  134. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +0 -1
  135. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -33
  136. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +0 -1
  137. package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -28
  138. package/lib/runtime/components/react/dist/mpx-form.d.ts.map +0 -1
  139. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -19
  140. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +0 -1
  141. package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -22
  142. package/lib/runtime/components/react/dist/mpx-image.d.ts.map +0 -1
  143. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +0 -8
  144. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +0 -1
  145. package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -51
  146. package/lib/runtime/components/react/dist/mpx-input.d.ts.map +0 -1
  147. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +0 -13
  148. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +0 -1
  149. package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -21
  150. package/lib/runtime/components/react/dist/mpx-label.d.ts.map +0 -1
  151. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -21
  152. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +0 -1
  153. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -66
  154. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +0 -1
  155. package/lib/runtime/components/react/dist/mpx-nav.d.ts +0 -9
  156. package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +0 -1
  157. package/lib/runtime/components/react/dist/mpx-nav.jsx +0 -132
  158. package/lib/runtime/components/react/dist/mpx-navigator.d.ts +0 -10
  159. package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +0 -1
  160. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +0 -7
  161. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +0 -1
  162. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +0 -8
  163. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +0 -1
  164. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +0 -7
  165. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +0 -1
  166. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +0 -7
  167. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +0 -1
  168. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +0 -7
  169. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +0 -1
  170. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +0 -3
  171. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +0 -1
  172. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +0 -7
  173. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +0 -1
  174. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +0 -7
  175. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +0 -1
  176. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +0 -107
  177. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +0 -1
  178. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +0 -33
  179. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +0 -1
  180. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -9
  181. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +0 -1
  182. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -24
  183. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +0 -1
  184. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -15
  185. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +0 -1
  186. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -14
  187. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +0 -1
  188. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +0 -20
  189. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +0 -17
  190. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +0 -1
  191. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +0 -13
  192. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +0 -1
  193. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +0 -12
  194. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +0 -1
  195. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +0 -23
  196. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +0 -1
  197. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +0 -17
  198. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +0 -1
  199. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +0 -16
  200. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +0 -1
  201. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +0 -30
  202. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +0 -1
  203. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +0 -10
  204. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +0 -1
  205. package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -24
  206. package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +0 -1
  207. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -21
  208. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +0 -1
  209. package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -27
  210. package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +0 -1
  211. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +0 -2
  212. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +0 -1
  213. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -25
  214. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +0 -1
  215. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +0 -15
  216. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +0 -1
  217. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -55
  218. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +0 -1
  219. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +0 -8
  220. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +0 -1
  221. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -8
  222. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +0 -1
  223. package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -31
  224. package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +0 -1
  225. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -18
  226. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +0 -1
  227. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -16
  228. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +0 -1
  229. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -19
  230. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +0 -1
  231. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +0 -53
  232. package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +0 -1
  233. package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -27
  234. package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +0 -1
  235. package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -23
  236. package/lib/runtime/components/react/dist/mpx-text.d.ts.map +0 -1
  237. package/lib/runtime/components/react/dist/mpx-textarea.d.ts +0 -8
  238. package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +0 -1
  239. package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -102
  240. package/lib/runtime/components/react/dist/mpx-video.d.ts.map +0 -1
  241. package/lib/runtime/components/react/dist/mpx-view.d.ts +0 -35
  242. package/lib/runtime/components/react/dist/mpx-view.d.ts.map +0 -1
  243. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +0 -23
  244. package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +0 -1
  245. package/lib/runtime/components/react/dist/parser.d.ts +0 -40
  246. package/lib/runtime/components/react/dist/parser.d.ts.map +0 -1
  247. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +0 -33
  248. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +0 -1
  249. package/lib/runtime/components/react/dist/useNodesRef.d.ts +0 -12
  250. package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +0 -1
  251. package/lib/runtime/components/react/dist/utils.d.ts +0 -123
  252. package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
  253. package/lib/runtime/components/react/mpx-camera.tsx +0 -275
  254. package/lib/runtime/components/react/mpx-nav.tsx +0 -155
  255. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +0 -55
  256. package/lib/utils/get-build-tag-component.js +0 -35
@@ -18,7 +18,7 @@
18
18
  * ✔ selection-start
19
19
  * ✔ selection-end
20
20
  * ✔ adjust-position
21
- * hold-keyboard
21
+ * hold-keyboard
22
22
  * ✘ safe-password-cert-path
23
23
  * ✘ safe-password-length
24
24
  * ✘ safe-password-time-stamp
@@ -52,7 +52,7 @@ const keyboardTypeMap = {
52
52
  digit: isIOS ? 'decimal-pad' : 'numeric'
53
53
  };
54
54
  const Input = forwardRef((props, ref) => {
55
- const { style = {}, allowFontScaling = false, type = 'text', value, password, 'placeholder-style': placeholderStyle = {}, disabled, maxlength = 140, 'cursor-spacing': cursorSpacing = 0, 'auto-focus': autoFocus, focus, 'confirm-type': confirmType = 'done', 'confirm-hold': confirmHold = false, cursor, 'cursor-color': cursorColor, 'selection-start': selectionStart = -1, 'selection-end': selectionEnd = -1, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'adjust-position': adjustPosition = true, 'hold-keyboard': holdKeyboard = false, bindinput, bindfocus, bindblur, bindconfirm, bindselectionchange,
55
+ const { style = {}, allowFontScaling = false, type = 'text', value, password, 'placeholder-style': placeholderStyle = {}, disabled, maxlength = 140, 'cursor-spacing': cursorSpacing = 0, 'auto-focus': autoFocus, focus, 'confirm-type': confirmType = 'done', 'confirm-hold': confirmHold = false, cursor, 'cursor-color': cursorColor, 'selection-start': selectionStart = -1, 'selection-end': selectionEnd = -1, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'adjust-position': adjustPosition = true, bindinput, bindfocus, bindblur, bindconfirm, bindselectionchange,
56
56
  // private
57
57
  multiline, 'auto-height': autoHeight, bindlinechange } = props;
58
58
  const formContext = useContext(FormContext);
@@ -144,8 +144,8 @@ const Input = forwardRef((props, ref) => {
144
144
  }
145
145
  };
146
146
  const setKeyboardAvoidContext = () => {
147
- if (keyboardAvoid) {
148
- keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition, holdKeyboard };
147
+ if (adjustPosition && keyboardAvoid) {
148
+ keyboardAvoid.current = { cursorSpacing, ref: nodeRef };
149
149
  }
150
150
  };
151
151
  const onTouchStart = () => {
@@ -156,39 +156,13 @@ const Input = forwardRef((props, ref) => {
156
156
  evt.nativeEvent.origin = 'input';
157
157
  };
158
158
  const onFocus = (evt) => {
159
- if (!keyboardAvoid?.current) {
160
- setKeyboardAvoidContext();
161
- }
162
- if (bindfocus) {
163
- const focusAction = () => {
164
- bindfocus(getCustomEvent('focus', evt, {
165
- detail: {
166
- value: tmpValue.current || '',
167
- height: keyboardAvoid?.current?.keyboardHeight
168
- },
169
- layoutRef
170
- }, props));
171
- if (keyboardAvoid?.current?.onKeyboardShow) {
172
- keyboardAvoid.current.onKeyboardShow = undefined;
173
- }
174
- };
175
- if (keyboardAvoid?.current) {
176
- // 有 keyboardAvoiding
177
- if (keyboardAvoid.current.keyboardHeight) {
178
- // iOS: keyboard 获取高度时机 keyboardWillShow 在 input focus 之前,可以立即执行
179
- focusAction();
180
- }
181
- else {
182
- // Android,Harmony: keyboard 获取高度时机 keyboardDidShow 在 input focus 之后,需要延迟回调
183
- evt.persist();
184
- keyboardAvoid.current.onKeyboardShow = focusAction;
185
- }
186
- }
187
- else {
188
- // 无 keyboardAvoiding,直接执行 focus 回调
189
- focusAction();
190
- }
191
- }
159
+ setKeyboardAvoidContext();
160
+ bindfocus && bindfocus(getCustomEvent('focus', evt, {
161
+ detail: {
162
+ value: tmpValue.current || ''
163
+ },
164
+ layoutRef
165
+ }, props));
192
166
  };
193
167
  const onBlur = (evt) => {
194
168
  bindblur && bindblur(getCustomEvent('blur', evt, {
@@ -1,103 +1,92 @@
1
- /* eslint-disable space-before-function-paren */
2
- import React, { useContext, useEffect, useRef } from 'react';
1
+ import React, { useContext, useEffect } from 'react';
3
2
  import { Keyboard, View } from 'react-native';
4
- import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing, cancelAnimation } from 'react-native-reanimated';
3
+ import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing } from 'react-native-reanimated';
5
4
  import { KeyboardAvoidContext } from './context';
6
- import { isAndroid, isIOS } from './utils';
5
+ import { isIOS } from './utils';
7
6
  const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
8
7
  const duration = isIOS ? 250 : 300;
9
8
  const easing = isIOS ? Easing.inOut(Easing.ease) : Easing.out(Easing.quad);
10
9
  const offset = useSharedValue(0);
11
10
  const basic = useSharedValue('auto');
12
11
  const keyboardAvoid = useContext(KeyboardAvoidContext);
13
- // fix: 某些特殊机型下隐藏键盘可能会先触发一次 keyboardWillShow,
14
- // 比如机型 iPhone 11 Pro,可能会导致显隐动画冲突
15
- // 因此增加状态标记 + cancelAnimation 来优化
16
- const isShow = useRef(false);
17
12
  const animatedStyle = useAnimatedStyle(() => ({
18
- // translate/position top可能会导致底部渲染区域缺失
19
- marginTop: -offset.value,
13
+ transform: [{ translateY: -offset.value }],
20
14
  flexBasis: basic.value
21
15
  }));
22
16
  const resetKeyboard = () => {
23
- if (!isShow.current) {
24
- return;
25
- }
26
- isShow.current = false;
27
17
  if (keyboardAvoid?.current) {
28
- const inputRef = keyboardAvoid.current.ref?.current;
29
- if (inputRef && inputRef.isFocused()) {
30
- // 修复 Android 点击键盘收起按钮时当前 input 没触发失焦的问题
31
- inputRef.blur();
32
- }
33
18
  keyboardAvoid.current = null;
34
19
  }
35
- cancelAnimation(offset);
36
20
  offset.value = withTiming(0, { duration, easing });
37
21
  basic.value = 'auto';
38
22
  };
39
23
  const onTouchEnd = ({ nativeEvent }) => {
40
24
  if (nativeEvent.origin !== 'input') {
41
- if (keyboardAvoid?.current?.holdKeyboard) {
42
- return;
43
- }
44
25
  Keyboard.isVisible() && Keyboard.dismiss();
45
26
  }
46
27
  };
47
28
  useEffect(() => {
48
29
  let subscriptions = [];
49
- function keybaordAvoding(evt) {
50
- if (!keyboardAvoid?.current || isShow.current) {
51
- return;
52
- }
53
- isShow.current = true;
54
- const { endCoordinates } = evt;
55
- const { ref, cursorSpacing = 0, adjustPosition, onKeyboardShow } = keyboardAvoid.current;
56
- keyboardAvoid.current.keyboardHeight = endCoordinates.height;
57
- onKeyboardShow?.();
58
- if (adjustPosition) {
59
- // 默认沿用旧版本逻辑,在 android 原生关闭键盘避让的情况下应该将该配置设置为 false,走 mpx 的键盘避让逻辑,否则bundle内的所有input都会无法避让键盘
60
- const enableNativeKeyboardAvoiding = mpxGlobal?.__mpx?.config?.rnConfig?.enableNativeKeyboardAvoiding ?? true;
61
- const callback = () => {
62
- ref?.current?.measure((x, y, width, height, pageX, pageY) => {
63
- function calculateOffset() {
64
- // enableNativeKeyboardAvoding 默认开启
65
- if (enableNativeKeyboardAvoiding && isAndroid) {
66
- const aboveOffset = pageY + height - endCoordinates.screenY;
67
- const belowOffset = endCoordinates.height - aboveOffset;
68
- const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
69
- const belowValue = Math.min(belowOffset, cursorSpacing);
70
- return aboveOffset > 0 ? belowValue : aboveValue;
71
- }
30
+ if (isIOS) {
31
+ subscriptions = [
32
+ Keyboard.addListener('keyboardWillShow', (evt) => {
33
+ if (!keyboardAvoid?.current)
34
+ return;
35
+ const { endCoordinates } = evt;
36
+ const { ref, cursorSpacing = 0 } = keyboardAvoid.current;
37
+ setTimeout(() => {
38
+ ref?.current?.measure((x, y, width, height, pageX, pageY) => {
72
39
  const aboveOffset = offset.value + pageY + height - endCoordinates.screenY;
73
40
  const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
74
41
  const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing);
75
- return aboveOffset > 0 ? belowValue : aboveValue;
76
- }
77
- cancelAnimation(offset);
78
- offset.value = withTiming(calculateOffset(), { duration, easing }, finished => {
42
+ const value = aboveOffset > 0 ? belowValue : aboveValue;
43
+ offset.value = withTiming(value, { duration, easing }, (finished) => {
44
+ if (finished) {
45
+ // Set flexBasic after animation to trigger re-layout and reset layout information
46
+ basic.value = '99.99%';
47
+ }
48
+ });
49
+ });
50
+ });
51
+ }),
52
+ Keyboard.addListener('keyboardWillHide', resetKeyboard)
53
+ ];
54
+ }
55
+ else {
56
+ subscriptions = [
57
+ Keyboard.addListener('keyboardDidShow', (evt) => {
58
+ if (!keyboardAvoid?.current)
59
+ return;
60
+ const { endCoordinates } = evt;
61
+ const { ref, cursorSpacing = 0 } = keyboardAvoid.current;
62
+ ref?.current?.measure((x, y, width, height, pageX, pageY) => {
63
+ const aboveOffset = pageY + height - endCoordinates.screenY;
64
+ const belowOffset = endCoordinates.height - aboveOffset;
65
+ const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
66
+ const belowValue = Math.min(belowOffset, cursorSpacing);
67
+ const value = aboveOffset > 0 ? belowValue : aboveValue;
68
+ offset.value = withTiming(value, { duration, easing }, (finished) => {
79
69
  if (finished) {
80
70
  // Set flexBasic after animation to trigger re-layout and reset layout information
81
71
  basic.value = '99.99%';
82
72
  }
83
73
  });
84
74
  });
85
- };
86
- (isIOS ? () => setTimeout(callback) : callback)();
87
- }
88
- }
89
- if (isIOS) {
90
- subscriptions = [Keyboard.addListener('keyboardWillShow', keybaordAvoding), Keyboard.addListener('keyboardWillHide', resetKeyboard)];
91
- }
92
- else {
93
- subscriptions = [Keyboard.addListener('keyboardDidShow', keybaordAvoding), Keyboard.addListener('keyboardDidHide', resetKeyboard)];
75
+ }),
76
+ Keyboard.addListener('keyboardDidHide', resetKeyboard)
77
+ ];
94
78
  }
95
79
  return () => {
96
80
  subscriptions.forEach(subscription => subscription.remove());
97
81
  };
98
82
  }, [keyboardAvoid]);
99
- return (<View style={style} onTouchEnd={onTouchEnd} onTouchMove={onTouchEnd}>
100
- <Animated.View style={[contentContainerStyle, animatedStyle]}>{children}</Animated.View>
83
+ return (<View style={style} onTouchEnd={onTouchEnd}>
84
+ <Animated.View style={[
85
+ contentContainerStyle,
86
+ animatedStyle
87
+ ]}>
88
+ {children}
89
+ </Animated.View>
101
90
  </View>);
102
91
  };
103
92
  KeyboardAvoidingView.displayName = 'MpxKeyboardAvoidingView';
@@ -17,7 +17,7 @@ const styles = {
17
17
  };
18
18
  const DefaultPickerItemH = 36;
19
19
  const _PickerView = forwardRef((props, ref) => {
20
- const { children, value = [], bindchange, style, 'enable-wheel-animation': enableWheelAnimation = true, 'indicator-style': indicatorStyle = {}, 'mask-style': pickerMaskStyle = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext } = props;
20
+ const { children, value = [], bindchange, style, 'indicator-style': indicatorStyle = {}, 'mask-style': pickerMaskStyle = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext } = props;
21
21
  const { height: indicatorH, ...pickerIndicatorStyle } = indicatorStyle;
22
22
  const nodeRef = useRef(null);
23
23
  const cloneRef = useRef(null);
@@ -67,7 +67,7 @@ const _PickerView = forwardRef((props, ref) => {
67
67
  columnData,
68
68
  ref: cloneRef,
69
69
  columnIndex: index,
70
- key: `pick-view-${index}-${columnData.length}`,
70
+ key: `pick-view-${index}`,
71
71
  wrapperStyle: {
72
72
  height: normalStyle?.height || DefaultPickerItemH,
73
73
  itemHeight: indicatorH || DefaultPickerItemH
@@ -75,8 +75,7 @@ const _PickerView = forwardRef((props, ref) => {
75
75
  onSelectChange: onSelectChange.bind(null, index),
76
76
  initialIndex,
77
77
  pickerIndicatorStyle,
78
- pickerMaskStyle,
79
- enableWheelAnimation
78
+ pickerMaskStyle
80
79
  });
81
80
  const realElement = React.cloneElement(child, wrappedProps);
82
81
  return wrapChildren({
@@ -5,13 +5,12 @@ import { useTransformStyle, splitStyle, splitProps, useLayout, usePrevious, isAn
5
5
  import useNodesRef from '../useNodesRef';
6
6
  import PickerIndicator from './pickerViewIndicator';
7
7
  import PickerMask from './pickerViewMask';
8
- import MpxPickerViewColumnItem from './pickerViewColumnItem';
9
- import MpxPickerViewColumnItemLite from './pickerViewColumnItemLite';
8
+ import MpxPickerVIewColumnItem from './pickerViewColumnItem';
10
9
  import { PickerViewColumnAnimationContext } from '../mpx-picker-view/pickerVIewContext';
11
10
  import { calcHeightOffsets } from './pickerViewFaces';
12
11
  const visibleCount = 5;
13
12
  const _PickerViewColumn = forwardRef((props, ref) => {
14
- const { columnData, columnIndex, initialIndex, onSelectChange, style, wrapperStyle, pickerMaskStyle, pickerIndicatorStyle, enableWheelAnimation = true, 'enable-var': enableVar, 'external-var-context': externalVarContext } = props;
13
+ const { columnData, columnIndex, initialIndex, onSelectChange, style, wrapperStyle, pickerMaskStyle, pickerIndicatorStyle, 'enable-var': enableVar, 'external-var-context': externalVarContext } = props;
15
14
  const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext });
16
15
  const { textStyle = {} } = splitStyle(normalStyle);
17
16
  const { textProps = {} } = splitProps(props);
@@ -44,7 +43,6 @@ const _PickerViewColumn = forwardRef((props, ref) => {
44
43
  const contentContainerStyle = useMemo(() => {
45
44
  return [{ paddingVertical: paddingHeight }];
46
45
  }, [paddingHeight]);
47
- const initialContentOffsetY = useMemo(() => initialIndex * itemRawH, [initialIndex, itemRawH]);
48
46
  const getIndex = useCallback((y) => {
49
47
  const calc = Math.round(y / itemRawH);
50
48
  return Math.max(0, Math.min(calc, maxIndex));
@@ -94,6 +92,16 @@ const _PickerViewColumn = forwardRef((props, ref) => {
94
92
  activeIndex.current = initialIndex;
95
93
  }, isIOS ? 0 : 200);
96
94
  }, [itemRawH, maxIndex, initialIndex]);
95
+ const onContentSizeChange = useCallback((_w, h) => {
96
+ const y = initialIndex * itemRawH;
97
+ if (y <= h) {
98
+ clearTimerScrollTo();
99
+ timerScrollTo.current = setTimeout(() => {
100
+ scrollViewRef.current?.scrollTo({ x: 0, y, animated: false });
101
+ activeIndex.current = initialIndex;
102
+ }, 0);
103
+ }
104
+ }, [itemRawH, initialIndex]);
97
105
  const onItemLayout = useCallback((e) => {
98
106
  const { height: rawH } = e.nativeEvent.layout;
99
107
  const roundedH = Math.round(rawH);
@@ -209,9 +217,7 @@ const _PickerViewColumn = forwardRef((props, ref) => {
209
217
  }
210
218
  }, [itemRawH, maxIndex, calcOffset, onMomentumScrollEnd]);
211
219
  const renderInnerchild = () => columnData.map((item, index) => {
212
- return enableWheelAnimation
213
- ? (<MpxPickerViewColumnItem key={index} item={item} index={index} itemHeight={itemHeight} textStyle={textStyle} textProps={textProps} visibleCount={visibleCount} onItemLayout={onItemLayout}/>)
214
- : (<MpxPickerViewColumnItemLite key={index} item={item} index={index} itemHeight={itemHeight} textStyle={textStyle} textProps={textProps} onItemLayout={onItemLayout}/>);
220
+ return (<MpxPickerVIewColumnItem key={index} item={item} index={index} itemHeight={itemHeight} textStyle={textStyle} textProps={textProps} visibleCount={visibleCount} onItemLayout={onItemLayout}/>);
215
221
  });
216
222
  const renderScollView = () => {
217
223
  const innerProps = extendObject({}, layoutProps, {
@@ -232,17 +238,17 @@ const _PickerViewColumn = forwardRef((props, ref) => {
232
238
  onScrollEndDrag,
233
239
  onMomentumScrollBegin,
234
240
  onMomentumScrollEnd,
235
- contentContainerStyle,
236
- contentOffset: { x: 0, y: initialContentOffsetY }
241
+ onContentSizeChange,
242
+ contentContainerStyle
237
243
  });
238
244
  return createElement(PickerViewColumnAnimationContext.Provider, { value: offsetYShared }, createElement(Reanimated.ScrollView, innerProps, renderInnerchild()));
239
245
  };
240
246
  const renderIndicator = () => (<PickerIndicator itemHeight={itemHeight} indicatorItemStyle={pickerIndicatorStyle}/>);
241
247
  const renderMask = () => (<PickerMask itemHeight={itemHeight} maskContainerStyle={pickerMaskStyle}/>);
242
248
  return (<View style={[styles.wrapper, normalStyle]}>
243
- {renderScollView()}
244
- {renderMask()}
245
- {renderIndicator()}
249
+ {renderScollView()}
250
+ {renderMask()}
251
+ {renderIndicator()}
246
252
  </View>);
247
253
  });
248
254
  const styles = StyleSheet.create({
@@ -1,20 +1,23 @@
1
- import React, { useMemo } from 'react';
2
- import Reanimated, { Extrapolation, interpolate, useAnimatedStyle } from 'react-native-reanimated';
1
+ import React, { useEffect } from 'react';
2
+ import Reanimated, { Extrapolation, interpolate, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
3
3
  import { extendObject } from '../utils';
4
4
  import { createFaces } from './pickerViewFaces';
5
5
  import { usePickerViewColumnAnimationContext, usePickerViewStyleContext } from '../mpx-picker-view/pickerVIewContext';
6
6
  const PickerViewColumnItem = ({ item, index, itemHeight, itemWidth = '100%', textStyle, textProps, visibleCount, onItemLayout }) => {
7
7
  const textStyleFromAncestor = usePickerViewStyleContext();
8
8
  const offsetYShared = usePickerViewColumnAnimationContext();
9
- const facesShared = useMemo(() => createFaces(itemHeight, visibleCount), [itemHeight, visibleCount]);
9
+ const facesShared = useSharedValue(createFaces(itemHeight, visibleCount));
10
+ useEffect(() => {
11
+ facesShared.value = createFaces(itemHeight, visibleCount);
12
+ }, [itemHeight]);
10
13
  const animatedStyles = useAnimatedStyle(() => {
11
- const inputRange = facesShared.map((f) => itemHeight * (index + f.index));
14
+ const inputRange = facesShared.value.map((f) => itemHeight * (index + f.index));
12
15
  return {
13
- opacity: interpolate(offsetYShared.value, inputRange, facesShared.map((x) => x.opacity), Extrapolation.CLAMP),
16
+ opacity: interpolate(offsetYShared.value, inputRange, facesShared.value.map((x) => x.opacity), Extrapolation.CLAMP),
14
17
  transform: [
15
- { translateY: interpolate(offsetYShared.value, inputRange, facesShared.map((x) => x.offsetY), Extrapolation.EXTEND) },
16
- { rotateX: interpolate(offsetYShared.value, inputRange, facesShared.map((x) => x.deg), Extrapolation.CLAMP) + 'deg' },
17
- { scale: interpolate(offsetYShared.value, inputRange, facesShared.map((x) => x.scale), Extrapolation.EXTEND) }
18
+ { translateY: interpolate(offsetYShared.value, inputRange, facesShared.value.map((x) => x.offsetY), Extrapolation.EXTEND) },
19
+ { rotateX: interpolate(offsetYShared.value, inputRange, facesShared.value.map((x) => x.deg), Extrapolation.CLAMP) + 'deg' },
20
+ { scale: interpolate(offsetYShared.value, inputRange, facesShared.value.map((x) => x.scale), Extrapolation.EXTEND) }
18
21
  ]
19
22
  };
20
23
  });
@@ -1,18 +1,14 @@
1
1
  import { useContext, useEffect, useRef } from 'react';
2
- import { PortalContext, ProviderContext, RouteContext, VarContext } from '../context';
2
+ import { PortalContext, RouteContext, VarContext } from '../context';
3
3
  import PortalHost, { portal } from './portal-host';
4
4
  const Portal = ({ children }) => {
5
5
  const manager = useContext(PortalContext);
6
6
  const keyRef = useRef(null);
7
7
  const { pageId } = useContext(RouteContext) || {};
8
8
  const varContext = useContext(VarContext);
9
- const parentProvides = useContext(ProviderContext);
10
9
  if (varContext) {
11
10
  children = (<VarContext.Provider value={varContext} key='varContextWrap'>{children}</VarContext.Provider>);
12
11
  }
13
- if (parentProvides) {
14
- children = (<ProviderContext.Provider value={parentProvides} key='providerContextWrap'>{children}</ProviderContext.Provider>);
15
- }
16
12
  useEffect(() => {
17
13
  manager.update(keyRef.current, children);
18
14
  }, [children]);
@@ -48,6 +48,8 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
48
48
  const scrollOffset = useRef(new RNAnimated.Value(0)).current;
49
49
  const simultaneousHandlers = flatGesture(originSimultaneousHandlers);
50
50
  const waitForHandlers = flatGesture(waitFor);
51
+ const snapScrollTop = useRef(0);
52
+ const snapScrollLeft = useRef(0);
51
53
  const [refreshing, setRefreshing] = useState(false);
52
54
  const [enableScroll, setEnableScroll] = useState(true);
53
55
  const enableScrollValue = useSharedValue(true);
@@ -125,12 +127,14 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
125
127
  warn('scroll-x and scroll-y cannot be set to true at the same time, Mpx will use the value of scroll-y as the criterion');
126
128
  }
127
129
  useEffect(() => {
128
- initialTimeout.current = setTimeout(() => {
129
- scrollToOffset(scrollLeft, scrollTop);
130
- }, 0);
131
- return () => {
132
- initialTimeout.current && clearTimeout(initialTimeout.current);
133
- };
130
+ if (snapScrollTop.current !== scrollTop || snapScrollLeft.current !== scrollLeft) {
131
+ initialTimeout.current = setTimeout(() => {
132
+ scrollToOffset(scrollLeft, scrollTop);
133
+ }, 0);
134
+ return () => {
135
+ initialTimeout.current && clearTimeout(initialTimeout.current);
136
+ };
137
+ }
134
138
  }, [scrollTop, scrollLeft]);
135
139
  useEffect(() => {
136
140
  if (scrollIntoView && __selectRef) {
@@ -312,6 +316,10 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
312
316
  function scrollToOffset(x = 0, y = 0, animated = scrollWithAnimation) {
313
317
  if (scrollViewRef.current) {
314
318
  scrollViewRef.current.scrollTo({ x, y, animated });
319
+ scrollOptions.current.scrollLeft = x;
320
+ scrollOptions.current.scrollTop = y;
321
+ snapScrollLeft.current = x;
322
+ snapScrollTop.current = y;
315
323
  }
316
324
  }
317
325
  function onScrollTouchMove(e) {
@@ -71,7 +71,7 @@ const easeMap = {
71
71
  easeInOutCubic: Easing.inOut(Easing.cubic)
72
72
  };
73
73
  const SwiperWrapper = forwardRef((props, ref) => {
74
- const { 'indicator-dots': showPagination, 'indicator-color': dotColor = 'rgba(0, 0, 0, .3)', 'indicator-active-color': activeDotColor = '#000000', 'enable-var': enableVar = false, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'external-var-context': externalVarContext, 'simultaneous-handlers': originSimultaneousHandlers = [], 'wait-for': waitFor = [], style = {}, autoplay = false, circular = false, disableGesture = false, current: propCurrent = 0, bindchange } = props;
74
+ const { 'indicator-dots': showPagination, 'indicator-color': dotColor = 'rgba(0, 0, 0, .3)', 'indicator-active-color': activeDotColor = '#000000', 'enable-var': enableVar = false, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'external-var-context': externalVarContext, 'simultaneous-handlers': originSimultaneousHandlers = [], 'wait-for': waitFor = [], style = {}, autoplay = false, circular = false, disableGesture = false, current: propCurrent, bindchange } = props;
75
75
  const easeingFunc = props['easing-function'] || 'default';
76
76
  const easeDuration = props.duration || 500;
77
77
  const horizontal = props.vertical !== undefined ? !props.vertical : true;
@@ -112,10 +112,10 @@ const SwiperWrapper = forwardRef((props, ref) => {
112
112
  // 每个元素的宽度 or 高度,有固定值直接初始化无则0
113
113
  const step = useSharedValue(initStep);
114
114
  // 记录选中元素的索引值
115
- const currentIndex = useSharedValue(propCurrent);
115
+ const currentIndex = useSharedValue(propCurrent || 0);
116
116
  // const initOffset = getOffset(props.current || 0, initStep)
117
117
  // 记录元素的偏移量
118
- const offset = useSharedValue(getOffset(propCurrent, initStep));
118
+ const offset = useSharedValue(getOffset(propCurrent || 0, initStep));
119
119
  const strAbso = 'absolute' + dir.toUpperCase();
120
120
  const strVelocity = 'velocity' + dir.toUpperCase();
121
121
  // 标识手指触摸和抬起, 起点在onBegin
@@ -170,7 +170,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
170
170
  const iStep = dir === 'x' ? realWidth : realHeight;
171
171
  if (iStep !== step.value) {
172
172
  step.value = iStep;
173
- updateCurrent(propCurrent, iStep);
173
+ updateCurrent(propCurrent || 0, iStep);
174
174
  updateAutoplay();
175
175
  }
176
176
  }
@@ -414,7 +414,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
414
414
  // 1. 如果用户在touch的过程中, 外部更新了current以外部为准(小程序表现)
415
415
  // 2. 手指滑动过程中更新索引,外部会把current再传入进来,导致offset直接更新,增加判断不同才更新
416
416
  if (propCurrent !== currentIndex.value) {
417
- updateCurrent(propCurrent, step.value);
417
+ updateCurrent(propCurrent || 0, step.value);
418
418
  }
419
419
  }, [propCurrent]);
420
420
  useEffect(() => {
@@ -696,6 +696,10 @@ const SwiperWrapper = forwardRef((props, ref) => {
696
696
  offset.value = moveDistance + offset.value;
697
697
  }
698
698
  preAbsolutePos.value = e[strAbso];
699
+ })
700
+ .onEnd((e) => {
701
+ // 修复部分安卓机型下onFinalize拿到的absolute值 和 onUpdate不一致的情况,通过onEnd进行修正为最终的位置
702
+ preAbsolutePos.value = e[strAbso];
699
703
  })
700
704
  .onFinalize((e) => {
701
705
  'worklet';
@@ -1,40 +1,16 @@
1
1
  /**
2
2
  * ✔ selectable
3
3
  * ✘ space
4
- * decode
4
+ * decode
5
5
  */
6
6
  import { Text } from 'react-native';
7
- import { useRef, forwardRef, createElement, Children } from 'react';
7
+ import { useRef, forwardRef, createElement } from 'react';
8
8
  import Portal from './mpx-portal';
9
9
  import useInnerProps from './getInnerListeners';
10
10
  import useNodesRef from './useNodesRef'; // 引入辅助函数
11
11
  import { useTransformStyle, wrapChildren, extendObject } from './utils';
12
- const decodeMap = {
13
- '&lt;': '<',
14
- '&gt;': '>',
15
- '&quot;': '"',
16
- '&amp;': '&',
17
- '&#39;': '\'',
18
- '&nbsp;': ' '
19
- };
20
- const encodedRe = /&(?:lt|gt|quot|amp|#39|nbsp);/g;
21
- function decode(value) {
22
- if (value != null) {
23
- return value.replace(encodedRe, function (match) {
24
- return decodeMap[match];
25
- });
26
- }
27
- }
28
- function getDecodedChildren(children) {
29
- return Children.map(children, (child) => {
30
- if (typeof child === 'string') {
31
- return decode(child);
32
- }
33
- return child;
34
- });
35
- }
36
12
  const _Text = forwardRef((props, ref) => {
37
- const { style = {}, allowFontScaling = false, selectable, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'user-select': userSelect, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, decode } = props;
13
+ const { style = {}, allowFontScaling = false, selectable, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'user-select': userSelect, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
38
14
  const { normalStyle, hasVarDec, varContextRef, hasPositionFixed } = useTransformStyle(style, {
39
15
  enableVar,
40
16
  externalVarContext,
@@ -52,13 +28,9 @@ const _Text = forwardRef((props, ref) => {
52
28
  selectable: !!selectable || !!userSelect,
53
29
  allowFontScaling
54
30
  }), [
55
- 'user-select',
56
- 'decode'
31
+ 'user-select'
57
32
  ]);
58
- const children = decode ? getDecodedChildren(props.children) : props.children;
59
- let finalComponent = createElement(Text, innerProps, wrapChildren(extendObject({}, props, {
60
- children
61
- }), {
33
+ let finalComponent = createElement(Text, innerProps, wrapChildren(props, {
62
34
  hasVarDec,
63
35
  varContext: varContextRef.current
64
36
  }));
@@ -398,7 +398,7 @@ function parseLinearGradient(text) {
398
398
  });
399
399
  }
400
400
  function parseBgImage(text) {
401
- if (!text || text === 'none')
401
+ if (!text)
402
402
  return {};
403
403
  const src = parseUrl(text);
404
404
  if (src)
@@ -176,7 +176,7 @@ const _WebView = forwardRef((props, ref) => {
176
176
  }
177
177
  break;
178
178
  case 'postMessage':
179
- bindmessage && bindmessage(getCustomEvent('message', {}, {
179
+ bindmessage && bindmessage(getCustomEvent('messsage', {}, {
180
180
  detail: {
181
181
  data: params[0]?.data
182
182
  }
@@ -169,34 +169,24 @@ function transformPercent(styleObj, percentKeyPaths, percentConfig) {
169
169
  function resolveVar(input, varContext) {
170
170
  const parsed = parseFunc(input, 'var');
171
171
  const replaced = new ReplaceSource(input);
172
- for (const { start, end, args } of parsed) {
172
+ parsed.forEach(({ start, end, args }) => {
173
173
  const varName = args[0];
174
- const fallback = args[1];
174
+ const fallback = args[1] || '';
175
175
  let varValue = hasOwn(varContext, varName) ? varContext[varName] : fallback;
176
- if (varValue === undefined)
177
- return;
178
176
  if (varUseRegExp.test(varValue)) {
179
- varValue = resolveVar(varValue, varContext);
180
- if (varValue === undefined)
181
- return;
177
+ varValue = '' + resolveVar(varValue, varContext);
182
178
  }
183
179
  else {
184
- varValue = global.__formatValue(varValue);
180
+ varValue = '' + global.__formatValue(varValue);
185
181
  }
186
182
  replaced.replace(start, end - 1, varValue);
187
- }
183
+ });
188
184
  return global.__formatValue(replaced.source());
189
185
  }
190
186
  function transformVar(styleObj, varKeyPaths, varContext, visitOther) {
191
187
  varKeyPaths.forEach((varKeyPath) => {
192
188
  setStyle(styleObj, varKeyPath, ({ target, key, value }) => {
193
- const resolved = resolveVar(value, varContext);
194
- if (resolved === undefined) {
195
- delete target[key];
196
- error(`Can not resolve css var at ${varKeyPath.join('.')}:${value}.`);
197
- return;
198
- }
199
- target[key] = resolved;
189
+ target[key] = resolveVar(value, varContext);
200
190
  visitOther({ target, key, value: target[key], keyPath: varKeyPath });
201
191
  });
202
192
  });