@mpxjs/webpack-plugin 2.10.17 → 2.10.18-beta.10

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 (275) hide show
  1. package/lib/config.js +60 -0
  2. package/lib/file-loader.js +4 -1
  3. package/lib/global.d.ts +231 -0
  4. package/lib/index.js +71 -74
  5. package/lib/init.js +3 -0
  6. package/lib/json-compiler/index.js +13 -4
  7. package/lib/loader.js +4 -0
  8. package/lib/platform/json/wx/index.js +6 -0
  9. package/lib/platform/style/wx/index.js +102 -72
  10. package/lib/platform/template/wx/component-config/ad.js +5 -0
  11. package/lib/platform/template/wx/component-config/button.js +10 -3
  12. package/lib/platform/template/wx/component-config/camera.js +25 -3
  13. package/lib/platform/template/wx/component-config/canvas.js +8 -1
  14. package/lib/platform/template/wx/component-config/cover-image.js +7 -2
  15. package/lib/platform/template/wx/component-config/cover-view.js +3 -1
  16. package/lib/platform/template/wx/component-config/form.js +27 -2
  17. package/lib/platform/template/wx/component-config/image.js +5 -0
  18. package/lib/platform/template/wx/component-config/input.js +10 -0
  19. package/lib/platform/template/wx/component-config/label.js +10 -2
  20. package/lib/platform/template/wx/component-config/map.js +11 -0
  21. package/lib/platform/template/wx/component-config/movable-area.js +4 -1
  22. package/lib/platform/template/wx/component-config/movable-view.js +17 -2
  23. package/lib/platform/template/wx/component-config/navigator.js +26 -0
  24. package/lib/platform/template/wx/component-config/picker-view.js +12 -0
  25. package/lib/platform/template/wx/component-config/picker.js +3 -1
  26. package/lib/platform/template/wx/component-config/progress.js +11 -1
  27. package/lib/platform/template/wx/component-config/rich-text.js +5 -0
  28. package/lib/platform/template/wx/component-config/scroll-view.js +12 -1
  29. package/lib/platform/template/wx/component-config/slider.js +8 -0
  30. package/lib/platform/template/wx/component-config/swiper-item.js +5 -2
  31. package/lib/platform/template/wx/component-config/swiper.js +10 -0
  32. package/lib/platform/template/wx/component-config/text.js +5 -0
  33. package/lib/platform/template/wx/component-config/textarea.js +19 -2
  34. package/lib/platform/template/wx/component-config/titlebar.js +12 -0
  35. package/lib/platform/template/wx/component-config/unsupported.js +10 -1
  36. package/lib/platform/template/wx/component-config/video.js +10 -0
  37. package/lib/platform/template/wx/index.js +21 -1
  38. package/lib/react/LoadAsyncChunkModule.js +3 -6
  39. package/lib/react/processStyles.js +21 -9
  40. package/lib/react/script-helper.js +2 -2
  41. package/lib/react/style-helper.js +76 -13
  42. package/lib/resolver/AddModePlugin.js +17 -7
  43. package/lib/resolver/ExtendComponentsPlugin.js +60 -0
  44. package/lib/runtime/components/ali/mpx-section-list.mpx +566 -0
  45. package/lib/runtime/components/ali/mpx-sticky-header.mpx +212 -0
  46. package/lib/runtime/components/ali/mpx-sticky-section.mpx +17 -0
  47. package/lib/runtime/components/react/animationHooks/index.ts +75 -0
  48. package/lib/runtime/components/react/animationHooks/useAnimationAPIHooks.ts +197 -0
  49. package/lib/runtime/components/react/animationHooks/useTransitionHooks.ts +301 -0
  50. package/lib/runtime/components/react/animationHooks/utils.ts +197 -0
  51. package/lib/runtime/components/react/context.ts +12 -3
  52. package/lib/runtime/components/react/dist/animationHooks/index.d.ts +15 -0
  53. package/lib/runtime/components/react/dist/animationHooks/index.js +67 -0
  54. package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.d.ts +3 -0
  55. package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.js +181 -0
  56. package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.d.ts +3 -0
  57. package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.js +279 -0
  58. package/lib/runtime/components/react/dist/animationHooks/utils.d.ts +109 -0
  59. package/lib/runtime/components/react/dist/animationHooks/utils.js +151 -0
  60. package/lib/runtime/components/react/dist/context.d.ts +10 -3
  61. package/lib/runtime/components/react/dist/context.js +1 -2
  62. package/lib/runtime/components/react/dist/event.config.d.ts +0 -1
  63. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +0 -1
  64. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +0 -1
  65. package/lib/runtime/components/react/dist/mpx-async-suspense.jsx +3 -1
  66. package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -1
  67. package/lib/runtime/components/react/dist/mpx-camera.d.ts +31 -0
  68. package/lib/runtime/components/react/dist/mpx-camera.jsx +236 -0
  69. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +0 -1
  70. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +0 -1
  71. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +0 -1
  72. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +0 -1
  73. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +0 -1
  74. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +0 -1
  75. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +0 -1
  76. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
  77. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +0 -1
  78. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
  79. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -1
  80. package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -1
  81. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
  82. package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
  83. package/lib/runtime/components/react/dist/mpx-image.jsx +2 -2
  84. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +0 -1
  85. package/lib/runtime/components/react/dist/mpx-input.d.ts +2 -1
  86. package/lib/runtime/components/react/dist/mpx-input.jsx +69 -50
  87. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +0 -1
  88. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +35 -6
  89. package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -1
  90. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
  91. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -1
  92. package/lib/runtime/components/react/dist/mpx-nav.d.ts +0 -1
  93. package/lib/runtime/components/react/dist/mpx-navigator.d.ts +0 -1
  94. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +0 -1
  95. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +0 -1
  96. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +0 -1
  97. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +0 -1
  98. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +0 -1
  99. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +0 -1
  100. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +0 -1
  101. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +0 -1
  102. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +0 -1
  103. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +0 -1
  104. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -1
  105. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -1
  106. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -1
  107. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -1
  108. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +0 -1
  109. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +0 -1
  110. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +0 -1
  111. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +0 -1
  112. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +0 -1
  113. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +0 -1
  114. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +0 -1
  115. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +0 -1
  116. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +2 -2
  117. package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
  118. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
  119. package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -1
  120. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +0 -1
  121. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
  122. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +0 -1
  123. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -1
  124. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +84 -78
  125. package/lib/runtime/components/react/dist/mpx-section-list.d.ts +48 -0
  126. package/lib/runtime/components/react/dist/mpx-section-list.jsx +292 -0
  127. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +0 -1
  128. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -1
  129. package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
  130. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -1
  131. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +20 -20
  132. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -1
  133. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -1
  134. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +11 -1
  135. package/lib/runtime/components/react/dist/mpx-swiper.jsx +136 -83
  136. package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
  137. package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
  138. package/lib/runtime/components/react/dist/mpx-textarea.d.ts +0 -1
  139. package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -0
  140. package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
  141. package/lib/runtime/components/react/dist/mpx-view.d.ts +3 -3
  142. package/lib/runtime/components/react/dist/mpx-view.jsx +22 -8
  143. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +0 -1
  144. package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
  145. package/lib/runtime/components/react/dist/parser.d.ts +0 -1
  146. package/lib/runtime/components/react/dist/useNodesRef.d.ts +0 -1
  147. package/lib/runtime/components/react/dist/utils.d.ts +10 -9
  148. package/lib/runtime/components/react/dist/utils.jsx +47 -24
  149. package/lib/runtime/components/react/mpx-async-suspense.tsx +3 -1
  150. package/lib/runtime/components/react/mpx-camera.tsx +327 -0
  151. package/lib/runtime/components/react/mpx-image.tsx +2 -2
  152. package/lib/runtime/components/react/mpx-input.tsx +71 -52
  153. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +35 -6
  154. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +10 -0
  155. package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +2 -2
  156. package/lib/runtime/components/react/mpx-scroll-view.tsx +110 -114
  157. package/lib/runtime/components/react/mpx-section-list.tsx +439 -0
  158. package/lib/runtime/components/react/mpx-sticky-header.tsx +24 -24
  159. package/lib/runtime/components/react/mpx-swiper.tsx +174 -84
  160. package/lib/runtime/components/react/mpx-textarea.tsx +1 -0
  161. package/lib/runtime/components/react/mpx-view.tsx +27 -12
  162. package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
  163. package/lib/runtime/components/react/tsconfig.json +26 -0
  164. package/lib/runtime/components/react/types/global.d.ts +1 -0
  165. package/lib/runtime/components/react/utils.tsx +51 -27
  166. package/lib/runtime/components/web/mpx-scroll-view.vue +5 -2
  167. package/lib/runtime/components/web/mpx-section-list.vue +551 -0
  168. package/lib/runtime/components/web/mpx-titlebar.vue +244 -0
  169. package/lib/runtime/components/wx/mpx-section-list-default/list-footer.mpx +26 -0
  170. package/lib/runtime/components/wx/mpx-section-list-default/list-header.mpx +26 -0
  171. package/lib/runtime/components/wx/mpx-section-list-default/list-item.mpx +26 -0
  172. package/lib/runtime/components/wx/mpx-section-list-default/section-header.mpx +26 -0
  173. package/lib/runtime/components/wx/mpx-section-list.mpx +209 -0
  174. package/lib/runtime/components/wx/mpx-sticky-header.mpx +40 -0
  175. package/lib/runtime/components/wx/mpx-sticky-section.mpx +31 -0
  176. package/lib/runtime/optionProcessor.js +5 -0
  177. package/lib/runtime/optionProcessorReact.js +7 -0
  178. package/lib/runtime/stringify.wxs +2 -2
  179. package/lib/script-setup-compiler/index.js +1 -2
  180. package/lib/style-compiler/strip-conditional.js +244 -0
  181. package/lib/template-compiler/compiler.js +89 -9
  182. package/lib/utils/const.js +29 -0
  183. package/lib/utils/dom-tag-config.js +1 -1
  184. package/lib/utils/string.js +25 -1
  185. package/lib/web/processMainScript.js +3 -1
  186. package/lib/wxss/loader.js +4 -1
  187. package/lib/wxss/utils.js +7 -2
  188. package/package.json +7 -14
  189. package/LICENSE +0 -433
  190. package/lib/runtime/components/react/dist/context.d.ts.map +0 -1
  191. package/lib/runtime/components/react/dist/event.config.d.ts.map +0 -1
  192. package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +0 -1
  193. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +0 -1
  194. package/lib/runtime/components/react/dist/mpx-button.d.ts.map +0 -1
  195. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +0 -1
  196. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +0 -1
  197. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +0 -1
  198. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +0 -1
  199. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +0 -1
  200. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +0 -1
  201. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +0 -1
  202. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +0 -1
  203. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +0 -1
  204. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +0 -1
  205. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +0 -1
  206. package/lib/runtime/components/react/dist/mpx-form.d.ts.map +0 -1
  207. package/lib/runtime/components/react/dist/mpx-icon/icons/cancel.png +0 -0
  208. package/lib/runtime/components/react/dist/mpx-icon/icons/clear.png +0 -0
  209. package/lib/runtime/components/react/dist/mpx-icon/icons/download.png +0 -0
  210. package/lib/runtime/components/react/dist/mpx-icon/icons/info.png +0 -0
  211. package/lib/runtime/components/react/dist/mpx-icon/icons/search.png +0 -0
  212. package/lib/runtime/components/react/dist/mpx-icon/icons/success.png +0 -0
  213. package/lib/runtime/components/react/dist/mpx-icon/icons/success_no_circle.png +0 -0
  214. package/lib/runtime/components/react/dist/mpx-icon/icons/waiting.png +0 -0
  215. package/lib/runtime/components/react/dist/mpx-icon/icons/warn.png +0 -0
  216. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +0 -1
  217. package/lib/runtime/components/react/dist/mpx-image.d.ts.map +0 -1
  218. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +0 -1
  219. package/lib/runtime/components/react/dist/mpx-input.d.ts.map +0 -1
  220. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +0 -1
  221. package/lib/runtime/components/react/dist/mpx-label.d.ts.map +0 -1
  222. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +0 -1
  223. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +0 -1
  224. package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +0 -1
  225. package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +0 -1
  226. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +0 -1
  227. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +0 -1
  228. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +0 -1
  229. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +0 -1
  230. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +0 -1
  231. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +0 -1
  232. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +0 -1
  233. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +0 -1
  234. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +0 -1
  235. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +0 -1
  236. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +0 -1
  237. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +0 -1
  238. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +0 -1
  239. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +0 -1
  240. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +0 -1
  241. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +0 -1
  242. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +0 -1
  243. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +0 -1
  244. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +0 -1
  245. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +0 -1
  246. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +0 -1
  247. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +0 -1
  248. package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +0 -1
  249. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +0 -1
  250. package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +0 -1
  251. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +0 -1
  252. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +0 -1
  253. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +0 -1
  254. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +0 -1
  255. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +0 -1
  256. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +0 -1
  257. package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +0 -1
  258. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +0 -1
  259. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +0 -1
  260. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +0 -1
  261. package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +0 -1
  262. package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +0 -1
  263. package/lib/runtime/components/react/dist/mpx-text.d.ts.map +0 -1
  264. package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +0 -1
  265. package/lib/runtime/components/react/dist/mpx-video.d.ts.map +0 -1
  266. package/lib/runtime/components/react/dist/mpx-view.d.ts.map +0 -1
  267. package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +0 -1
  268. package/lib/runtime/components/react/dist/parser.d.ts.map +0 -1
  269. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +0 -33
  270. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +0 -1
  271. package/lib/runtime/components/react/dist/useAnimationHooks.js +0 -289
  272. package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +0 -1
  273. package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
  274. package/lib/runtime/components/react/useAnimationHooks.ts +0 -320
  275. package/lib/style-compiler/strip-conditional-loader.js +0 -289
@@ -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
@@ -95,13 +95,16 @@ export interface InputProps {
95
95
  'selection-start'?: number
96
96
  'selection-end'?: number
97
97
  'placeholder-style'?: { color?: string }
98
- 'enable-offset'?: boolean,
98
+ 'enable-offset'?: boolean
99
99
  'enable-var'?: boolean
100
100
  'external-var-context'?: Record<string, any>
101
101
  'parent-font-size'?: number
102
102
  'parent-width'?: number
103
103
  'parent-height'?: number
104
- 'adjust-position': boolean,
104
+ // 只有 RN 环境读取
105
+ 'keyboard-type'?: string
106
+ 'adjust-position': boolean
107
+ 'hold-keyboard'?: boolean
105
108
  bindinput?: (evt: NativeSyntheticEvent<TextInputTextInputEventData> | unknown) => void
106
109
  bindfocus?: (evt: NativeSyntheticEvent<TextInputFocusEventData> | unknown) => void
107
110
  bindblur?: (evt: NativeSyntheticEvent<TextInputFocusEventData> | unknown) => void
@@ -118,11 +121,11 @@ export interface PrivateInputProps {
118
121
 
119
122
  type FinalInputProps = InputProps & PrivateInputProps
120
123
 
121
- const keyboardTypeMap: Record<Type, string> = {
122
- text: 'default',
124
+ const inputModeMap: Record<Type, string> = {
125
+ text: 'text',
123
126
  number: 'numeric',
124
- idcard: 'default',
125
- digit: isIOS ? 'decimal-pad' : 'numeric'
127
+ idcard: 'text',
128
+ digit: 'decimal'
126
129
  }
127
130
 
128
131
  const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps>((props: FinalInputProps, ref): JSX.Element => {
@@ -150,6 +153,8 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
150
153
  'parent-width': parentWidth,
151
154
  'parent-height': parentHeight,
152
155
  'adjust-position': adjustPosition = true,
156
+ 'keyboard-type': originalKeyboardType,
157
+ 'hold-keyboard': holdKeyboard = false,
153
158
  bindinput,
154
159
  bindfocus,
155
160
  bindblur,
@@ -182,9 +187,11 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
182
187
  return ''
183
188
  }
184
189
 
185
- const keyboardType = keyboardTypeMap[type]
186
190
  const defaultValue = parseValue(value)
191
+ // 微信小程序的 input 永远是单行,textAlignVertical 固定为 auto
192
+ // multiline 为 true 时表示是 textarea 组件复用此逻辑
187
193
  const textAlignVertical = multiline ? 'top' : 'auto'
194
+ const isAutoFocus = !!autoFocus || !!focus
188
195
 
189
196
  const tmpValue = useRef<string>(defaultValue)
190
197
  const cursorIndex = useRef<number>(0)
@@ -193,13 +200,10 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
193
200
  const [inputValue, setInputValue] = useState(defaultValue)
194
201
  const [contentHeight, setContentHeight] = useState(0)
195
202
  const [selection, setSelection] = useState({ start: -1, end: tmpValue.current.length })
196
-
197
203
  const styleObj = extendObject(
198
204
  { padding: 0, backgroundColor: '#fff' },
199
205
  style,
200
- multiline && autoHeight
201
- ? { height: 'auto', minHeight: Math.max((style as any)?.minHeight || 35, contentHeight) }
202
- : {}
206
+ multiline && autoHeight ? { height: 'auto' } : {}
203
207
  )
204
208
 
205
209
  const {
@@ -281,12 +285,16 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
281
285
 
282
286
  const setKeyboardAvoidContext = () => {
283
287
  if (keyboardAvoid) {
284
- keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition }
288
+ // readyToShow 仅在从另一个输入框切换聚焦时为 true(ref 不同),
289
+ // 避免同一个输入框重复调用(onTouchStart + useEffect)或单次聚焦时误设为 true 导致无法正常失焦
290
+ const readyToShow = !!(keyboardAvoid.current && keyboardAvoid.current.ref !== nodeRef)
291
+ keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition, holdKeyboard, readyToShow }
285
292
  }
286
293
  }
287
294
 
288
295
  const onTouchStart = () => {
289
- // sometimes the focus event occurs later than the keyboardWillShow event
296
+ // 手动聚焦时初始化 keyboardAvoid 上下文
297
+ // auto-focus/focus 不会触发而是在 useEffect 中初始化
290
298
  setKeyboardAvoidContext()
291
299
  }
292
300
 
@@ -295,42 +303,49 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
295
303
  }
296
304
 
297
305
  const onFocus = (evt: NativeSyntheticEvent<TextInputFocusEventData>) => {
298
- setKeyboardAvoidContext()
306
+ if (!keyboardAvoid?.current) {
307
+ // Android:从一个正聚焦状态 input,聚焦到另一个新的 input 时,正常会触发如下时序:
308
+ // 新的 Input `onTouchStart` -> 旧输入框键盘 `keyboardDidHide` -> 新的 Input `onFocus`
309
+ // 导致这里的 keyboardAvoid.current 为 null,所以需要判空重新初始化。
310
+ setKeyboardAvoidContext()
311
+ }
299
312
 
300
- if (bindfocus) {
301
- const focusAction = () => {
302
- bindfocus(
303
- getCustomEvent(
304
- 'focus',
305
- evt,
306
- {
307
- detail: {
308
- value: tmpValue.current || '',
309
- height: keyboardAvoid?.current?.keyboardHeight
310
- },
311
- layoutRef
313
+ const focusAction = () => {
314
+ bindfocus?.(
315
+ getCustomEvent(
316
+ 'focus',
317
+ evt,
318
+ {
319
+ detail: {
320
+ value: tmpValue.current || '',
321
+ height: keyboardAvoid?.current?.keyboardHeight
312
322
  },
313
- props
314
- )
323
+ layoutRef
324
+ },
325
+ props
315
326
  )
316
- if (keyboardAvoid?.current?.onKeyboardShow) {
317
- keyboardAvoid.current.onKeyboardShow = undefined
318
- }
327
+ )
328
+ if (keyboardAvoid?.current?.onKeyboardShow) {
329
+ keyboardAvoid.current.onKeyboardShow = undefined
319
330
  }
320
- if (keyboardAvoid?.current) {
321
- // 有 keyboardAvoiding
322
- if (keyboardAvoid.current.keyboardHeight) {
323
- // iOS: keyboard 获取高度时机 keyboardWillShow 在 input focus 之前,可以立即执行
324
- focusAction()
325
- } else {
326
- // Android,Harmony: keyboard 获取高度时机 keyboardDidShow 在 input focus 之后,需要延迟回调
327
- evt.persist()
328
- keyboardAvoid.current.onKeyboardShow = focusAction
329
- }
330
- } else {
331
- // 无 keyboardAvoiding,直接执行 focus 回调
331
+ }
332
+
333
+ if (keyboardAvoid?.current) {
334
+ // keyboardAvoiding
335
+ if (keyboardAvoid.current.keyboardHeight) {
336
+ // 仅以下场景触发顺序:先 keyboardWillShow 获取高度 -> 后 onFocus,可以立即执行
337
+ // - iOS + 手动点击聚焦
332
338
  focusAction()
339
+ } else {
340
+ // 其他场景触发顺序:先 onFocus -> 后 keyboardWillShow 获取高度 -> 执行回调
341
+ // - iOS + auto-focus/focus=true 自动聚焦
342
+ // - Android 手动点击聚焦/自动聚焦 都一样
343
+ evt.persist()
344
+ keyboardAvoid.current.onKeyboardShow = focusAction
333
345
  }
346
+ } else {
347
+ // 兜底:无 keyboardAvoiding 直接执行 focus 回调
348
+ focusAction()
334
349
  }
335
350
  }
336
351
 
@@ -440,19 +455,22 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
440
455
  }, [])
441
456
 
442
457
  useEffect(() => {
443
- if (focus) {
458
+ if (isAutoFocus) {
459
+ // auto-focus/focus=true 初始化 keyboardAvoidContext
444
460
  setKeyboardAvoidContext()
445
461
  }
446
- }, [focus])
462
+ }, [isAutoFocus])
447
463
 
448
464
  useUpdateEffect(() => {
449
465
  if (!nodeRef?.current) {
450
466
  return
451
467
  }
452
- focus
468
+ // RN autoFocus 属性仅在初次渲染时生效
469
+ // 后续更新需要手动调用 focus/blur 方法,和微信小程序对齐
470
+ isAutoFocus
453
471
  ? (nodeRef.current as TextInput)?.focus()
454
472
  : (nodeRef.current as TextInput)?.blur()
455
- }, [focus])
473
+ }, [isAutoFocus])
456
474
 
457
475
  const innerProps = useInnerProps(
458
476
  extendObject(
@@ -463,16 +481,17 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
463
481
  ref: nodeRef,
464
482
  style: extendObject({}, normalStyle, layoutStyle),
465
483
  allowFontScaling,
466
- keyboardType: keyboardType,
484
+ inputMode: originalKeyboardType ? undefined : inputModeMap[type],
485
+ keyboardType: originalKeyboardType,
467
486
  secureTextEntry: !!password,
468
487
  defaultValue: defaultValue,
469
488
  value: inputValue,
470
489
  maxLength: maxlength === -1 ? undefined : maxlength,
471
490
  editable: !disabled,
472
- autoFocus: !!autoFocus || !!focus,
491
+ autoFocus: isAutoFocus,
473
492
  selection: selectionStart > -1 || typeof cursor === 'number' ? selection : undefined,
474
493
  selectionColor: cursorColor,
475
- blurOnSubmit: !multiline && !confirmHold,
494
+ blurOnSubmit: multiline ? confirmType !== 'return' : !confirmHold,
476
495
  underlineColorAndroid: 'rgba(0,0,0,0)',
477
496
  textAlignVertical: textAlignVertical,
478
497
  placeholderTextColor: placeholderStyle?.color,
@@ -484,7 +503,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
484
503
  onChange,
485
504
  onSelectionChange,
486
505
  onContentSizeChange,
487
- onSubmitEditing: bindconfirm && !multiline && onSubmitEditing
506
+ onSubmitEditing: bindconfirm && onSubmitEditing
488
507
  },
489
508
  !!multiline && confirmType === 'return' ? {} : { enterKeyHint: confirmType }
490
509
  ),
@@ -23,10 +23,13 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
23
23
  // 比如机型 iPhone 11 Pro,可能会导致显隐动画冲突
24
24
  // 因此增加状态标记 + cancelAnimation 来优化
25
25
  const isShow = useRef<boolean>(false)
26
+ const keybaordHandleTimerRef = useRef<NodeJS.Timeout | null>(null)
26
27
 
27
28
  const animatedStyle = useAnimatedStyle(() => ({
28
- // translate/position top可能会导致底部渲染区域缺失
29
- marginTop: -offset.value,
29
+ // translate/position top+ overflow hidden 在 android 上时因为键盘顶起让页面高度变小,同时元素位置上移
30
+ // 此时最底部的区域是超出了页面高度的,hidden生效就被隐藏掉,因此需要 android 配置聚焦时禁用高度缩小
31
+ // margin-top 因为在 react-native 上和 flex 1 同时存在时,负值只会让容器高度整体变高,不会让元素上移
32
+ transform: [{ translateY: -offset.value }],
30
33
  flexBasis: basic.value as DimensionValue
31
34
  }))
32
35
 
@@ -39,11 +42,20 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
39
42
 
40
43
  if (keyboardAvoid?.current) {
41
44
  const inputRef = keyboardAvoid.current.ref?.current
42
- if (inputRef && inputRef.isFocused()) {
45
+ if (inputRef && inputRef.isFocused() && !keyboardAvoid.current.readyToShow) {
43
46
  // 修复 Android 点击键盘收起按钮时当前 input 没触发失焦的问题
47
+ // keyboardAvoid.current.readyToShow = true 表示聚焦到了新的输入框,不需要手动触发失焦
44
48
  inputRef.blur()
45
49
  }
46
- keyboardAvoid.current = null
50
+ if (!keyboardAvoid.current.onKeyboardShow) {
51
+ // 修复部分 Android 机型可能时序问题:当从 input 已聚焦状态,聚焦到另一个 input 时,可能时序:
52
+ // - 新的 Input `onTouchStart` -> 新的 Input `onFocus` -> 旧输入框键盘 `keyboardDidHide` -> 新输入框键盘 `keyboardDidShow`
53
+ // - 此时 keyboardAvoid.current 如果清空 null,会导致新输入框键盘 `keyboardDidShow` 回调 keybaordAvoding 执行失败。
54
+ // 修复方案:
55
+ // 如果出现时序问题,那么新的 Input `onFocus` 会更早执行,那么 `keyboardAvoid.current.onKeyboardShow` 存在,
56
+ // 那么不应该重置为 null,反之,说明时正常情况,应当重置为 null。
57
+ keyboardAvoid.current = null
58
+ }
47
59
  }
48
60
 
49
61
  cancelAnimation(offset)
@@ -53,6 +65,9 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
53
65
 
54
66
  const onTouchEnd = ({ nativeEvent }: NativeSyntheticEvent<NativeTouchEvent & { origin?: string }>) => {
55
67
  if (nativeEvent.origin !== 'input') {
68
+ if (keyboardAvoid?.current?.holdKeyboard) {
69
+ return
70
+ }
56
71
  Keyboard.isVisible() && Keyboard.dismiss()
57
72
  }
58
73
  }
@@ -61,7 +76,11 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
61
76
  let subscriptions: EmitterSubscription[] = []
62
77
 
63
78
  function keybaordAvoding(evt: any) {
64
- if (!keyboardAvoid?.current || isShow.current) {
79
+ if (keyboardAvoid?.current?.readyToShow) {
80
+ // 重置标记位
81
+ keyboardAvoid.current.readyToShow = false
82
+ }
83
+ if (!keyboardAvoid?.current) {
65
84
  return
66
85
  }
67
86
 
@@ -106,13 +125,23 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
106
125
  }
107
126
 
108
127
  if (isIOS) {
109
- subscriptions = [Keyboard.addListener('keyboardWillShow', keybaordAvoding), Keyboard.addListener('keyboardWillHide', resetKeyboard)]
128
+ subscriptions = [
129
+ Keyboard.addListener('keyboardWillShow', (evt: any) => {
130
+ if (keybaordHandleTimerRef.current) {
131
+ clearTimeout(keybaordHandleTimerRef.current)
132
+ }
133
+ // iphone 在input聚焦时长按滑动后会导致 show 事件先于 focus 事件发生,因此等一下,等 focus 先触发拿到 input,避免键盘出现但input没顶上去
134
+ keybaordHandleTimerRef.current = setTimeout(() => keybaordAvoding(evt), 32)
135
+ }),
136
+ Keyboard.addListener('keyboardWillHide', resetKeyboard)
137
+ ]
110
138
  } else {
111
139
  subscriptions = [Keyboard.addListener('keyboardDidShow', keybaordAvoding), Keyboard.addListener('keyboardDidHide', resetKeyboard)]
112
140
  }
113
141
 
114
142
  return () => {
115
143
  subscriptions.forEach(subscription => subscription.remove())
144
+ keybaordHandleTimerRef.current && clearTimeout(keybaordHandleTimerRef.current)
116
145
  }
117
146
  }, [keyboardAvoid])
118
147
 
@@ -136,6 +136,16 @@ const _PickerViewColumn = forwardRef<HandlerRef<ScrollView & View, ColumnProps>,
136
136
  }
137
137
  }, [])
138
138
 
139
+ // `contentOffset` prop sets visual position but does not fire scroll events,
140
+ // so `offsetYShared` (from `useScrollViewOffset`) stays at 0 until the user scrolls.
141
+ // Directly sync it whenever `itemRawH` is established so wheel animation renders correctly.
142
+ useEffect(() => {
143
+ if (!itemRawH || dragging.current || scrolling.current) {
144
+ return
145
+ }
146
+ offsetYShared.value = activeIndex.current * itemRawH
147
+ }, [itemRawH])
148
+
139
149
  useEffect(() => {
140
150
  if (
141
151
  !scrollViewRef.current ||
@@ -19,7 +19,7 @@ const _PortalManager = forwardRef((props: PortalManagerProps, ref:ForwardedRef<u
19
19
  setState((prevState) => ({
20
20
  portals: [...prevState.portals, { key, children }]
21
21
  }))
22
- }, [state])
22
+ }, [])
23
23
 
24
24
  const update = useCallback((key: number, children: ReactNode) => {
25
25
  setState((prevState) => ({
@@ -30,7 +30,7 @@ const _PortalManager = forwardRef((props: PortalManagerProps, ref:ForwardedRef<u
30
30
  return item
31
31
  })
32
32
  }))
33
- }, [state])
33
+ }, [])
34
34
 
35
35
  const unmount = useCallback((key: number) => {
36
36
  setState((prevState) => ({
@@ -112,6 +112,11 @@ type ScrollAdditionalProps = {
112
112
 
113
113
  const AnimatedScrollView = RNAnimated.createAnimatedComponent(ScrollView) as React.ComponentType<any>
114
114
 
115
+ const REFRESH_COLOR = {
116
+ black: ['#000'],
117
+ white: ['#fff']
118
+ }
119
+
115
120
  const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, ScrollViewProps>((scrollViewProps: ScrollViewProps = {}, ref): JSX.Element => {
116
121
  const { textProps, innerProps: props = {} } = splitProps(scrollViewProps)
117
122
  const {
@@ -121,9 +126,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
121
126
  binddragstart,
122
127
  binddragging,
123
128
  binddragend,
124
- bindtouchstart,
125
129
  bindtouchmove,
126
- bindtouchend,
127
130
  'scroll-x': scrollX = false,
128
131
  'scroll-y': scrollY = false,
129
132
  'enable-back-to-top': enableBackToTop = false,
@@ -159,14 +162,15 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
159
162
  const simultaneousHandlers = flatGesture(originSimultaneousHandlers)
160
163
  const waitForHandlers = flatGesture(waitFor)
161
164
 
162
- const [refreshing, setRefreshing] = useState(false)
165
+ const { refresherContent, otherContent } = getRefresherContent(props.children)
166
+ const hasRefresher = refresherContent && refresherEnabled
163
167
 
168
+ const [refreshing, setRefreshing] = useState(false)
164
169
  const [enableScroll, setEnableScroll] = useState(true)
165
- const enableScrollValue = useSharedValue(true)
166
-
167
170
  const [scrollBounces, setScrollBounces] = useState(false)
168
- const bouncesValue = useSharedValue(!!false)
169
171
 
172
+ const enableScrollValue = useSharedValue(true)
173
+ const bouncesValue = useSharedValue(false)
170
174
  const translateY = useSharedValue(0)
171
175
  const isAtTop = useSharedValue(true)
172
176
  const refresherHeight = useSharedValue(0)
@@ -186,16 +190,8 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
186
190
 
187
191
  const firstScrollIntoViewChange = useRef<boolean>(true)
188
192
 
189
- const refreshColor = {
190
- black: ['#000'],
191
- white: ['#fff']
192
- }
193
-
194
193
  const isContentSizeChange = useRef(false)
195
194
 
196
- const { refresherContent, otherContent } = getRefresherContent(props.children)
197
- const hasRefresher = refresherContent && refresherEnabled
198
-
199
195
  const {
200
196
  normalStyle,
201
197
  hasVarDec,
@@ -643,67 +639,71 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
643
639
  }
644
640
  }
645
641
 
646
- // 处理下拉刷新的手势
647
- const panGesture = Gesture.Pan()
648
- .onUpdate((event) => {
649
- 'worklet'
650
- if (enhanced && !!bounces) {
651
- if (event.translationY > 0 && bouncesValue.value) {
652
- updateBouncesState(false)
653
- } else if ((event.translationY < 0) && !bouncesValue.value) {
654
- updateBouncesState(true)
642
+ // 处理下拉刷新的手势 - 使用 useMemo 避免每次渲染都创建
643
+ const panGesture = useMemo(() => {
644
+ if (!hasRefresher) return Gesture.Pan() // 返回空手势
645
+
646
+ return Gesture.Pan()
647
+ .onUpdate((event) => {
648
+ 'worklet'
649
+ if (enhanced && !!bounces) {
650
+ if (event.translationY > 0 && bouncesValue.value) {
651
+ updateBouncesState(false)
652
+ } else if ((event.translationY < 0) && !bouncesValue.value) {
653
+ updateBouncesState(true)
654
+ }
655
655
  }
656
- }
657
656
 
658
- if (translateY.value <= 0 && event.translationY < 0) {
659
- // 滑动到顶再向上开启滚动
660
- updateScrollState(true)
661
- } else if (event.translationY > 0 && isAtTop.value) {
662
- // 滚动到顶再向下禁止滚动
663
- updateScrollState(false)
664
- }
665
- // 禁止滚动后切换为滑动
666
- if (!enableScrollValue.value && isAtTop.value) {
667
- if (refreshing) {
668
- // 从完全展开状态(refresherHeight.value)开始计算偏移
669
- translateY.value = Math.max(
670
- 0,
671
- Math.min(
672
- refresherHeight.value,
673
- refresherHeight.value + event.translationY
657
+ if (translateY.value <= 0 && event.translationY < 0) {
658
+ // 滑动到顶再向上开启滚动
659
+ updateScrollState(true)
660
+ } else if (event.translationY > 0 && isAtTop.value) {
661
+ // 滚动到顶再向下禁止滚动
662
+ updateScrollState(false)
663
+ }
664
+ // 禁止滚动后切换为滑动
665
+ if (!enableScrollValue.value && isAtTop.value) {
666
+ if (refreshing) {
667
+ // 从完全展开状态(refresherHeight.value)开始计算偏移
668
+ translateY.value = Math.max(
669
+ 0,
670
+ Math.min(
671
+ refresherHeight.value,
672
+ refresherHeight.value + event.translationY
673
+ )
674
674
  )
675
- )
676
- } else if (event.translationY > 0) {
677
- // 非刷新状态下的下拉逻辑保持不变
678
- translateY.value = Math.min(event.translationY * 0.6, refresherHeight.value)
675
+ } else if (event.translationY > 0) {
676
+ // 非刷新状态下的下拉逻辑保持不变
677
+ translateY.value = Math.min(event.translationY * 0.6, refresherHeight.value)
678
+ }
679
679
  }
680
- }
681
- })
682
- .onEnd((event) => {
683
- 'worklet'
684
- if (enableScrollValue.value) return
685
- if (refreshing) {
686
- // 刷新状态下,根据滑动距离决定是否隐藏
687
- // 如果向下滑动没超过 refresherThreshold,就完全隐藏,如果向上滑动完全隐藏
688
- if ((event.translationY > 0 && translateY.value < refresherThreshold) || event.translationY < 0) {
680
+ })
681
+ .onEnd((event) => {
682
+ 'worklet'
683
+ if (enableScrollValue.value) return
684
+ if (refreshing) {
685
+ // 刷新状态下,根据滑动距离决定是否隐藏
686
+ // 如果向下滑动没超过 refresherThreshold,就完全隐藏,如果向上滑动完全隐藏
687
+ if ((event.translationY > 0 && translateY.value < refresherThreshold) || event.translationY < 0) {
688
+ translateY.value = withTiming(0)
689
+ updateScrollState(true)
690
+ runOnJS(runOnJSCallback)('setRefreshing', false)
691
+ } else {
692
+ translateY.value = withTiming(refresherHeight.value)
693
+ }
694
+ } else if (event.translationY >= refresherHeight.value) {
695
+ // 触发刷新
696
+ translateY.value = withTiming(refresherHeight.value)
697
+ runOnJS(runOnJSCallback)('onRefresh')
698
+ } else {
699
+ // 回弹
689
700
  translateY.value = withTiming(0)
690
701
  updateScrollState(true)
691
702
  runOnJS(runOnJSCallback)('setRefreshing', false)
692
- } else {
693
- translateY.value = withTiming(refresherHeight.value)
694
703
  }
695
- } else if (event.translationY >= refresherHeight.value) {
696
- // 触发刷新
697
- translateY.value = withTiming(refresherHeight.value)
698
- runOnJS(runOnJSCallback)('onRefresh')
699
- } else {
700
- // 回弹
701
- translateY.value = withTiming(0)
702
- updateScrollState(true)
703
- runOnJS(runOnJSCallback)('setRefreshing', false)
704
- }
705
- })
706
- .simultaneousWithExternalGesture(scrollViewRef)
704
+ })
705
+ .simultaneousWithExternalGesture(scrollViewRef)
706
+ }, [hasRefresher, enhanced, bounces, refreshing, refresherThreshold])
707
707
 
708
708
  const scrollAdditionalProps: ScrollAdditionalProps = extendObject(
709
709
  {
@@ -779,61 +779,57 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
779
779
 
780
780
  const ScrollViewComponent = enableSticky ? AnimatedScrollView : ScrollView
781
781
 
782
- const withRefresherScrollView = createElement(
783
- GestureDetector,
784
- { gesture: panGesture },
785
- createElement(
786
- ScrollViewComponent,
787
- innerProps,
788
- createElement(
789
- Animated.View,
790
- { style: [refresherAnimatedStyle, refresherLayoutStyle], onLayout: onRefresherLayout },
791
- refresherContent
792
- ),
782
+ const createScrollViewContent = () => {
783
+ const wrappedChildren = wrapChildren(hasRefresher ? extendObject({}, props, { children: otherContent }) : props,
784
+ {
785
+ hasVarDec,
786
+ varContext: varContextRef.current,
787
+ textStyle,
788
+ textProps
789
+ })
790
+ return createElement(ScrollViewContext.Provider, { value: contextValue }, wrappedChildren)
791
+ }
792
+
793
+ const withRefresherScrollView = () => {
794
+ return createElement(
795
+ GestureDetector,
796
+ { gesture: panGesture },
793
797
  createElement(
794
- Animated.View,
795
- { style: contentAnimatedStyle },
798
+ ScrollViewComponent,
799
+ innerProps,
800
+ createElement(
801
+ Animated.View,
802
+ { style: [refresherAnimatedStyle, refresherLayoutStyle], onLayout: onRefresherLayout },
803
+ refresherContent
804
+ ),
796
805
  createElement(
797
- ScrollViewContext.Provider,
798
- { value: contextValue },
799
- wrapChildren(
800
- extendObject({}, props, { children: otherContent }),
801
- {
802
- hasVarDec,
803
- varContext: varContextRef.current,
804
- textStyle,
805
- textProps
806
- }
807
- )
806
+ Animated.View,
807
+ { style: contentAnimatedStyle },
808
+ createScrollViewContent()
808
809
  )
809
810
  )
810
811
  )
811
- )
812
+ }
812
813
 
813
- const commonScrollView = createElement(
814
- ScrollViewComponent,
815
- extendObject({}, innerProps, {
816
- refreshControl: refresherEnabled
817
- ? createElement(RefreshControl, extendObject({
818
- progressBackgroundColor: refresherBackground,
819
- refreshing: refreshing,
820
- onRefresh: onRefresh
821
- }, refresherDefaultStyle && refresherDefaultStyle !== 'none'
822
- ? { colors: refreshColor[refresherDefaultStyle] }
823
- : {}))
824
- : undefined
825
- }),
826
- createElement(ScrollViewContext.Provider, { value: contextValue },
827
- wrapChildren(props, {
828
- hasVarDec,
829
- varContext: varContextRef.current,
830
- textStyle,
831
- textProps
832
- })
814
+ const commonScrollView = () => {
815
+ const refreshControl = refresherEnabled
816
+ ? createElement(RefreshControl, extendObject({
817
+ progressBackgroundColor: refresherBackground,
818
+ refreshing: refreshing,
819
+ onRefresh: onRefresh
820
+ }, refresherDefaultStyle && refresherDefaultStyle !== 'none'
821
+ ? { colors: REFRESH_COLOR[refresherDefaultStyle] }
822
+ : {}))
823
+ : undefined
824
+
825
+ return createElement(
826
+ ScrollViewComponent,
827
+ extendObject({}, innerProps, { refreshControl }),
828
+ createScrollViewContent()
833
829
  )
834
- )
830
+ }
835
831
 
836
- let scrollViewComponent = hasRefresher ? withRefresherScrollView : commonScrollView
832
+ let scrollViewComponent = hasRefresher ? withRefresherScrollView() : commonScrollView()
837
833
 
838
834
  if (hasPositionFixed) {
839
835
  scrollViewComponent = createElement(Portal, null, scrollViewComponent)