@mpxjs/webpack-plugin 2.10.17 → 2.10.18-beta.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 (262) 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 +70 -73
  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/unsupported.js +10 -1
  35. package/lib/platform/template/wx/component-config/video.js +10 -0
  36. package/lib/platform/template/wx/index.js +21 -1
  37. package/lib/react/LoadAsyncChunkModule.js +1 -1
  38. package/lib/react/processStyles.js +21 -9
  39. package/lib/react/script-helper.js +2 -2
  40. package/lib/react/style-helper.js +76 -13
  41. package/lib/resolver/AddModePlugin.js +17 -7
  42. package/lib/resolver/ExtendComponentsPlugin.js +60 -0
  43. package/lib/runtime/components/ali/mpx-section-list.mpx +566 -0
  44. package/lib/runtime/components/ali/mpx-sticky-header.mpx +212 -0
  45. package/lib/runtime/components/ali/mpx-sticky-section.mpx +17 -0
  46. package/lib/runtime/components/react/animationHooks/index.ts +75 -0
  47. package/lib/runtime/components/react/animationHooks/useAnimationAPIHooks.ts +197 -0
  48. package/lib/runtime/components/react/animationHooks/useTransitionHooks.ts +301 -0
  49. package/lib/runtime/components/react/animationHooks/utils.ts +197 -0
  50. package/lib/runtime/components/react/context.ts +12 -3
  51. package/lib/runtime/components/react/dist/animationHooks/index.d.ts +15 -0
  52. package/lib/runtime/components/react/dist/animationHooks/index.js +67 -0
  53. package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.d.ts +3 -0
  54. package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.js +181 -0
  55. package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.d.ts +3 -0
  56. package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.js +279 -0
  57. package/lib/runtime/components/react/dist/animationHooks/utils.d.ts +109 -0
  58. package/lib/runtime/components/react/dist/animationHooks/utils.js +151 -0
  59. package/lib/runtime/components/react/dist/context.d.ts +10 -3
  60. package/lib/runtime/components/react/dist/context.js +1 -2
  61. package/lib/runtime/components/react/dist/event.config.d.ts +0 -1
  62. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +0 -1
  63. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +0 -1
  64. package/lib/runtime/components/react/dist/mpx-async-suspense.jsx +3 -1
  65. package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -1
  66. package/lib/runtime/components/react/dist/mpx-camera.d.ts +31 -0
  67. package/lib/runtime/components/react/dist/mpx-camera.jsx +236 -0
  68. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +0 -1
  69. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +0 -1
  70. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +0 -1
  71. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +0 -1
  72. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +0 -1
  73. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +0 -1
  74. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +0 -1
  75. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
  76. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +0 -1
  77. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
  78. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -1
  79. package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -1
  80. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
  81. package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
  82. package/lib/runtime/components/react/dist/mpx-image.jsx +2 -2
  83. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +0 -1
  84. package/lib/runtime/components/react/dist/mpx-input.d.ts +2 -1
  85. package/lib/runtime/components/react/dist/mpx-input.jsx +66 -50
  86. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +0 -1
  87. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +35 -6
  88. package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -1
  89. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
  90. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -1
  91. package/lib/runtime/components/react/dist/mpx-nav.d.ts +0 -1
  92. package/lib/runtime/components/react/dist/mpx-navigator.d.ts +0 -1
  93. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +0 -1
  94. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +0 -1
  95. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +0 -1
  96. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +0 -1
  97. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +0 -1
  98. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +0 -1
  99. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +0 -1
  100. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +0 -1
  101. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +0 -1
  102. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +0 -1
  103. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -1
  104. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -1
  105. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -1
  106. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -1
  107. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +0 -1
  108. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +0 -1
  109. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +0 -1
  110. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +0 -1
  111. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +0 -1
  112. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +0 -1
  113. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +0 -1
  114. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +0 -1
  115. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +2 -2
  116. package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
  117. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
  118. package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -1
  119. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +0 -1
  120. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
  121. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +0 -1
  122. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -1
  123. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +84 -78
  124. package/lib/runtime/components/react/dist/mpx-section-list.d.ts +48 -0
  125. package/lib/runtime/components/react/dist/mpx-section-list.jsx +292 -0
  126. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +0 -1
  127. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -1
  128. package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
  129. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -1
  130. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +20 -20
  131. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -1
  132. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -1
  133. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +11 -1
  134. package/lib/runtime/components/react/dist/mpx-swiper.jsx +136 -83
  135. package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
  136. package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
  137. package/lib/runtime/components/react/dist/mpx-textarea.d.ts +0 -1
  138. package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -0
  139. package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
  140. package/lib/runtime/components/react/dist/mpx-view.d.ts +3 -3
  141. package/lib/runtime/components/react/dist/mpx-view.jsx +22 -8
  142. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +0 -1
  143. package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
  144. package/lib/runtime/components/react/dist/parser.d.ts +0 -1
  145. package/lib/runtime/components/react/dist/useNodesRef.d.ts +0 -1
  146. package/lib/runtime/components/react/dist/utils.d.ts +10 -9
  147. package/lib/runtime/components/react/dist/utils.jsx +47 -24
  148. package/lib/runtime/components/react/mpx-async-suspense.tsx +3 -1
  149. package/lib/runtime/components/react/mpx-camera.tsx +327 -0
  150. package/lib/runtime/components/react/mpx-image.tsx +2 -2
  151. package/lib/runtime/components/react/mpx-input.tsx +77 -54
  152. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +35 -6
  153. package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +2 -2
  154. package/lib/runtime/components/react/mpx-scroll-view.tsx +110 -114
  155. package/lib/runtime/components/react/mpx-section-list.tsx +439 -0
  156. package/lib/runtime/components/react/mpx-sticky-header.tsx +24 -24
  157. package/lib/runtime/components/react/mpx-swiper.tsx +156 -81
  158. package/lib/runtime/components/react/mpx-textarea.tsx +1 -0
  159. package/lib/runtime/components/react/mpx-view.tsx +27 -12
  160. package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
  161. package/lib/runtime/components/react/tsconfig.json +26 -0
  162. package/lib/runtime/components/react/types/global.d.ts +1 -0
  163. package/lib/runtime/components/react/utils.tsx +51 -27
  164. package/lib/runtime/components/web/mpx-scroll-view.vue +5 -2
  165. package/lib/runtime/components/web/mpx-section-list.vue +551 -0
  166. package/lib/runtime/components/wx/mpx-section-list-default/list-footer.mpx +26 -0
  167. package/lib/runtime/components/wx/mpx-section-list-default/list-header.mpx +26 -0
  168. package/lib/runtime/components/wx/mpx-section-list-default/list-item.mpx +26 -0
  169. package/lib/runtime/components/wx/mpx-section-list-default/section-header.mpx +26 -0
  170. package/lib/runtime/components/wx/mpx-section-list.mpx +209 -0
  171. package/lib/runtime/components/wx/mpx-sticky-header.mpx +40 -0
  172. package/lib/runtime/components/wx/mpx-sticky-section.mpx +31 -0
  173. package/lib/runtime/optionProcessor.js +5 -0
  174. package/lib/runtime/optionProcessorReact.js +7 -0
  175. package/lib/runtime/stringify.wxs +2 -2
  176. package/lib/script-setup-compiler/index.js +1 -2
  177. package/lib/style-compiler/strip-conditional.js +243 -0
  178. package/lib/template-compiler/compiler.js +9 -8
  179. package/lib/utils/const.js +29 -0
  180. package/lib/utils/dom-tag-config.js +1 -1
  181. package/lib/utils/string.js +25 -1
  182. package/lib/wxss/loader.js +4 -1
  183. package/lib/wxss/utils.js +7 -2
  184. package/package.json +7 -14
  185. package/LICENSE +0 -433
  186. package/lib/runtime/components/react/dist/context.d.ts.map +0 -1
  187. package/lib/runtime/components/react/dist/event.config.d.ts.map +0 -1
  188. package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +0 -1
  189. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +0 -1
  190. package/lib/runtime/components/react/dist/mpx-button.d.ts.map +0 -1
  191. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +0 -1
  192. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +0 -1
  193. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +0 -1
  194. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +0 -1
  195. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +0 -1
  196. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +0 -1
  197. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +0 -1
  198. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +0 -1
  199. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +0 -1
  200. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +0 -1
  201. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +0 -1
  202. package/lib/runtime/components/react/dist/mpx-form.d.ts.map +0 -1
  203. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +0 -1
  204. package/lib/runtime/components/react/dist/mpx-image.d.ts.map +0 -1
  205. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +0 -1
  206. package/lib/runtime/components/react/dist/mpx-input.d.ts.map +0 -1
  207. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +0 -1
  208. package/lib/runtime/components/react/dist/mpx-label.d.ts.map +0 -1
  209. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +0 -1
  210. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +0 -1
  211. package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +0 -1
  212. package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +0 -1
  213. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +0 -1
  214. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +0 -1
  215. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +0 -1
  216. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +0 -1
  217. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +0 -1
  218. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +0 -1
  219. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +0 -1
  220. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +0 -1
  221. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +0 -1
  222. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +0 -1
  223. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +0 -1
  224. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +0 -1
  225. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +0 -1
  226. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +0 -1
  227. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +0 -1
  228. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +0 -1
  229. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +0 -1
  230. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +0 -1
  231. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +0 -1
  232. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +0 -1
  233. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +0 -1
  234. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +0 -1
  235. package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +0 -1
  236. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +0 -1
  237. package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +0 -1
  238. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +0 -1
  239. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +0 -1
  240. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +0 -1
  241. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +0 -1
  242. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +0 -1
  243. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +0 -1
  244. package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +0 -1
  245. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +0 -1
  246. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +0 -1
  247. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +0 -1
  248. package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +0 -1
  249. package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +0 -1
  250. package/lib/runtime/components/react/dist/mpx-text.d.ts.map +0 -1
  251. package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +0 -1
  252. package/lib/runtime/components/react/dist/mpx-video.d.ts.map +0 -1
  253. package/lib/runtime/components/react/dist/mpx-view.d.ts.map +0 -1
  254. package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +0 -1
  255. package/lib/runtime/components/react/dist/parser.d.ts.map +0 -1
  256. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +0 -33
  257. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +0 -1
  258. package/lib/runtime/components/react/dist/useAnimationHooks.js +0 -289
  259. package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +0 -1
  260. package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
  261. package/lib/runtime/components/react/useAnimationHooks.ts +0 -320
  262. package/lib/style-compiler/strip-conditional-loader.js +0 -289
@@ -42,17 +42,23 @@ import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, ext
42
42
  import { IntersectionObserverContext, ScrollViewContext } from './context';
43
43
  import Portal from './mpx-portal';
44
44
  const AnimatedScrollView = RNAnimated.createAnimatedComponent(ScrollView);
45
+ const REFRESH_COLOR = {
46
+ black: ['#000'],
47
+ white: ['#fff']
48
+ };
45
49
  const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
46
50
  const { textProps, innerProps: props = {} } = splitProps(scrollViewProps);
47
- const { enhanced = false, bounces = true, style = {}, binddragstart, binddragging, binddragend, bindtouchstart, bindtouchmove, bindtouchend, 'scroll-x': scrollX = false, 'scroll-y': scrollY = false, 'enable-back-to-top': enableBackToTop = false, 'enable-trigger-intersection-observer': enableTriggerIntersectionObserver = false, 'paging-enabled': pagingEnabled = false, 'upper-threshold': upperThreshold = 50, 'lower-threshold': lowerThreshold = 50, 'scroll-with-animation': scrollWithAnimation = false, 'refresher-enabled': refresherEnabled, 'refresher-default-style': refresherDefaultStyle, 'refresher-background': refresherBackground, 'refresher-threshold': refresherThreshold = 45, 'show-scrollbar': showScrollbar = true, 'scroll-into-view': scrollIntoView = '', 'scroll-top': scrollTop = 0, 'scroll-left': scrollLeft = 0, 'refresher-triggered': refresherTriggered, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'simultaneous-handlers': originSimultaneousHandlers, 'wait-for': waitFor, 'enable-sticky': enableSticky, 'scroll-event-throttle': scrollEventThrottle = 0, 'scroll-into-view-offset': scrollIntoViewOffset = 0, __selectRef } = props;
51
+ const { enhanced = false, bounces = true, style = {}, binddragstart, binddragging, binddragend, bindtouchmove, 'scroll-x': scrollX = false, 'scroll-y': scrollY = false, 'enable-back-to-top': enableBackToTop = false, 'enable-trigger-intersection-observer': enableTriggerIntersectionObserver = false, 'paging-enabled': pagingEnabled = false, 'upper-threshold': upperThreshold = 50, 'lower-threshold': lowerThreshold = 50, 'scroll-with-animation': scrollWithAnimation = false, 'refresher-enabled': refresherEnabled, 'refresher-default-style': refresherDefaultStyle, 'refresher-background': refresherBackground, 'refresher-threshold': refresherThreshold = 45, 'show-scrollbar': showScrollbar = true, 'scroll-into-view': scrollIntoView = '', 'scroll-top': scrollTop = 0, 'scroll-left': scrollLeft = 0, 'refresher-triggered': refresherTriggered, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'simultaneous-handlers': originSimultaneousHandlers, 'wait-for': waitFor, 'enable-sticky': enableSticky, 'scroll-event-throttle': scrollEventThrottle = 0, 'scroll-into-view-offset': scrollIntoViewOffset = 0, __selectRef } = props;
48
52
  const scrollOffset = useRef(new RNAnimated.Value(0)).current;
49
53
  const simultaneousHandlers = flatGesture(originSimultaneousHandlers);
50
54
  const waitForHandlers = flatGesture(waitFor);
55
+ const { refresherContent, otherContent } = getRefresherContent(props.children);
56
+ const hasRefresher = refresherContent && refresherEnabled;
51
57
  const [refreshing, setRefreshing] = useState(false);
52
58
  const [enableScroll, setEnableScroll] = useState(true);
53
- const enableScrollValue = useSharedValue(true);
54
59
  const [scrollBounces, setScrollBounces] = useState(false);
55
- const bouncesValue = useSharedValue(!!false);
60
+ const enableScrollValue = useSharedValue(true);
61
+ const bouncesValue = useSharedValue(false);
56
62
  const translateY = useSharedValue(0);
57
63
  const isAtTop = useSharedValue(true);
58
64
  const refresherHeight = useSharedValue(0);
@@ -68,13 +74,7 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
68
74
  const initialTimeout = useRef(null);
69
75
  const intersectionObservers = useContext(IntersectionObserverContext);
70
76
  const firstScrollIntoViewChange = useRef(true);
71
- const refreshColor = {
72
- black: ['#000'],
73
- white: ['#fff']
74
- };
75
77
  const isContentSizeChange = useRef(false);
76
- const { refresherContent, otherContent } = getRefresherContent(props.children);
77
- const hasRefresher = refresherContent && refresherEnabled;
78
78
  const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, hasPositionFixed, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
79
79
  const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
80
80
  const scrollViewRef = useRef(null);
@@ -455,67 +455,71 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
455
455
  runOnJS(runOnJSCallback)('setScrollBounces', newValue);
456
456
  }
457
457
  }
458
- // 处理下拉刷新的手势
459
- const panGesture = Gesture.Pan()
460
- .onUpdate((event) => {
461
- 'worklet';
462
- if (enhanced && !!bounces) {
463
- if (event.translationY > 0 && bouncesValue.value) {
464
- updateBouncesState(false);
458
+ // 处理下拉刷新的手势 - 使用 useMemo 避免每次渲染都创建
459
+ const panGesture = useMemo(() => {
460
+ if (!hasRefresher)
461
+ return Gesture.Pan(); // 返回空手势
462
+ return Gesture.Pan()
463
+ .onUpdate((event) => {
464
+ 'worklet';
465
+ if (enhanced && !!bounces) {
466
+ if (event.translationY > 0 && bouncesValue.value) {
467
+ updateBouncesState(false);
468
+ }
469
+ else if ((event.translationY < 0) && !bouncesValue.value) {
470
+ updateBouncesState(true);
471
+ }
465
472
  }
466
- else if ((event.translationY < 0) && !bouncesValue.value) {
467
- updateBouncesState(true);
473
+ if (translateY.value <= 0 && event.translationY < 0) {
474
+ // 滑动到顶再向上开启滚动
475
+ updateScrollState(true);
468
476
  }
469
- }
470
- if (translateY.value <= 0 && event.translationY < 0) {
471
- // 滑动到顶再向上开启滚动
472
- updateScrollState(true);
473
- }
474
- else if (event.translationY > 0 && isAtTop.value) {
475
- // 滚动到顶再向下禁止滚动
476
- updateScrollState(false);
477
- }
478
- // 禁止滚动后切换为滑动
479
- if (!enableScrollValue.value && isAtTop.value) {
477
+ else if (event.translationY > 0 && isAtTop.value) {
478
+ // 滚动到顶再向下禁止滚动
479
+ updateScrollState(false);
480
+ }
481
+ // 禁止滚动后切换为滑动
482
+ if (!enableScrollValue.value && isAtTop.value) {
483
+ if (refreshing) {
484
+ // 从完全展开状态(refresherHeight.value)开始计算偏移
485
+ translateY.value = Math.max(0, Math.min(refresherHeight.value, refresherHeight.value + event.translationY));
486
+ }
487
+ else if (event.translationY > 0) {
488
+ // 非刷新状态下的下拉逻辑保持不变
489
+ translateY.value = Math.min(event.translationY * 0.6, refresherHeight.value);
490
+ }
491
+ }
492
+ })
493
+ .onEnd((event) => {
494
+ 'worklet';
495
+ if (enableScrollValue.value)
496
+ return;
480
497
  if (refreshing) {
481
- // 从完全展开状态(refresherHeight.value)开始计算偏移
482
- translateY.value = Math.max(0, Math.min(refresherHeight.value, refresherHeight.value + event.translationY));
498
+ // 刷新状态下,根据滑动距离决定是否隐藏
499
+ // 如果向下滑动没超过 refresherThreshold,就完全隐藏,如果向上滑动完全隐藏
500
+ if ((event.translationY > 0 && translateY.value < refresherThreshold) || event.translationY < 0) {
501
+ translateY.value = withTiming(0);
502
+ updateScrollState(true);
503
+ runOnJS(runOnJSCallback)('setRefreshing', false);
504
+ }
505
+ else {
506
+ translateY.value = withTiming(refresherHeight.value);
507
+ }
483
508
  }
484
- else if (event.translationY > 0) {
485
- // 非刷新状态下的下拉逻辑保持不变
486
- translateY.value = Math.min(event.translationY * 0.6, refresherHeight.value);
509
+ else if (event.translationY >= refresherHeight.value) {
510
+ // 触发刷新
511
+ translateY.value = withTiming(refresherHeight.value);
512
+ runOnJS(runOnJSCallback)('onRefresh');
487
513
  }
488
- }
489
- })
490
- .onEnd((event) => {
491
- 'worklet';
492
- if (enableScrollValue.value)
493
- return;
494
- if (refreshing) {
495
- // 刷新状态下,根据滑动距离决定是否隐藏
496
- // 如果向下滑动没超过 refresherThreshold,就完全隐藏,如果向上滑动完全隐藏
497
- if ((event.translationY > 0 && translateY.value < refresherThreshold) || event.translationY < 0) {
514
+ else {
515
+ // 回弹
498
516
  translateY.value = withTiming(0);
499
517
  updateScrollState(true);
500
518
  runOnJS(runOnJSCallback)('setRefreshing', false);
501
519
  }
502
- else {
503
- translateY.value = withTiming(refresherHeight.value);
504
- }
505
- }
506
- else if (event.translationY >= refresherHeight.value) {
507
- // 触发刷新
508
- translateY.value = withTiming(refresherHeight.value);
509
- runOnJS(runOnJSCallback)('onRefresh');
510
- }
511
- else {
512
- // 回弹
513
- translateY.value = withTiming(0);
514
- updateScrollState(true);
515
- runOnJS(runOnJSCallback)('setRefreshing', false);
516
- }
517
- })
518
- .simultaneousWithExternalGesture(scrollViewRef);
520
+ })
521
+ .simultaneousWithExternalGesture(scrollViewRef);
522
+ }, [hasRefresher, enhanced, bounces, refreshing, refresherThreshold]);
519
523
  const scrollAdditionalProps = extendObject({
520
524
  style: extendObject(hasOwn(innerStyle, 'flex') || hasOwn(innerStyle, 'flexGrow')
521
525
  ? {}
@@ -575,29 +579,31 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
575
579
  'bindrefresherrefresh'
576
580
  ], { layoutRef });
577
581
  const ScrollViewComponent = enableSticky ? AnimatedScrollView : ScrollView;
578
- const withRefresherScrollView = createElement(GestureDetector, { gesture: panGesture }, createElement(ScrollViewComponent, innerProps, createElement(Animated.View, { style: [refresherAnimatedStyle, refresherLayoutStyle], onLayout: onRefresherLayout }, refresherContent), createElement(Animated.View, { style: contentAnimatedStyle }, createElement(ScrollViewContext.Provider, { value: contextValue }, wrapChildren(extendObject({}, props, { children: otherContent }), {
579
- hasVarDec,
580
- varContext: varContextRef.current,
581
- textStyle,
582
- textProps
583
- })))));
584
- const commonScrollView = createElement(ScrollViewComponent, extendObject({}, innerProps, {
585
- refreshControl: refresherEnabled
582
+ const createScrollViewContent = () => {
583
+ const wrappedChildren = wrapChildren(hasRefresher ? extendObject({}, props, { children: otherContent }) : props, {
584
+ hasVarDec,
585
+ varContext: varContextRef.current,
586
+ textStyle,
587
+ textProps
588
+ });
589
+ return createElement(ScrollViewContext.Provider, { value: contextValue }, wrappedChildren);
590
+ };
591
+ const withRefresherScrollView = () => {
592
+ return createElement(GestureDetector, { gesture: panGesture }, createElement(ScrollViewComponent, innerProps, createElement(Animated.View, { style: [refresherAnimatedStyle, refresherLayoutStyle], onLayout: onRefresherLayout }, refresherContent), createElement(Animated.View, { style: contentAnimatedStyle }, createScrollViewContent())));
593
+ };
594
+ const commonScrollView = () => {
595
+ const refreshControl = refresherEnabled
586
596
  ? createElement(RefreshControl, extendObject({
587
597
  progressBackgroundColor: refresherBackground,
588
598
  refreshing: refreshing,
589
599
  onRefresh: onRefresh
590
600
  }, refresherDefaultStyle && refresherDefaultStyle !== 'none'
591
- ? { colors: refreshColor[refresherDefaultStyle] }
601
+ ? { colors: REFRESH_COLOR[refresherDefaultStyle] }
592
602
  : {}))
593
- : undefined
594
- }), createElement(ScrollViewContext.Provider, { value: contextValue }, wrapChildren(props, {
595
- hasVarDec,
596
- varContext: varContextRef.current,
597
- textStyle,
598
- textProps
599
- })));
600
- let scrollViewComponent = hasRefresher ? withRefresherScrollView : commonScrollView;
603
+ : undefined;
604
+ return createElement(ScrollViewComponent, extendObject({}, innerProps, { refreshControl }), createScrollViewContent());
605
+ };
606
+ let scrollViewComponent = hasRefresher ? withRefresherScrollView() : commonScrollView();
601
607
  if (hasPositionFixed) {
602
608
  scrollViewComponent = createElement(Portal, null, scrollViewComponent);
603
609
  }
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ interface ListItem {
3
+ isSectionHeader?: boolean;
4
+ _originalItemIndex?: number;
5
+ [key: string]: any;
6
+ }
7
+ interface ItemHeightType {
8
+ value?: number;
9
+ getter?: (item: any, index: number) => number;
10
+ }
11
+ interface SectionListProps {
12
+ enhanced?: boolean;
13
+ bounces?: boolean;
14
+ scrollEventThrottle?: number;
15
+ height?: number | string;
16
+ width?: number | string;
17
+ listData?: ListItem[];
18
+ generichash?: string;
19
+ style?: Record<string, any>;
20
+ itemHeight?: ItemHeightType;
21
+ sectionHeaderHeight?: ItemHeightType;
22
+ listHeaderData?: any;
23
+ listHeaderHeight?: ItemHeightType;
24
+ useListHeader?: boolean;
25
+ listFooterData?: any;
26
+ useListFooter?: boolean;
27
+ 'genericrecycle-item'?: string;
28
+ 'genericsection-header'?: string;
29
+ 'genericlist-header'?: string;
30
+ 'genericlist-footer'?: string;
31
+ 'enable-var'?: boolean;
32
+ 'external-var-context'?: any;
33
+ 'parent-font-size'?: number;
34
+ 'parent-width'?: number;
35
+ 'parent-height'?: number;
36
+ 'enable-sticky'?: boolean;
37
+ 'enable-back-to-top'?: boolean;
38
+ 'end-reached-threshold'?: number;
39
+ 'refresher-enabled'?: boolean;
40
+ 'show-scrollbar'?: boolean;
41
+ 'refresher-triggered'?: boolean;
42
+ bindrefresherrefresh?: (event: any) => void;
43
+ bindscrolltolower?: (event: any) => void;
44
+ bindscroll?: (event: any) => void;
45
+ [key: string]: any;
46
+ }
47
+ declare const _SectionList: React.ForwardRefExoticComponent<Omit<SectionListProps, "ref"> & React.RefAttributes<any>>;
48
+ export default _SectionList;
@@ -0,0 +1,292 @@
1
+ import React, { forwardRef, useRef, useState, useEffect, useMemo, createElement, useImperativeHandle, memo } from 'react';
2
+ import { SectionList, RefreshControl } from 'react-native';
3
+ import useInnerProps, { getCustomEvent } from './getInnerListeners';
4
+ import { extendObject, useLayout, useTransformStyle } from './utils';
5
+ const getGeneric = (generichash, generickey) => {
6
+ if (!generichash || !generickey)
7
+ return null;
8
+ const GenericComponent = global.__mpxGenericsMap?.[generichash]?.[generickey]?.();
9
+ if (!GenericComponent)
10
+ return null;
11
+ return memo(forwardRef((props, ref) => {
12
+ return createElement(GenericComponent, extendObject({}, {
13
+ ref: ref
14
+ }, props));
15
+ }));
16
+ };
17
+ const _SectionList = forwardRef((props = {}, ref) => {
18
+ const { enhanced = false, bounces = true, scrollEventThrottle = 0, height, width, listData, generichash, style = {}, itemHeight = {}, sectionHeaderHeight = {}, listHeaderHeight = {}, listHeaderData = null, useListHeader = false, listFooterData = null, useListFooter = false, 'genericrecycle-item': genericrecycleItem, 'genericsection-header': genericsectionHeader, 'genericlist-header': genericListHeader, 'genericlist-footer': genericListFooter, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'enable-sticky': enableSticky = false, 'enable-back-to-top': enableBackToTop = false, 'end-reached-threshold': onEndReachedThreshold = 0.1, 'refresher-enabled': refresherEnabled, 'show-scrollbar': showScrollbar = true, 'refresher-triggered': refresherTriggered } = props;
19
+ const [refreshing, setRefreshing] = useState(!!refresherTriggered);
20
+ const scrollViewRef = useRef(null);
21
+ const indexMap = useRef({});
22
+ const reverseIndexMap = useRef({});
23
+ const { hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
24
+ const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: scrollViewRef });
25
+ useEffect(() => {
26
+ if (refreshing !== refresherTriggered) {
27
+ setRefreshing(!!refresherTriggered);
28
+ }
29
+ }, [refresherTriggered]);
30
+ const onRefresh = () => {
31
+ const { bindrefresherrefresh } = props;
32
+ bindrefresherrefresh &&
33
+ bindrefresherrefresh(getCustomEvent('refresherrefresh', {}, { layoutRef }, props));
34
+ };
35
+ const onEndReached = () => {
36
+ const { bindscrolltolower } = props;
37
+ bindscrolltolower &&
38
+ bindscrolltolower(getCustomEvent('scrolltolower', {}, { layoutRef }, props));
39
+ };
40
+ const onScroll = (event) => {
41
+ const { bindscroll } = props;
42
+ bindscroll &&
43
+ bindscroll(getCustomEvent('scroll', event.nativeEvent, { layoutRef }, props));
44
+ };
45
+ // 通过sectionIndex和rowIndex获取原始索引
46
+ const getOriginalIndex = (sectionIndex, rowIndex) => {
47
+ const key = `${sectionIndex}_${rowIndex}`;
48
+ return reverseIndexMap.current[key] ?? -1; // 如果找不到,返回-1
49
+ };
50
+ const scrollToIndex = ({ index, animated, viewOffset = 0, viewPosition = 0 }) => {
51
+ if (scrollViewRef.current) {
52
+ // 通过索引映射表快速定位位置
53
+ const position = indexMap.current[index];
54
+ const [sectionIndex, itemIndex] = position.split('_');
55
+ scrollViewRef.current.scrollToLocation?.({
56
+ itemIndex: itemIndex === 'header' ? 0 : Number(itemIndex) + 1,
57
+ sectionIndex: Number(sectionIndex) || 0,
58
+ animated,
59
+ viewOffset,
60
+ viewPosition
61
+ });
62
+ }
63
+ };
64
+ const getItemHeight = ({ sectionIndex, rowIndex }) => {
65
+ if (!itemHeight) {
66
+ return 0;
67
+ }
68
+ if (itemHeight.getter) {
69
+ const item = convertedListData[sectionIndex].data[rowIndex];
70
+ // 使用getOriginalIndex获取原始索引
71
+ const originalIndex = getOriginalIndex(sectionIndex, rowIndex);
72
+ return itemHeight.getter?.(item, originalIndex) || 0;
73
+ }
74
+ else {
75
+ return itemHeight.value || 0;
76
+ }
77
+ };
78
+ const getSectionHeaderHeight = ({ sectionIndex }) => {
79
+ const item = convertedListData[sectionIndex];
80
+ const { hasSectionHeader } = item;
81
+ // 使用getOriginalIndex获取原始索引
82
+ const originalIndex = getOriginalIndex(sectionIndex, 'header');
83
+ if (!hasSectionHeader)
84
+ return 0;
85
+ if (sectionHeaderHeight.getter) {
86
+ return sectionHeaderHeight.getter?.(item, originalIndex) || 0;
87
+ }
88
+ else {
89
+ return sectionHeaderHeight.value || 0;
90
+ }
91
+ };
92
+ const convertedListData = useMemo(() => {
93
+ const sections = [];
94
+ let currentSection = null;
95
+ // 清空之前的索引映射
96
+ indexMap.current = {};
97
+ // 清空反向索引映射
98
+ reverseIndexMap.current = {};
99
+ // 处理 listData 为空的情况
100
+ if (!listData || !listData.length) {
101
+ return sections;
102
+ }
103
+ listData.forEach((item, index) => {
104
+ if (item.isSectionHeader) {
105
+ // 如果已经存在一个 section,先把它添加到 sections 中
106
+ if (currentSection) {
107
+ sections.push(currentSection);
108
+ }
109
+ // 创建新的 section
110
+ currentSection = {
111
+ headerData: item,
112
+ data: [],
113
+ hasSectionHeader: true,
114
+ _originalItemIndex: index
115
+ };
116
+ // 为 section header 添加索引映射
117
+ const sectionIndex = sections.length;
118
+ indexMap.current[index] = `${sectionIndex}_header`;
119
+ // 添加反向索引映射
120
+ reverseIndexMap.current[`${sectionIndex}_header`] = index;
121
+ }
122
+ else {
123
+ // 如果没有当前 section,创建一个默认的
124
+ if (!currentSection) {
125
+ // 创建默认section (无header的section)
126
+ currentSection = {
127
+ headerData: null,
128
+ data: [],
129
+ hasSectionHeader: false,
130
+ _originalItemIndex: -1
131
+ };
132
+ }
133
+ // 将 item 添加到当前 section 的 data 中
134
+ const itemIndex = currentSection.data.length;
135
+ currentSection.data.push(extendObject({}, item, {
136
+ _originalItemIndex: index
137
+ }));
138
+ let sectionIndex;
139
+ // 为 item 添加索引映射 - 存储格式为: "sectionIndex_itemIndex"
140
+ if (!currentSection.hasSectionHeader && sections.length === 0) {
141
+ // 在默认section中(第一个且无header)
142
+ sectionIndex = 0;
143
+ indexMap.current[index] = `${sectionIndex}_${itemIndex}`;
144
+ }
145
+ else {
146
+ // 在普通section中
147
+ sectionIndex = sections.length;
148
+ indexMap.current[index] = `${sectionIndex}_${itemIndex}`;
149
+ }
150
+ // 添加反向索引映射
151
+ reverseIndexMap.current[`${sectionIndex}_${itemIndex}`] = index;
152
+ }
153
+ });
154
+ // 添加最后一个 section
155
+ if (currentSection) {
156
+ sections.push(currentSection);
157
+ }
158
+ return sections;
159
+ }, [listData]);
160
+ const { getItemLayout } = useMemo(() => {
161
+ const layouts = [];
162
+ let offset = 0;
163
+ if (useListHeader) {
164
+ // 计算列表头部的高度
165
+ offset += listHeaderHeight.getter?.() || listHeaderHeight.value || 0;
166
+ }
167
+ // 遍历所有 sections
168
+ convertedListData.forEach((section, sectionIndex) => {
169
+ // 添加 section header 的位置信息
170
+ const headerHeight = getSectionHeaderHeight({ sectionIndex });
171
+ layouts.push({
172
+ length: headerHeight,
173
+ offset,
174
+ index: layouts.length
175
+ });
176
+ offset += headerHeight;
177
+ // 添加该 section 中所有 items 的位置信息
178
+ section.data.forEach((item, itemIndex) => {
179
+ const contenteight = getItemHeight({ sectionIndex, rowIndex: itemIndex });
180
+ layouts.push({
181
+ length: contenteight,
182
+ offset,
183
+ index: layouts.length
184
+ });
185
+ offset += contenteight;
186
+ });
187
+ // 添加该 section 尾部位置信息
188
+ // 因为即使 sectionList 没传 renderSectionFooter,getItemLayout 中的 index 的计算也会包含尾部节点
189
+ layouts.push({
190
+ length: 0,
191
+ offset,
192
+ index: layouts.length
193
+ });
194
+ });
195
+ return {
196
+ itemLayouts: layouts,
197
+ getItemLayout: (data, index) => layouts[index]
198
+ };
199
+ }, [convertedListData, useListHeader, itemHeight.value, itemHeight.getter, sectionHeaderHeight.value, sectionHeaderHeight.getter, listHeaderHeight.value, listHeaderHeight.getter]);
200
+ const scrollAdditionalProps = extendObject({
201
+ alwaysBounceVertical: false,
202
+ alwaysBounceHorizontal: false,
203
+ scrollEventThrottle: scrollEventThrottle,
204
+ scrollsToTop: enableBackToTop,
205
+ showsHorizontalScrollIndicator: showScrollbar,
206
+ onEndReachedThreshold,
207
+ ref: scrollViewRef,
208
+ bounces: false,
209
+ stickySectionHeadersEnabled: enableSticky,
210
+ onScroll: onScroll,
211
+ onEndReached: onEndReached
212
+ }, layoutProps);
213
+ if (enhanced) {
214
+ Object.assign(scrollAdditionalProps, {
215
+ bounces
216
+ });
217
+ }
218
+ if (refresherEnabled) {
219
+ Object.assign(scrollAdditionalProps, {
220
+ refreshing: refreshing
221
+ });
222
+ }
223
+ useImperativeHandle(ref, () => {
224
+ return {
225
+ ...props,
226
+ scrollToIndex
227
+ };
228
+ });
229
+ const innerProps = useInnerProps(extendObject({}, props, scrollAdditionalProps), [
230
+ 'id',
231
+ 'show-scrollbar',
232
+ 'lower-threshold',
233
+ 'refresher-triggered',
234
+ 'refresher-enabled',
235
+ 'bindrefresherrefresh'
236
+ ], { layoutRef });
237
+ // 使用 ref 保存最新的数据,避免数据变化时组件销毁重建
238
+ const listHeaderDataRef = useRef(listHeaderData);
239
+ listHeaderDataRef.current = listHeaderData;
240
+ const listFooterDataRef = useRef(listFooterData);
241
+ listFooterDataRef.current = listFooterData;
242
+ // 使用 useMemo 获取 GenericComponent 并创建渲染函数,避免每次组件更新都重新创建函数引用导致不必要的重新渲染
243
+ const renderItem = useMemo(() => {
244
+ const ItemComponent = getGeneric(generichash, genericrecycleItem);
245
+ if (!ItemComponent)
246
+ return undefined;
247
+ return ({ item }) => createElement(ItemComponent, { itemData: item });
248
+ }, [generichash, genericrecycleItem]);
249
+ const renderSectionHeader = useMemo(() => {
250
+ const SectionHeaderComponent = getGeneric(generichash, genericsectionHeader);
251
+ if (!SectionHeaderComponent)
252
+ return undefined;
253
+ return (sectionData) => {
254
+ if (!sectionData.section.hasSectionHeader)
255
+ return null;
256
+ return createElement(SectionHeaderComponent, { itemData: sectionData.section.headerData });
257
+ };
258
+ }, [generichash, genericsectionHeader]);
259
+ const ListHeaderComponent = useMemo(() => {
260
+ if (!useListHeader)
261
+ return null;
262
+ const ListHeaderGenericComponent = getGeneric(generichash, genericListHeader);
263
+ if (!ListHeaderGenericComponent)
264
+ return null;
265
+ return () => createElement(ListHeaderGenericComponent, { listHeaderData: listHeaderDataRef.current });
266
+ }, [useListHeader, generichash, genericListHeader]);
267
+ const ListFooterComponent = useMemo(() => {
268
+ if (!useListFooter)
269
+ return null;
270
+ const ListFooterGenericComponent = getGeneric(generichash, genericListFooter);
271
+ if (!ListFooterGenericComponent)
272
+ return null;
273
+ return () => createElement(ListFooterGenericComponent, { listFooterData: listFooterDataRef.current });
274
+ }, [useListFooter, generichash, genericListFooter]);
275
+ return createElement(SectionList, extendObject({
276
+ style: [{ height, width }, style, layoutStyle],
277
+ sections: convertedListData,
278
+ renderItem: renderItem,
279
+ getItemLayout: getItemLayout,
280
+ ListHeaderComponent: useListHeader ? ListHeaderComponent : null,
281
+ ListFooterComponent: useListFooter ? ListFooterComponent : null,
282
+ renderSectionHeader: renderSectionHeader,
283
+ refreshControl: refresherEnabled
284
+ ? React.createElement(RefreshControl, {
285
+ onRefresh: onRefresh,
286
+ refreshing: refreshing
287
+ })
288
+ : undefined
289
+ }, innerProps));
290
+ });
291
+ _SectionList.displayName = 'MpxSectionList';
292
+ export default _SectionList;
@@ -5,4 +5,3 @@ declare const SimpleText: {
5
5
  displayName: string;
6
6
  };
7
7
  export default SimpleText;
8
- //# sourceMappingURL=mpx-simple-text.d.ts.map
@@ -5,4 +5,3 @@ declare const SimpleView: {
5
5
  displayName: string;
6
6
  };
7
7
  export default SimpleView;
8
- //# sourceMappingURL=mpx-simple-view.d.ts.map
@@ -28,4 +28,3 @@ export interface SliderProps {
28
28
  }
29
29
  declare const Slider: import("react").ForwardRefExoticComponent<SliderProps & import("react").RefAttributes<HandlerRef<View, SliderProps>>>;
30
30
  export default Slider;
31
- //# sourceMappingURL=mpx-slider.d.ts.map
@@ -15,4 +15,3 @@ interface StickyHeaderProps {
15
15
  }
16
16
  declare const _StickyHeader: import("react").ForwardRefExoticComponent<StickyHeaderProps & import("react").RefAttributes<HandlerRef<View, StickyHeaderProps>>>;
17
17
  export default _StickyHeader;
18
- //# sourceMappingURL=mpx-sticky-header.d.ts.map
@@ -8,9 +8,8 @@ import useInnerProps, { getCustomEvent } from './getInnerListeners';
8
8
  const _StickyHeader = forwardRef((stickyHeaderProps = {}, ref) => {
9
9
  const { textProps, innerProps: props = {} } = splitProps(stickyHeaderProps);
10
10
  const { style, bindstickontopchange, padding = [0, 0, 0, 0], 'offset-top': offsetTop = 0, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
11
- const scrollViewContext = useContext(ScrollViewContext);
11
+ const { scrollOffset, gestureRef: scrollViewRef } = useContext(ScrollViewContext);
12
12
  const stickyContext = useContext(StickyContext);
13
- const { scrollOffset } = scrollViewContext;
14
13
  const { registerStickyHeader, unregisterStickyHeader } = stickyContext;
15
14
  const headerRef = useRef(null);
16
15
  const isStickOnTopRef = useRef(false);
@@ -29,7 +28,6 @@ const _StickyHeader = forwardRef((stickyHeaderProps = {}, ref) => {
29
28
  }, []);
30
29
  function updatePosition() {
31
30
  if (headerRef.current) {
32
- const scrollViewRef = scrollViewContext.gestureRef;
33
31
  if (scrollViewRef && scrollViewRef.current) {
34
32
  headerRef.current.measureLayout(scrollViewRef.current, (left, top) => {
35
33
  Animated.timing(headerTopAnimated, {
@@ -52,7 +50,7 @@ const _StickyHeader = forwardRef((stickyHeaderProps = {}, ref) => {
52
50
  style: normalStyle
53
51
  });
54
52
  useEffect(() => {
55
- if (!bindstickontopchange)
53
+ if (!bindstickontopchange || !scrollOffset)
56
54
  return;
57
55
  const listener = scrollOffset.addListener((state) => {
58
56
  const currentScrollValue = state.value;
@@ -70,24 +68,26 @@ const _StickyHeader = forwardRef((stickyHeaderProps = {}, ref) => {
70
68
  return () => {
71
69
  scrollOffset.removeListener(listener);
72
70
  };
73
- }, []);
71
+ }, [bindstickontopchange, scrollOffset]);
74
72
  const animatedStyle = useMemo(() => {
75
- const translateY = Animated.subtract(scrollOffset, headerTopAnimated).interpolate({
76
- inputRange: [0, 1],
77
- outputRange: [0, 1],
78
- extrapolateLeft: 'clamp',
79
- extrapolateRight: 'extend'
80
- });
81
- const finalTranslateY = offsetTop === 0
82
- ? translateY
83
- : Animated.add(translateY, Animated.subtract(scrollOffset, headerTopAnimated).interpolate({
73
+ if (scrollOffset) {
74
+ const translateY = Animated.subtract(scrollOffset, headerTopAnimated).interpolate({
84
75
  inputRange: [0, 1],
85
- outputRange: [0, offsetTop],
86
- extrapolate: 'clamp'
87
- }));
88
- return {
89
- transform: [{ translateY: finalTranslateY }]
90
- };
76
+ outputRange: [0, 1],
77
+ extrapolateLeft: 'clamp',
78
+ extrapolateRight: 'extend'
79
+ });
80
+ const finalTranslateY = offsetTop === 0
81
+ ? translateY
82
+ : Animated.add(translateY, Animated.subtract(scrollOffset, headerTopAnimated).interpolate({
83
+ inputRange: [0, 1],
84
+ outputRange: [0, offsetTop],
85
+ extrapolate: 'clamp'
86
+ }));
87
+ return {
88
+ transform: [{ translateY: finalTranslateY }]
89
+ };
90
+ }
91
91
  }, [scrollOffset, headerTopAnimated, offsetTop]);
92
92
  const innerProps = useInnerProps(extendObject({}, props, {
93
93
  ref: headerRef,
@@ -13,4 +13,3 @@ interface StickySectionProps {
13
13
  }
14
14
  declare const _StickySection: import("react").ForwardRefExoticComponent<StickySectionProps & import("react").RefAttributes<HandlerRef<View, StickySectionProps>>>;
15
15
  export default _StickySection;
16
- //# sourceMappingURL=mpx-sticky-section.d.ts.map