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

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 +244 -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
@@ -0,0 +1,551 @@
1
+ <template>
2
+ <div class="mpx-section-list">
3
+ <ScrollView
4
+ ref="scrollView"
5
+ :enableSticky="enableSticky"
6
+ :scroll-y="true"
7
+ :enhanced="enhanced"
8
+ :scrollWithAnimation="scrollWithAnimation"
9
+ :refresherEnabled="refresherEnabled"
10
+ :refresherTriggered="refresherTriggered"
11
+ :scrollOptions="scrollOptions"
12
+ @scroll="onScroll"
13
+ @scrolltolower="onScrolltolower"
14
+ @refresherrefresh="onRefresherrefresh"
15
+ :style="scrollViewStyle"
16
+ >
17
+ <div class="content-wrapper">
18
+ <template v-if="useListHeader">
19
+ <list-header :listHeaderData="listHeaderData"></list-header>
20
+ </template>
21
+ <div class="infinite-list-placeholder" ref="infinitePlaceholder"></div>
22
+ <div class="infinite-list" ref="infiniteList">
23
+ <template v-for="item in visibleData">
24
+ <section-header
25
+ v-if="item.itemData && item.itemData.isSectionHeader"
26
+ :key="'header' + (item.itemData.item_key || item._index)"
27
+ :itemData="item.itemData"
28
+ />
29
+ <recycle-item
30
+ v-if="item.itemData && !item.itemData.isSectionHeader"
31
+ :key="'item' + (item.itemData.item_key || item._index)"
32
+ :itemData="item.itemData"
33
+ />
34
+ </template>
35
+ </div>
36
+ <template v-if="useListFooter">
37
+ <list-footer :listFooterData="listFooterData"></list-footer>
38
+ </template>
39
+ </div>
40
+ <template
41
+ v-if="
42
+ _stickyHeaders &&
43
+ _stickyHeaders.length &&
44
+ enableSticky &&
45
+ genericsectionHeader
46
+ "
47
+ >
48
+ <StickyHeader
49
+ v-for="stickyItem in _stickyHeaders"
50
+ :key="stickyItem._index"
51
+ class="sticky-section"
52
+ :style="{
53
+ top:
54
+ ((positions[stickyItem._index] &&
55
+ positions[stickyItem._index].top) ||
56
+ 0) + 'px',
57
+ }"
58
+ >
59
+ <section-header
60
+ :key="'header' + stickyItem._index"
61
+ :itemData="stickyItem.itemData"
62
+ />
63
+ </StickyHeader>
64
+ </template>
65
+ </ScrollView>
66
+ </div>
67
+ </template>
68
+
69
+ <script>
70
+ import ScrollView from "./mpx-scroll-view.vue";
71
+ import StickyHeader from "./mpx-sticky-header.vue";
72
+
73
+ export default {
74
+ props: {
75
+ width: String | Number,
76
+ height: String | Number,
77
+ listData: {
78
+ type: Array,
79
+ default: () => {
80
+ return []
81
+ }
82
+ },
83
+ scrollOptions: {
84
+ type: Object,
85
+ default: () => {
86
+ return {}
87
+ }
88
+ },
89
+ minRenderCount: {
90
+ type: Number,
91
+ default: 10,
92
+ },
93
+ bufferScale: {
94
+ type: Number,
95
+ default: 1,
96
+ },
97
+ itemHeight: {
98
+ type: Object,
99
+ default: () => {
100
+ return {}
101
+ }
102
+ },
103
+ listHeaderHeight: {
104
+ type: Object,
105
+ default: () => {
106
+ return {}
107
+ }
108
+ },
109
+ sectionHeaderHeight: {
110
+ type: Object,
111
+ default: () => {
112
+ return {}
113
+ }
114
+ },
115
+ listHeaderData: {
116
+ type: Object,
117
+ default: () => {
118
+ return {}
119
+ }
120
+ },
121
+ enhanced: {
122
+ type: Boolean,
123
+ default: false
124
+ },
125
+ refresherEnabled: {
126
+ type: Boolean,
127
+ default: false
128
+ },
129
+ refresherTriggered: {
130
+ type: Boolean,
131
+ default: false
132
+ },
133
+ enableSticky: {
134
+ type: Boolean,
135
+ default: false
136
+ },
137
+ scrollWithAnimation: {
138
+ type: Boolean,
139
+ default: false
140
+ },
141
+ useListHeader: {
142
+ type: Boolean,
143
+ default: true
144
+ },
145
+ listFooterData: {
146
+ type: Object,
147
+ default: () => {
148
+ return {}
149
+ }
150
+ },
151
+ useListFooter: {
152
+ type: Boolean,
153
+ default: false
154
+ },
155
+ generichash: String,
156
+ genericlistHeader: String,
157
+ genericlistFooter: String,
158
+ genericrecycleItem: String,
159
+ genericsectionHeader: String
160
+ },
161
+ data() {
162
+ return {
163
+ start: 0,
164
+ end: 0,
165
+ containerHeight: 0,
166
+ positions: [],
167
+ visibleCounts: [],
168
+ };
169
+ },
170
+ computed: {
171
+ _listData() {
172
+ return (this.listData && this.listData.map((item, index) => {
173
+ return {
174
+ itemData: item,
175
+ _index: `_${index}`,
176
+ };
177
+ })) || [];
178
+ },
179
+ _stickyHeaders() {
180
+ const data = [];
181
+ this.listData && this.listData.forEach((item, index) => {
182
+ if (item.isSectionHeader) {
183
+ data.push({
184
+ itemData: item,
185
+ _index: index,
186
+ });
187
+ }
188
+ });
189
+ return data;
190
+ },
191
+ scrollViewStyle() {
192
+ return `height: ${this.formatDimension(
193
+ this.height
194
+ )};width: ${this.formatDimension(this.width)}`;
195
+ },
196
+ visibleCount() {
197
+ if (!this.visibleCounts.length) return this.minRenderCount;
198
+ return Math.max(this.visibleCounts[this.start], this.minRenderCount);
199
+ },
200
+ aboveCount() {
201
+ if (!this._listData.length || !this.visibleCounts.length) return 0;
202
+ let count = 0;
203
+ const startIndex = Math.max(0, this.start);
204
+ const endIndex = Math.max(0, startIndex - this.bufferScale);
205
+
206
+ for (let i = startIndex; i > endIndex; i--) {
207
+ count += this.visibleCounts[i] || 0;
208
+ }
209
+
210
+ return count;
211
+ },
212
+ belowCount() {
213
+ if (!this._listData.length || !this.visibleCounts.length) return 0;
214
+ let count = 0;
215
+ const startIndex = Math.min(this.start, this._listData.length - 1);
216
+ const endIndex = Math.min(
217
+ startIndex + this.bufferScale,
218
+ this._listData.length - 1
219
+ );
220
+
221
+ for (let i = startIndex; i < endIndex; i++) {
222
+ count += this.visibleCounts[i] || 0;
223
+ }
224
+
225
+ return count;
226
+ },
227
+ visibleData() {
228
+ if (!this._listData.length) return [];
229
+
230
+ const start = Math.min(
231
+ Math.max(0, this.start - this.aboveCount),
232
+ this._listData.length - 1
233
+ );
234
+
235
+ let end = Math.min(
236
+ this._listData.length,
237
+ this.start + this.visibleCount + this.belowCount
238
+ );
239
+
240
+ // 如果接近列表末尾,确保显示所有剩余项目
241
+ if (end > this._listData.length - 3) {
242
+ end = this._listData.length;
243
+ }
244
+
245
+ return this._listData.slice(start, end).map((item, idx) => {
246
+ const realIndex = start + idx;
247
+ return {
248
+ ...item,
249
+ _index: `_${realIndex}`,
250
+ };
251
+ });
252
+ },
253
+ _listHeaderHeight() {
254
+ let listHeaderHeight = 0;
255
+ if (this.useListHeader) {
256
+ listHeaderHeight =
257
+ this.getItemHeight(this.listHeaderData, 0, "listHeaderHeight") || 0;
258
+ }
259
+ return listHeaderHeight;
260
+ },
261
+ placeholderHeight() {
262
+ if (!this.positions.length) return 0;
263
+ return (
264
+ this.positions[this.positions.length - 1].bottom -
265
+ this._listHeaderHeight || 0
266
+ );
267
+ },
268
+ },
269
+ watch: {
270
+ listData: {
271
+ handler() {
272
+ this.initPositions();
273
+ this.setPlaceholderStyle();
274
+ // 更新真实偏移量
275
+ this.setStartOffset();
276
+ },
277
+ },
278
+ itemHeight: {
279
+ handler() {
280
+ this.handleHeightChange()
281
+ },
282
+ deep: true
283
+ },
284
+ sectionHeaderHeight: {
285
+ handler() {
286
+ this.handleHeightChange()
287
+ },
288
+ deep: true
289
+ },
290
+ listHeaderHeight: {
291
+ handler() {
292
+ this.handleHeightChange()
293
+ },
294
+ deep: true
295
+ },
296
+ containerHeight() {
297
+ this.calculateVisibleCounts();
298
+ },
299
+ },
300
+ created() {
301
+ this.registerGenericComponents();
302
+ },
303
+ mounted() {
304
+ this.initPositions();
305
+ this.containerHeight = this.$refs.scrollView?.$el?.clientHeight || 0;
306
+ this.setPlaceholderStyle();
307
+ if (!this.positions || !this.positions.length) {
308
+ return;
309
+ }
310
+ this.start = this.getStartIndex();
311
+ this.end = this.start + this.visibleCount;
312
+ this.setStartOffset();
313
+ },
314
+ methods: {
315
+ handleHeightChange () {
316
+ this.initPositions();
317
+ this.setPlaceholderStyle();
318
+ this.setStartOffset();
319
+ // 外部传值虽然变了,但是未触发 DOM 实际宽高变更,所以也不会自动触发 scrollView 内部 refresh 机制
320
+ // 需要手动触发,让 sticky-header 重新计算位置
321
+ this.$refs.scrollView?.forceUpdateRefreshVersion?.()
322
+ },
323
+ registerGenericComponents() {
324
+ if (!this.generichash || !global.__mpxGenericsMap[this.generichash]) {
325
+ return;
326
+ }
327
+
328
+ let components = null;
329
+ const genericList = {
330
+ "recycle-item": this.genericrecycleItem ,
331
+ "list-header": this.genericlistHeader,
332
+ "section-header": this.genericsectionHeader,
333
+ "list-footer": this.genericlistFooter
334
+ }
335
+
336
+ for (const key in genericList) {
337
+ const value = genericList[key]
338
+ if (value) {
339
+ components = components || {};
340
+ components[key] = global.__mpxGenericsMap[this.generichash][value]
341
+ }
342
+ }
343
+
344
+ if (components) {
345
+ this.$options.components = Object.assign(
346
+ {},
347
+ this.$options.components,
348
+ components
349
+ );
350
+ }
351
+ },
352
+ formatDimension(value) {
353
+ return typeof value === "number" ? `${value}px` : value || "100%";
354
+ },
355
+ setPlaceholderStyle() {
356
+ const infinitePlaceholder = this.$refs.infinitePlaceholder;
357
+ if (infinitePlaceholder) {
358
+ infinitePlaceholder.style.height = `${this.placeholderHeight}px`;
359
+ }
360
+ },
361
+ initPositions() {
362
+ let bottom = this._listHeaderHeight || 0;
363
+ this.positions = this._listData.map((item, index) => {
364
+ const height = this.getItemHeight(
365
+ item.itemData,
366
+ index,
367
+ item.itemData.isSectionHeader ? "sectionHeaderHeight" : "itemHeight"
368
+ );
369
+ const position = {
370
+ index,
371
+ height: height,
372
+ top: bottom,
373
+ bottom: bottom + height,
374
+ };
375
+ bottom = position.bottom;
376
+ return position;
377
+ });
378
+
379
+ if (this.containerHeight) {
380
+ this.calculateVisibleCounts();
381
+ }
382
+ },
383
+ calculateVisibleCounts() {
384
+ this.visibleCounts = this.positions.map((_, startIndex) => {
385
+ let count = 0;
386
+ let totalHeight = 0;
387
+
388
+ for (let i = startIndex; i < this.positions.length; i++) {
389
+ totalHeight += this.positions[i].height;
390
+ if (totalHeight > this.containerHeight) {
391
+ break;
392
+ }
393
+ count++;
394
+ }
395
+
396
+ // 如果是最后几个项目,确保全部显示
397
+ if (startIndex + count > this.positions.length - 3) {
398
+ count = this.positions.length - startIndex;
399
+ }
400
+
401
+ return count;
402
+ });
403
+ },
404
+
405
+ getStartIndex(scrollTop = 0) {
406
+ // 确保不会返回超出范围的索引
407
+ if (!this.positions.length) {
408
+ return 0;
409
+ }
410
+
411
+ // 如果滚动位置为0,直接返回0
412
+ if (scrollTop <= 0) {
413
+ return 0;
414
+ }
415
+ const index = this.binarySearch(this.positions, scrollTop);
416
+ return Math.max(0, Math.min(index, this._listData.length - 1));
417
+ },
418
+ binarySearch(list, value) {
419
+ if (!list.length) return 0;
420
+
421
+ // 如果 scrollTop 超过了最后一个元素的底部
422
+ if (value >= list[list.length - 1].bottom) {
423
+ return list.length - 1;
424
+ }
425
+
426
+ let start = 0;
427
+ let end = list.length - 1;
428
+
429
+ while (start <= end) {
430
+ const midIndex = Math.floor((start + end) / 2);
431
+ const midValue = list[midIndex];
432
+
433
+ if (value >= midValue.top && value < midValue.bottom) {
434
+ return midIndex;
435
+ }
436
+
437
+ if (value < midValue.top) {
438
+ end = midIndex - 1;
439
+ } else {
440
+ start = midIndex + 1;
441
+ }
442
+ }
443
+
444
+ return Math.min(Math.max(0, start - 1), list.length - 1);
445
+ },
446
+ setStartOffset() {
447
+ const infiniteList = this.$refs.infiniteList;
448
+ if (!this.positions.length || !infiniteList) return;
449
+ if (this.start >= 1) {
450
+ // 确保 startIndex 不会超出范围
451
+ const startIndex = Math.min(
452
+ Math.max(0, this.start - this.aboveCount),
453
+ this.positions.length - 1
454
+ );
455
+
456
+ const offset = this.positions[startIndex].top;
457
+ infiniteList.style.transform = `translateY(${offset}px)`;
458
+ } else {
459
+ infiniteList.style.transform = `translateY(${this.positions[0].top}px)`;
460
+ }
461
+ },
462
+ getItemHeight(item, index, key) {
463
+ const { value, getter } = this[key];
464
+ if (typeof getter === "function") {
465
+ return getter(item, index) || 0;
466
+ } else {
467
+ return value || 0;
468
+ }
469
+ },
470
+ onScroll(e) {
471
+ const { scrollTop } = e.detail;
472
+ const newStart = this.getStartIndex(scrollTop);
473
+
474
+ // 只有当start发生足够变化时才更新,避免滚动触发重渲染
475
+ if (Math.abs(newStart - this.end) >= Math.floor(this.belowCount / 2)) {
476
+ this.start = newStart;
477
+ this.end = this.start + this.visibleCount;
478
+ this.setStartOffset();
479
+ }
480
+
481
+ this.$emit("scroll", e);
482
+ },
483
+ onScrolltolower(e) {
484
+ this.$emit("scrolltolower", e);
485
+ },
486
+ onRefresherrefresh(e) {
487
+ this.$emit("refresherrefresh", e);
488
+ },
489
+ scrollToIndex({ index, animated, viewPosition = 0, viewOffset = 0 }) {
490
+ const isStickyHeader = this._listData[index].itemData?.isSectionHeader;
491
+ let prevHeaderHeight = 0;
492
+ // 如果不是sticky header 查找最近一个吸顶的 sticky header
493
+ if (!isStickyHeader && this.enableSticky) {
494
+ for (let i = index - 1; i >= 0; i--) {
495
+ if (this._listData[i].itemData?.isSectionHeader) {
496
+ prevHeaderHeight = this.positions[i].height;
497
+ break;
498
+ }
499
+ }
500
+ }
501
+
502
+ const itemTop = (this.positions[index]?.top || 0) - prevHeaderHeight;
503
+ const itemHeight = this.positions[index]?.height || 0;
504
+ const containerHeight = this.containerHeight;
505
+
506
+ let targetTop = itemTop;
507
+ if (viewPosition === 1) {
508
+ // 滚动到可视区底部
509
+ targetTop = itemTop - (containerHeight - itemHeight);
510
+ } else if (viewPosition === 0.5) {
511
+ // 滚动到可视区中央
512
+ targetTop = itemTop - (containerHeight - itemHeight) / 2;
513
+ }
514
+
515
+ targetTop -= viewOffset;
516
+
517
+ this.$refs.scrollView?.bs.scrollTo(0, -targetTop, animated ? 200 : 0);
518
+ },
519
+ },
520
+ components: {
521
+ ScrollView,
522
+ StickyHeader,
523
+ },
524
+ };
525
+ </script>
526
+
527
+ <style scoped>
528
+ .mpx-section-list {
529
+ position: relative;
530
+ overflow: hidden;
531
+ height: 100%;
532
+ }
533
+
534
+ .content-wrapper {
535
+ position: relative;
536
+ width: 100%;
537
+ }
538
+
539
+ .infinite-list {
540
+ left: 0;
541
+ right: 0;
542
+ top: 0;
543
+ position: absolute;
544
+ will-change: transform;
545
+ -webkit-backface-visibility: hidden;
546
+ backface-visibility: hidden;
547
+ }
548
+ .sticky-section {
549
+ position: absolute !important;
550
+ }
551
+ </style>
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <view class="mpx-list-footer-default">
3
+ <view class="mpx-default-content">list-footer-default</view>
4
+ </view>
5
+ </template>
6
+
7
+ <script>
8
+ import { createComponent } from '@mpxjs/core'
9
+ createComponent({})
10
+ </script>
11
+
12
+ <style lang="stylus" scoped>
13
+ .mpx-list-footer-default
14
+ margin 4px 16px
15
+ padding 16px
16
+ background #fff
17
+ border-radius 8px
18
+ box-shadow 0 2px 4px rgba(0,0,0,0.1)
19
+
20
+ .mpx-default-content
21
+ display flex
22
+ flex-direction column
23
+ font-size 14px
24
+ color #666
25
+
26
+ </style>
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <view class="mpx-list-header-default">
3
+ <view class="mpx-default-content">list-header-default</view>
4
+ </view>
5
+ </template>
6
+
7
+ <script>
8
+ import { createComponent } from '@mpxjs/core'
9
+ createComponent({})
10
+ </script>
11
+
12
+ <style lang="stylus" scoped>
13
+ .mpx-list-header-default
14
+ margin 4px 16px
15
+ padding 16px
16
+ background #fff
17
+ border-radius 8px
18
+ box-shadow 0 2px 4px rgba(0,0,0,0.1)
19
+
20
+ .mpx-default-content
21
+ display flex
22
+ flex-direction column
23
+ font-size 14px
24
+ color #666
25
+
26
+ </style>
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <view class="mpx-recycle-item-default">
3
+ <view class="mpx-default-content">recycle-item-default</view>
4
+ </view>
5
+ </template>
6
+
7
+ <script>
8
+ import { createComponent } from '@mpxjs/core'
9
+ createComponent({})
10
+ </script>
11
+
12
+ <style lang="stylus" scoped>
13
+ .mpx-recycle-item-default
14
+ margin 4px 16px
15
+ padding 16px
16
+ background #fff
17
+ border-radius 8px
18
+ box-shadow 0 2px 4px rgba(0,0,0,0.1)
19
+
20
+ .mpx-default-content
21
+ display flex
22
+ flex-direction column
23
+ font-size 14px
24
+ color #666
25
+
26
+ </style>
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <view class="mpx-section-header-default">
3
+ <view class="mpx-default-content">section-header-default</view>
4
+ </view>
5
+ </template>
6
+
7
+ <script>
8
+ import { createComponent } from '@mpxjs/core'
9
+ createComponent({})
10
+ </script>
11
+
12
+ <style lang="stylus" scoped>
13
+ .mpx-section-header-default
14
+ margin 4px 16px
15
+ padding 16px
16
+ background #fff
17
+ border-radius 8px
18
+ box-shadow 0 2px 4px rgba(0,0,0,0.1)
19
+
20
+ .mpx-default-content
21
+ display flex
22
+ flex-direction column
23
+ font-size 14px
24
+ color #666
25
+
26
+ </style>