@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
@@ -16,4 +16,3 @@ interface SwiperItemProps {
16
16
  }
17
17
  declare const _SwiperItem: import("react").ForwardRefExoticComponent<SwiperItemProps & import("react").RefAttributes<HandlerRef<View, SwiperItemProps>>>;
18
18
  export default _SwiperItem;
19
- //# sourceMappingURL=mpx-swiper-item.d.ts.map
@@ -5,6 +5,11 @@ import { GestureHandler } from './utils';
5
5
  /**
6
6
  * ✔ indicator-dots
7
7
  * ✔ indicator-color
8
+ * ✔ indicator-width
9
+ * ✔ indicator-height
10
+ * ✔ indicator-radius
11
+ * ✔ indicator-spacing
12
+ * ✔ indicator-margin
8
13
  * ✔ indicator-active-color
9
14
  * ✔ autoplay
10
15
  * ✔ current
@@ -29,6 +34,11 @@ interface SwiperProps {
29
34
  scale?: boolean;
30
35
  'indicator-dots'?: boolean;
31
36
  'indicator-color'?: string;
37
+ 'indicator-width'?: number;
38
+ 'indicator-height'?: number;
39
+ 'indicator-spacing'?: number;
40
+ 'indicator-radius'?: number;
41
+ 'indicator-margin'?: number;
32
42
  'indicator-active-color'?: string;
33
43
  vertical?: boolean;
34
44
  style: {
@@ -46,8 +56,8 @@ interface SwiperProps {
46
56
  'wait-for'?: Array<GestureHandler>;
47
57
  'simultaneous-handlers'?: Array<GestureHandler>;
48
58
  disableGesture?: boolean;
59
+ 'display-multiple-items'?: number;
49
60
  bindchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
50
61
  }
51
62
  declare const SwiperWrapper: React.ForwardRefExoticComponent<SwiperProps & React.RefAttributes<HandlerRef<View, SwiperProps>>>;
52
63
  export default SwiperWrapper;
53
- //# sourceMappingURL=mpx-swiper.d.ts.map
@@ -13,23 +13,23 @@ import Portal from './mpx-portal';
13
13
  const styles = {
14
14
  pagination_x: {
15
15
  position: 'absolute',
16
- bottom: 25,
16
+ bottom: 0,
17
17
  left: 0,
18
18
  right: 0,
19
19
  flexDirection: 'row',
20
20
  flex: 1,
21
21
  justifyContent: 'center',
22
- alignItems: 'center'
22
+ alignItems: 'flex-end'
23
23
  },
24
24
  pagination_y: {
25
25
  position: 'absolute',
26
- right: 15,
26
+ right: 0,
27
27
  top: 0,
28
28
  bottom: 0,
29
29
  flexDirection: 'column',
30
30
  flex: 1,
31
31
  justifyContent: 'center',
32
- alignItems: 'center'
32
+ alignItems: 'flex-end'
33
33
  },
34
34
  pagerWrapperx: {
35
35
  position: 'absolute',
@@ -49,16 +49,6 @@ const styles = {
49
49
  justifyContent: 'flex-start'
50
50
  }
51
51
  };
52
- const dotCommonStyle = {
53
- width: 8,
54
- height: 8,
55
- borderRadius: 4,
56
- marginLeft: 3,
57
- marginRight: 3,
58
- marginTop: 3,
59
- marginBottom: 3,
60
- zIndex: 98
61
- };
62
52
  const activeDotStyle = {
63
53
  zIndex: 99
64
54
  };
@@ -71,7 +61,18 @@ const easeMap = {
71
61
  easeInOutCubic: Easing.inOut(Easing.cubic)
72
62
  };
73
63
  const SwiperWrapper = forwardRef((props, ref) => {
74
- const { 'indicator-dots': showPagination, 'indicator-color': dotColor = 'rgba(0, 0, 0, .3)', 'indicator-active-color': activeDotColor = '#000000', 'enable-var': enableVar = false, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'external-var-context': externalVarContext, 'simultaneous-handlers': originSimultaneousHandlers = [], 'wait-for': waitFor = [], style = {}, autoplay = false, circular = false, disableGesture = false, current: propCurrent = 0, bindchange } = props;
64
+ const { 'indicator-dots': showPagination, 'indicator-color': dotColor = 'rgba(0, 0, 0, .3)', 'indicator-width': dotWidth = 8, 'indicator-height': dotHeight = 8, 'indicator-radius': dotRadius = 4, 'indicator-spacing': dotSpacing = 4, 'indicator-margin': paginationMargin = 10, 'indicator-active-color': activeDotColor = '#000000', 'enable-var': enableVar = false, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'external-var-context': externalVarContext, 'simultaneous-handlers': originSimultaneousHandlers = [], 'wait-for': waitFor = [], style = {}, autoplay = false, circular = false, disableGesture = false, current: propCurrent = 0, bindchange } = props;
65
+ const dotCommonStyle = {
66
+ width: dotWidth,
67
+ height: dotHeight,
68
+ borderRadius: dotRadius,
69
+ marginLeft: dotSpacing,
70
+ marginRight: dotSpacing,
71
+ marginTop: dotSpacing,
72
+ marginBottom: dotSpacing,
73
+ zIndex: 98
74
+ };
75
+ const displayMultipleItems = props['display-multiple-items'] || 1;
75
76
  const easeingFunc = props['easing-function'] || 'default';
76
77
  const easeDuration = props.duration || 500;
77
78
  const horizontal = props.vertical !== undefined ? !props.vertical : true;
@@ -97,18 +98,19 @@ const SwiperWrapper = forwardRef((props, ref) => {
97
98
  const preMarginShared = useSharedValue(preMargin);
98
99
  const nextMarginShared = useSharedValue(nextMargin);
99
100
  const autoplayShared = useSharedValue(autoplay);
101
+ const children = Array.isArray(props.children) ? props.children.filter(child => child) : (props.children ? [props.children] : []);
100
102
  // 默认前后补位的元素个数
101
- const patchElmNum = circular ? (preMargin ? 2 : 1) : 0;
103
+ const patchElmNum = (circular && children.length > 1) ? displayMultipleItems + 1 : 0;
102
104
  const patchElmNumShared = useSharedValue(patchElmNum);
105
+ const displayMultipleItemsShared = useSharedValue(displayMultipleItems);
103
106
  const circularShared = useSharedValue(circular);
104
- const children = Array.isArray(props.children) ? props.children.filter(child => child) : (props.children ? [props.children] : []);
105
107
  // 对有变化的变量,在worklet中只能使用sharedValue变量,useRef不能更新
106
108
  const childrenLength = useSharedValue(children.length);
107
109
  const initWidth = typeof normalStyle?.width === 'number' ? normalStyle.width - preMargin - nextMargin : normalStyle.width;
108
110
  const initHeight = typeof normalStyle?.height === 'number' ? normalStyle.height - preMargin - nextMargin : normalStyle.height;
109
111
  const dir = horizontal === false ? 'y' : 'x';
110
112
  const pstep = dir === 'x' ? initWidth : initHeight;
111
- const initStep = isNaN(pstep) ? 0 : pstep;
113
+ const initStep = isNaN(pstep) ? 0 : pstep / displayMultipleItems;
112
114
  // 每个元素的宽度 or 高度,有固定值直接初始化无则0
113
115
  const step = useSharedValue(initStep);
114
116
  // 记录选中元素的索引值
@@ -124,8 +126,12 @@ const SwiperWrapper = forwardRef((props, ref) => {
124
126
  const preAbsolutePos = useSharedValue(0);
125
127
  // 记录从onBegin 到 onTouchesUp 时移动的距离
126
128
  const moveTranstion = useSharedValue(0);
129
+ // 记录用户手滑动的方向
130
+ const moveDir = useSharedValue(0);
127
131
  const timerId = useRef(0);
128
132
  const intervalTimer = props.interval || 500;
133
+ // 记录是否首次,首次不能触发bindchange回调
134
+ const isFirstRef = useRef(true);
129
135
  const simultaneousHandlers = flatGesture(originSimultaneousHandlers);
130
136
  const waitForHandlers = flatGesture(waitFor);
131
137
  // 判断gesture手势是否需要协同处理、等待手势失败响应
@@ -152,6 +158,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
152
158
  'style',
153
159
  'indicator-dots',
154
160
  'indicator-color',
161
+ 'indicator-width',
155
162
  'indicator-active-color',
156
163
  'previous-margin',
157
164
  'vertical',
@@ -167,7 +174,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
167
174
  const { width, height } = e.nativeEvent.layout;
168
175
  const realWidth = dir === 'x' ? width - preMargin - nextMargin : width;
169
176
  const realHeight = dir === 'y' ? height - preMargin - nextMargin : height;
170
- const iStep = dir === 'x' ? realWidth : realHeight;
177
+ const iStep = (dir === 'x' ? realWidth : realHeight) / displayMultipleItems;
171
178
  if (iStep !== step.value) {
172
179
  step.value = iStep;
173
180
  updateCurrent(propCurrent, iStep);
@@ -193,7 +200,17 @@ const SwiperWrapper = forwardRef((props, ref) => {
193
200
  for (let i = 0; i < children.length; i++) {
194
201
  dots.push(<View style={[dotCommonStyle, { backgroundColor: unActionColor }]} key={i}></View>);
195
202
  }
196
- return (<View pointerEvents="none" style={styles['pagination_' + dir]}>
203
+ let paginationStyle = styles['pagination_' + dir];
204
+ if (paginationMargin) {
205
+ paginationStyle = {
206
+ ...paginationStyle,
207
+ marginBottom: paginationMargin,
208
+ marginLeft: paginationMargin,
209
+ marginRight: paginationMargin,
210
+ marginTop: paginationMargin
211
+ };
212
+ }
213
+ return (<View pointerEvents="none" style={paginationStyle} key="pagination">
197
214
  <View style={[styles['pagerWrapper' + dir]]}>
198
215
  <Animated.View style={[
199
216
  dotCommonStyle,
@@ -213,19 +230,35 @@ const SwiperWrapper = forwardRef((props, ref) => {
213
230
  function renderItems() {
214
231
  const intLen = children.length;
215
232
  let renderChild = children.slice();
233
+ // if (circular && intLen > 1) {
234
+ // // 最前面加最后一个元素
235
+ // const lastChild = React.cloneElement(children[intLen - 1] as ReactElement, { key: 'clone0' })
236
+ // // 最后面加第一个元素
237
+ // const firstChild = React.cloneElement(children[0] as ReactElement, { key: 'clone1' })
238
+ // if (preMargin) {
239
+ // const lastChild1 = React.cloneElement(children[intLen - 2] as ReactElement, { key: 'clone2' })
240
+ // const firstChild1 = React.cloneElement(children[1] as ReactElement, { key: 'clone3' })
241
+ // renderChild = [lastChild1, lastChild].concat(renderChild).concat([firstChild, firstChild1])
242
+ // } else {
243
+ // renderChild = [lastChild].concat(renderChild).concat([firstChild])
244
+ // }
245
+ // }
216
246
  if (circular && intLen > 1) {
217
- // 最前面加最后一个元素
218
- const lastChild = React.cloneElement(children[intLen - 1], { key: 'clone0' });
219
- // 最后面加第一个元素
220
- const firstChild = React.cloneElement(children[0], { key: 'clone1' });
221
- if (preMargin) {
222
- const lastChild1 = React.cloneElement(children[intLen - 2], { key: 'clone2' });
223
- const firstChild1 = React.cloneElement(children[1], { key: 'clone3' });
224
- renderChild = [lastChild1, lastChild].concat(renderChild).concat([firstChild, firstChild1]);
225
- }
226
- else {
227
- renderChild = [lastChild].concat(renderChild).concat([firstChild]);
228
- }
247
+ // 动态生成前置补位元素
248
+ const frontClones = [];
249
+ // 计算补位序列的起始索引。例如 len=3, patch=2 -> start=1 (即从B开始)
250
+ const startIndex = intLen - (patchElmNum % intLen);
251
+ for (let i = 0; i < patchElmNum; i++) {
252
+ const sourceIndex = (startIndex + i) % intLen;
253
+ frontClones.push(React.cloneElement(children[sourceIndex], { key: `clone_front_${i}` }));
254
+ }
255
+ // 动态生成后置补位元素
256
+ const backClones = [];
257
+ for (let i = 0; i < patchElmNum; i++) {
258
+ const sourceIndex = i % intLen;
259
+ backClones.push(React.cloneElement(children[sourceIndex], { key: `clone_back_${i}` }));
260
+ }
261
+ renderChild = [...frontClones, ...renderChild, ...backClones];
229
262
  }
230
263
  const arrChildren = renderChild.map((child, index) => {
231
264
  const extraStyle = {};
@@ -260,7 +293,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
260
293
  let nextIndex = currentIndex.value;
261
294
  if (!circularShared.value) {
262
295
  // 获取下一个位置的坐标, 循环到最后一个元素,直接停止, 取消定时器
263
- if (currentIndex.value === childrenLength.value - 1) {
296
+ if (currentIndex.value === childrenLength.value - displayMultipleItemsShared.value) {
264
297
  pauseLoop();
265
298
  return;
266
299
  }
@@ -325,11 +358,9 @@ const SwiperWrapper = forwardRef((props, ref) => {
325
358
  resumeLoop
326
359
  };
327
360
  }, []);
328
- function handleSwiperChange(current, pCurrent) {
329
- if (pCurrent !== currentIndex.value) {
330
- const eventData = getCustomEvent('change', {}, { detail: { current, source: 'touch' }, layoutRef: layoutRef });
331
- bindchange && bindchange(eventData);
332
- }
361
+ function handleSwiperChange(current) {
362
+ const eventData = getCustomEvent('change', {}, { detail: { current, source: 'touch' }, layoutRef: layoutRef });
363
+ bindchange && bindchange(eventData);
333
364
  }
334
365
  const runOnJSCallbackRef = useRef({
335
366
  loop,
@@ -379,9 +410,10 @@ const SwiperWrapper = forwardRef((props, ref) => {
379
410
  // 1. 用户在当前页切换选中项,动画;用户携带选中index打开到swiper页直接选中不走动画
380
411
  useAnimatedReaction(() => currentIndex.value, (newIndex, preIndex) => {
381
412
  // 这里必须传递函数名, 直接写()=> {}形式会报 访问了未sharedValue信息
382
- if (newIndex !== preIndex && bindchange) {
413
+ if (newIndex !== preIndex && bindchange && !isFirstRef.current) {
383
414
  runOnJS(runOnJSCallback)('handleSwiperChange', newIndex, propCurrent);
384
415
  }
416
+ isFirstRef.current = false;
385
417
  });
386
418
  useEffect(() => {
387
419
  let patchStep = 0;
@@ -427,13 +459,15 @@ const SwiperWrapper = forwardRef((props, ref) => {
427
459
  };
428
460
  }, [autoplay]);
429
461
  useEffect(() => {
430
- if (circular !== circularShared.value) {
462
+ if (circular !== circularShared.value || patchElmNum !== patchElmNumShared.value || displayMultipleItems !== displayMultipleItemsShared.value) {
431
463
  circularShared.value = circular;
432
- patchElmNumShared.value = circular ? (preMargin ? 2 : 1) : 0;
464
+ patchElmNumShared.value = patchElmNum;
465
+ displayMultipleItemsShared.value = displayMultipleItems;
433
466
  offset.value = getOffset(currentIndex.value, step.value);
434
467
  }
435
- }, [circular, preMargin]);
468
+ }, [circular, patchElmNum, displayMultipleItems]);
436
469
  const { gestureHandler } = useMemo(() => {
470
+ // 基于transdir + 当前offset计算索引
437
471
  function getTargetPosition(eventData) {
438
472
  'worklet';
439
473
  // 移动的距离
@@ -450,7 +484,8 @@ const SwiperWrapper = forwardRef((props, ref) => {
450
484
  const moveToIndex = transdir < 0 ? Math.ceil(computedIndex) : Math.floor(computedIndex);
451
485
  // 实际应该定位的索引值
452
486
  if (!circularShared.value) {
453
- selectedIndex = moveToIndex;
487
+ const maxIndex = Math.max(0, childrenLength.value - displayMultipleItemsShared.value);
488
+ selectedIndex = Math.min(Math.max(moveToIndex, 0), maxIndex);
454
489
  moveToTargetPos = selectedIndex * step.value;
455
490
  }
456
491
  else {
@@ -486,7 +521,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
486
521
  const gestureMovePos = offset.value + translation;
487
522
  if (!circularShared.value) {
488
523
  // 如果只判断区间,中间非滑动状态(handleResistanceMove)向左滑动,突然改为向右滑动,但是还在非滑动态,本应该可滑动判断为了不可滑动
489
- const posEnd = -step.value * (childrenLength.value - 1);
524
+ const posEnd = -step.value * (childrenLength.value - displayMultipleItemsShared.value);
490
525
  if (transdir < 0) {
491
526
  return gestureMovePos > posEnd;
492
527
  }
@@ -546,10 +581,8 @@ const SwiperWrapper = forwardRef((props, ref) => {
546
581
  }
547
582
  });
548
583
  }
549
- // 当前的offset和index多对应的offset进行对比,判断是否超过一半
550
- function computeHalf(eventData) {
584
+ function computeHalf() {
551
585
  'worklet';
552
- const { transdir } = eventData;
553
586
  const currentOffset = Math.abs(offset.value);
554
587
  let preOffset = (currentIndex.value + patchElmNumShared.value) * step.value;
555
588
  if (circularShared.value) {
@@ -558,35 +591,14 @@ const SwiperWrapper = forwardRef((props, ref) => {
558
591
  // 正常事件中拿到的translation值(正向滑动<0,倒着滑>0)
559
592
  const diffOffset = preOffset - currentOffset;
560
593
  const half = Math.abs(diffOffset) > step.value / 2;
561
- const isTriggerUpdateHalf = (transdir < 0 && currentOffset < preOffset) || (transdir > 0 && currentOffset > preOffset);
562
- return {
563
- diffOffset,
564
- half,
565
- isTriggerUpdateHalf
566
- };
567
- }
568
- function handleLongPress(eventData) {
569
- 'worklet';
570
- const { diffOffset, half, isTriggerUpdateHalf } = computeHalf(eventData);
571
- if (+diffOffset === 0) {
572
- runOnJS(runOnJSCallback)('resumeLoop');
573
- }
574
- else if (isTriggerUpdateHalf) {
575
- // 如果触发了onUpdate时的索引变更
576
- handleEnd(eventData);
577
- }
578
- else if (half) {
579
- handleEnd(eventData);
580
- }
581
- else {
582
- handleBack(eventData);
583
- }
594
+ return half;
584
595
  }
585
596
  function reachBoundary(eventData) {
586
597
  'worklet';
587
598
  // 1. 基于当前的offset和translation判断是否超过当前边界值
588
599
  const { translation } = eventData;
589
- const boundaryStart = -patchElmNumShared.value * step.value;
600
+ // 与终点的逻辑对齐,都是超过补位元素对应的起点offset
601
+ const boundaryStart = 0;
590
602
  const boundaryEnd = -(childrenLength.value + patchElmNumShared.value) * step.value;
591
603
  const moveToOffset = offset.value + translation;
592
604
  let isBoundary = false;
@@ -603,7 +615,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
603
615
  // 超过边界的距离
604
616
  const exceedLength = Math.abs(boundaryStart) - Math.abs(moveToOffset);
605
617
  // 计算对标正常元素所在的offset
606
- resetOffset = (patchElmNumShared.value + childrenLength.value - 1) * step.value + (step.value - exceedLength);
618
+ resetOffset = (patchElmNumShared.value + childrenLength.value - 1) * step.value - exceedLength;
607
619
  }
608
620
  return {
609
621
  isBoundary,
@@ -616,7 +628,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
616
628
  const { translation, transdir } = eventData;
617
629
  const moveToOffset = offset.value + translation;
618
630
  const maxOverDrag = Math.floor(step.value / 2);
619
- const maxOffset = translation < 0 ? -(childrenLength.value - 1) * step.value : 0;
631
+ const maxOffset = translation < 0 ? -(childrenLength.value - displayMultipleItemsShared.value) * step.value : 0;
620
632
  let resistance = 0.1;
621
633
  let overDrag = 0;
622
634
  let finalOffset = 0;
@@ -642,6 +654,14 @@ const SwiperWrapper = forwardRef((props, ref) => {
642
654
  }
643
655
  return finalOffset;
644
656
  }
657
+ // 设置手势移动的方向
658
+ function setMoveDir(curAbsoPos) {
659
+ 'worklet';
660
+ const distance = curAbsoPos - preAbsolutePos.value;
661
+ if (distance) {
662
+ moveDir.value = curAbsoPos - preAbsolutePos.value;
663
+ }
664
+ }
645
665
  const gesturePan = Gesture.Pan()
646
666
  .onBegin((e) => {
647
667
  'worklet';
@@ -663,9 +683,9 @@ const SwiperWrapper = forwardRef((props, ref) => {
663
683
  transdir: moveDistance
664
684
  };
665
685
  // 1. 支持滑动中超出一半更新索引的能力:只更新索引并不会影响onFinalize依据当前offset计算的索引
666
- const { half } = computeHalf(eventData);
667
- if (childrenLength.value > 1 && half) {
668
- const { selectedIndex } = getTargetPosition(eventData);
686
+ const offsetHalf = computeHalf();
687
+ if (childrenLength.value > 1 && offsetHalf) {
688
+ const { selectedIndex } = getTargetPosition({ transdir: moveDistance });
669
689
  currentIndex.value = selectedIndex;
670
690
  }
671
691
  // 2. 非循环: 处理用户一直拖拽到临界点的场景,如果放到onFinalize无法阻止offset.value更新为越界的值
@@ -677,6 +697,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
677
697
  const finalOffset = handleResistanceMove(eventData);
678
698
  offset.value = finalOffset;
679
699
  }
700
+ setMoveDir(e[strAbso]);
680
701
  preAbsolutePos.value = e[strAbso];
681
702
  return;
682
703
  }
@@ -684,6 +705,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
684
705
  if (circularShared.value && childrenLength.value === 1) {
685
706
  const finalOffset = handleResistanceMove(eventData);
686
707
  offset.value = finalOffset;
708
+ setMoveDir(e[strAbso]);
687
709
  preAbsolutePos.value = e[strAbso];
688
710
  return;
689
711
  }
@@ -695,6 +717,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
695
717
  else {
696
718
  offset.value = moveDistance + offset.value;
697
719
  }
720
+ setMoveDir(e[strAbso]);
698
721
  preAbsolutePos.value = e[strAbso];
699
722
  })
700
723
  .onFinalize((e) => {
@@ -703,10 +726,21 @@ const SwiperWrapper = forwardRef((props, ref) => {
703
726
  return;
704
727
  touchfinish.value = true;
705
728
  // 触发过onUpdate正常情况下e[strAbso] - preAbsolutePos.value=0; 未触发过onUpdate的情况下e[strAbso] - preAbsolutePos.value 不为0
729
+ // 正常状态下基于onUpdate时的moveDir判断方向、未触发onUpdate的则基于onBegin的moveTranstion判断方向
706
730
  const moveDistance = e[strAbso] - preAbsolutePos.value;
731
+ // 默认兜底方向: 以onBegin为起点,因一些原因未触发onUpdate但是触发了位移
732
+ const defaultDir = e[strAbso] - moveTranstion.value;
733
+ // 实时方向:方向基于onUpdate时的方向,滑动的速度超过阈值时基于实时的滑动方向计算
734
+ const realtimeData = {
735
+ transdir: moveDir.value || defaultDir
736
+ };
737
+ // 起始方向:基于用户起始手势
738
+ const originData = {
739
+ transdir: defaultDir
740
+ };
707
741
  const eventData = {
708
742
  translation: moveDistance,
709
- transdir: moveDistance !== 0 ? moveDistance : e[strAbso] - moveTranstion.value
743
+ transdir: realtimeData.transdir
710
744
  };
711
745
  // 1. 只有一个元素:循环 和 非循环状态,都走回弹效果
712
746
  if (childrenLength.value === 1) {
@@ -720,21 +754,39 @@ const SwiperWrapper = forwardRef((props, ref) => {
720
754
  // 非循环支持最后元素可滑动能力后,向左快速移动未超过最大可移动范围一半,因为offset为正值,向左滑动handleBack,默认向上取整
721
755
  // 但是在offset大于0时,取0。[-100, 0](back取0), [0, 100](back取1), 所以handleLongPress里的处理逻辑需要兼容支持,因此这里直接单独处理,不耦合下方公共的判断逻辑。
722
756
  if (!circularShared.value && !canMove(eventData)) {
723
- if (eventData.transdir < 0) {
724
- handleBack(eventData);
757
+ if (realtimeData.transdir < 0) {
758
+ handleBack(realtimeData);
725
759
  }
726
760
  else {
727
- handleEnd(eventData);
761
+ handleEnd(realtimeData);
728
762
  }
729
763
  return;
730
764
  }
731
765
  // 3. 非循环状态可移动态、循环状态, 正常逻辑处理
732
766
  const velocity = e[strVelocity];
733
- if (Math.abs(velocity) < longPressRatio) {
734
- handleLongPress(eventData);
767
+ // 用于判断是否超过一半,基于索引判断是否超过一半不可行(1.滑动过程中索引会变更导致计算反向, 2.边界场景会更新offset也会导致基于索引+offset判断实效)
768
+ const tmp = offset.value % step.value > step.value / 2;
769
+ // 小于0手向左滑动
770
+ const offsetHalf = originData.transdir < 0 ? tmp : !tmp;
771
+ if (offsetHalf) {
772
+ if (Math.abs(velocity) > longPressRatio) {
773
+ // 超过速度阈值,按照实时方向(快速来回滑动)
774
+ handleEnd(realtimeData);
775
+ }
776
+ else {
777
+ // 超过速度阈值,按照起始方向(慢速长按)
778
+ handleEnd(originData);
779
+ }
735
780
  }
736
781
  else {
737
- handleEnd(eventData);
782
+ if (Math.abs(velocity) > longPressRatio) {
783
+ // 超过速度阈值,按照实时方向(快速来回滑动)
784
+ handleEnd(realtimeData);
785
+ }
786
+ else {
787
+ // 超过速度阈值,按照起始方向(慢速长按)
788
+ handleBack(originData);
789
+ }
738
790
  }
739
791
  })
740
792
  .withRef(swiperGestureRef);
@@ -770,6 +822,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
770
822
  style: [normalStyle, layoutStyle, styles.swiper]
771
823
  }, layoutProps, innerProps);
772
824
  const animateComponent = createElement(Animated.View, {
825
+ key: 'swiperContainer',
773
826
  style: [{ flexDirection: dir === 'x' ? 'row' : 'column', width: '100%', height: '100%' }, animatedStyles]
774
827
  }, wrapChildren({
775
828
  children: arrPages
@@ -24,4 +24,3 @@ interface _SwitchProps extends SwitchProps {
24
24
  }
25
25
  declare const _Switch: import("react").ForwardRefExoticComponent<_SwitchProps & import("react").RefAttributes<HandlerRef<Switch, _SwitchProps>>>;
26
26
  export default _Switch;
27
- //# sourceMappingURL=mpx-switch.d.ts.map
@@ -20,4 +20,3 @@ interface _TextProps extends TextProps {
20
20
  }
21
21
  declare const _Text: import("react").ForwardRefExoticComponent<_TextProps & import("react").RefAttributes<HandlerRef<Text, _TextProps>>>;
22
22
  export default _Text;
23
- //# sourceMappingURL=mpx-text.d.ts.map
@@ -5,4 +5,3 @@ import { HandlerRef } from './useNodesRef';
5
5
  export type TextareProps = Omit<InputProps & PrivateInputProps, 'type' | 'password' | 'multiline' | 'confirm-hold'>;
6
6
  declare const Textarea: import("react").ForwardRefExoticComponent<TextareProps & import("react").RefAttributes<HandlerRef<TextInput, TextareProps>>>;
7
7
  export default Textarea;
8
- //# sourceMappingURL=mpx-textarea.d.ts.map
@@ -4,6 +4,7 @@
4
4
  * type, password, confirm-hold
5
5
  * Addition:
6
6
  * ✔ confirm-type
7
+ * ✘ confirm-hold
7
8
  * ✔ auto-height
8
9
  * ✘ fixed
9
10
  * ✘ show-confirm-bar
@@ -99,4 +99,3 @@ interface VideoProps {
99
99
  }
100
100
  declare const MpxVideo: import("react").ForwardRefExoticComponent<VideoProps & import("react").RefAttributes<HandlerRef<View, VideoProps>>>;
101
101
  export default MpxVideo;
102
- //# sourceMappingURL=mpx-video.d.ts.map
@@ -6,7 +6,8 @@
6
6
  */
7
7
  import { View, NativeSyntheticEvent, ViewProps } from 'react-native';
8
8
  import { ReactNode } from 'react';
9
- import type { AnimationProp } from './useAnimationHooks';
9
+ import { AnimationType } from './animationHooks/index';
10
+ import type { AnimationProp } from './animationHooks/utils';
10
11
  import { ExtendedViewStyle } from './types/common';
11
12
  import { HandlerRef } from './useNodesRef';
12
13
  export interface _ViewProps extends ViewProps {
@@ -23,7 +24,7 @@ export interface _ViewProps extends ViewProps {
23
24
  'parent-font-size'?: number;
24
25
  'parent-width'?: number;
25
26
  'parent-height'?: number;
26
- 'enable-animation'?: boolean;
27
+ 'enable-animation'?: boolean | AnimationType;
27
28
  bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
28
29
  bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
29
30
  bindtouchend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
@@ -32,4 +33,3 @@ export interface _ViewProps extends ViewProps {
32
33
  }
33
34
  declare const _View: import("react").ForwardRefExoticComponent<_ViewProps & import("react").RefAttributes<HandlerRef<View, _ViewProps>>>;
34
35
  export default _View;
35
- //# sourceMappingURL=mpx-view.d.ts.map
@@ -8,7 +8,7 @@ import { View, StyleSheet, Image } from 'react-native';
8
8
  import { useRef, useState, useEffect, forwardRef, createElement } from 'react';
9
9
  import useInnerProps from './getInnerListeners';
10
10
  import Animated from 'react-native-reanimated';
11
- import useAnimationHooks from './useAnimationHooks';
11
+ import useAnimationHooks from './animationHooks/index';
12
12
  import useNodesRef from './useNodesRef';
13
13
  import { parseUrl, PERCENT_REGEX, splitStyle, splitProps, useTransformStyle, wrapChildren, useLayout, renderImage, pickStyle, extendObject, useHover } from './utils';
14
14
  import { error, isFunction } from '@mpxjs/utils';
@@ -203,7 +203,7 @@ function backgroundSize(imageProps, preImageInfo, imageSize, layoutInfo) {
203
203
  else { // 数值类型 ImageStyle
204
204
  // 数值类型设置为 stretch
205
205
  imageProps.resizeMode = 'stretch';
206
- if (type === 'linear' && (!layoutWidth || !layoutHeight)) {
206
+ if (type === 'linear' && (!layoutWidth || !layoutHeight) && (isPercent(width) || isPercent(height))) {
207
207
  // ios 上 linear 组件只要重新触发渲染,在渲染过程中外层容器 width 或者 height 被设置为 0,通过设置 % 的方式会渲染不出来,即使后面再更新为正常宽高也渲染不出来
208
208
  // 所以 hack 手动先将 linear 宽高也设置为 0,后面再更新为正确的数值或 %。
209
209
  dimensions = {
@@ -274,6 +274,18 @@ function normalizeBackgroundPosition(parts) {
274
274
  let hOffset = 0;
275
275
  let vStart = 'top';
276
276
  let vOffset = 0;
277
+ if (!Array.isArray(parts)) {
278
+ // 模板 style 属性传入单个数值时不会和 class 一样转成数组,需要手动转换
279
+ parts = [parts];
280
+ }
281
+ // 模板 style 属性传入时, 需要额外转换处理单位 px/rpx/vh 以及 center 转化为 50%
282
+ parts = parts.map((part) => {
283
+ if (typeof part !== 'string')
284
+ return part;
285
+ if (part === 'center')
286
+ return '50%';
287
+ return global.__formatValue(part);
288
+ });
277
289
  if (parts.length === 4)
278
290
  return parts;
279
291
  // 归一化
@@ -415,14 +427,16 @@ function normalizeBackgroundSize(backgroundSize, type) {
415
427
  const sizeList = backgroundSize.slice();
416
428
  if (sizeList.length === 1)
417
429
  sizeList.push('auto');
418
- if (type === 'linear') {
430
+ return sizeList.map((val) => {
431
+ if (typeof val !== 'string')
432
+ return val;
419
433
  // 处理当使用渐变的时候,background-size出现cover, contain, auto,当作100%处理
420
- for (const i in sizeList) {
421
- const val = sizeList[i];
422
- sizeList[i] = /^cover|contain|auto$/.test(val) ? '100%' : val;
434
+ if (type === 'linear' && /^cover|contain|auto$/.test(val)) {
435
+ val = '100%';
423
436
  }
424
- }
425
- return sizeList;
437
+ // 模板 style 属性传入时, 需要额外转换处理单位 px/rpx/vh
438
+ return global.__formatValue(val);
439
+ });
426
440
  }
427
441
  function preParseImage(imageStyle) {
428
442
  const { backgroundImage = '', backgroundSize = ['auto'], backgroundPosition = [0, 0] } = normalizeStyle(imageStyle) || {};
@@ -20,4 +20,3 @@ interface WebViewProps {
20
20
  }
21
21
  declare const _WebView: import("react").ForwardRefExoticComponent<Omit<WebViewProps, "ref"> & import("react").RefAttributes<HandlerRef<WebView<{}>, WebViewProps>>>;
22
22
  export default _WebView;
23
- //# sourceMappingURL=mpx-web-view.d.ts.map
@@ -184,7 +184,7 @@ const _WebView = forwardRef((props, ref) => {
184
184
  }
185
185
  break;
186
186
  case 'postMessage':
187
- bindmessage && bindmessage(getCustomEvent('messsage', {}, {
187
+ bindmessage && bindmessage(getCustomEvent('message', {}, {
188
188
  detail: {
189
189
  data: params[0]?.data
190
190
  }
@@ -37,4 +37,3 @@ export declare class ReplaceSource {
37
37
  source(): string;
38
38
  }
39
39
  export {};
40
- //# sourceMappingURL=parser.d.ts.map
@@ -9,4 +9,3 @@ export type HandlerRef<T, P> = {
9
9
  };
10
10
  export default function useNodesRef<T, P>(props: P, ref: ForwardedRef<HandlerRef<T, P>>, nodeRef: RefObject<T>, instance?: Obj): void;
11
11
  export {};
12
- //# sourceMappingURL=useNodesRef.d.ts.map