@mpxjs/webpack-plugin 2.9.59 → 2.9.62

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 (106) hide show
  1. package/lib/platform/style/wx/index.js +314 -254
  2. package/lib/platform/template/wx/component-config/checkbox-group.js +8 -0
  3. package/lib/platform/template/wx/component-config/checkbox.js +8 -0
  4. package/lib/platform/template/wx/component-config/cover-image.js +15 -0
  5. package/lib/platform/template/wx/component-config/cover-view.js +9 -0
  6. package/lib/platform/template/wx/component-config/form.js +13 -1
  7. package/lib/platform/template/wx/component-config/icon.js +8 -0
  8. package/lib/platform/template/wx/component-config/index.js +5 -1
  9. package/lib/platform/template/wx/component-config/label.js +15 -0
  10. package/lib/platform/template/wx/component-config/movable-area.js +18 -1
  11. package/lib/platform/template/wx/component-config/movable-view.js +18 -1
  12. package/lib/platform/template/wx/component-config/navigator.js +8 -0
  13. package/lib/platform/template/wx/component-config/picker-view-column.js +8 -0
  14. package/lib/platform/template/wx/component-config/picker-view.js +18 -2
  15. package/lib/platform/template/wx/component-config/picker.js +14 -1
  16. package/lib/platform/template/wx/component-config/radio-group.js +8 -0
  17. package/lib/platform/template/wx/component-config/radio.js +8 -0
  18. package/lib/platform/template/wx/component-config/root-portal.js +15 -0
  19. package/lib/platform/template/wx/component-config/switch.js +8 -0
  20. package/lib/platform/template/wx/component-config/unsupported.js +1 -3
  21. package/lib/react/processScript.js +2 -0
  22. package/lib/runtime/components/react/context.ts +38 -0
  23. package/lib/runtime/components/react/dist/context.js +7 -0
  24. package/lib/runtime/components/react/dist/getInnerListeners.js +22 -11
  25. package/lib/runtime/components/react/dist/mpx-button.jsx +67 -45
  26. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +81 -0
  27. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +152 -0
  28. package/lib/runtime/components/react/dist/mpx-form.jsx +59 -0
  29. package/lib/runtime/components/react/dist/mpx-icon.jsx +51 -0
  30. package/lib/runtime/components/react/dist/mpx-image/index.jsx +17 -22
  31. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -1
  32. package/lib/runtime/components/react/dist/mpx-input.jsx +38 -16
  33. package/lib/runtime/components/react/dist/mpx-label.jsx +63 -0
  34. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +46 -0
  35. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +346 -0
  36. package/lib/runtime/components/react/dist/mpx-navigator.jsx +35 -0
  37. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +69 -0
  38. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +138 -0
  39. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +139 -0
  40. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +90 -0
  41. package/lib/runtime/components/react/dist/mpx-picker/regionData.js +6099 -0
  42. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +76 -0
  43. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +244 -0
  44. package/lib/runtime/components/react/dist/mpx-picker/type.js +1 -0
  45. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +15 -0
  46. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +68 -0
  47. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +79 -0
  48. package/lib/runtime/components/react/dist/mpx-radio.jsx +169 -0
  49. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +11 -0
  50. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +66 -50
  51. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +206 -147
  52. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +9 -7
  53. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +3 -3
  54. package/lib/runtime/components/react/dist/mpx-switch.jsx +76 -0
  55. package/lib/runtime/components/react/dist/mpx-text.jsx +7 -19
  56. package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -1
  57. package/lib/runtime/components/react/dist/mpx-view.jsx +326 -96
  58. package/lib/runtime/components/react/dist/mpx-web-view.jsx +9 -15
  59. package/lib/runtime/components/react/dist/types/common.js +1 -0
  60. package/lib/runtime/components/react/dist/useNodesRef.js +3 -8
  61. package/lib/runtime/components/react/dist/utils.js +82 -14
  62. package/lib/runtime/components/react/getInnerListeners.ts +25 -13
  63. package/lib/runtime/components/react/mpx-button.tsx +87 -67
  64. package/lib/runtime/components/react/mpx-checkbox-group.tsx +147 -0
  65. package/lib/runtime/components/react/mpx-checkbox.tsx +245 -0
  66. package/lib/runtime/components/react/mpx-form.tsx +89 -0
  67. package/lib/runtime/components/react/mpx-icon.tsx +103 -0
  68. package/lib/runtime/components/react/mpx-image/index.tsx +20 -32
  69. package/lib/runtime/components/react/mpx-image/svg.tsx +2 -2
  70. package/lib/runtime/components/react/mpx-input.tsx +54 -26
  71. package/lib/runtime/components/react/mpx-label.tsx +115 -0
  72. package/lib/runtime/components/react/mpx-movable-area.tsx +67 -0
  73. package/lib/runtime/components/react/mpx-movable-view.tsx +425 -0
  74. package/lib/runtime/components/react/mpx-navigator.tsx +67 -0
  75. package/lib/runtime/components/react/mpx-picker/date.tsx +83 -0
  76. package/lib/runtime/components/react/mpx-picker/index.tsx +155 -0
  77. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +153 -0
  78. package/lib/runtime/components/react/mpx-picker/region.tsx +104 -0
  79. package/lib/runtime/components/react/mpx-picker/regionData.ts +6101 -0
  80. package/lib/runtime/components/react/mpx-picker/selector.tsx +92 -0
  81. package/lib/runtime/components/react/mpx-picker/time.tsx +274 -0
  82. package/lib/runtime/components/react/mpx-picker/type.ts +107 -0
  83. package/lib/runtime/components/react/mpx-picker-view-column.tsx +28 -0
  84. package/lib/runtime/components/react/mpx-picker-view.tsx +104 -0
  85. package/lib/runtime/components/react/mpx-radio-group.tsx +147 -0
  86. package/lib/runtime/components/react/mpx-radio.tsx +246 -0
  87. package/lib/runtime/components/react/mpx-root-portal.tsx +25 -0
  88. package/lib/runtime/components/react/mpx-scroll-view.tsx +82 -58
  89. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +203 -156
  90. package/lib/runtime/components/react/mpx-swiper/index.tsx +12 -13
  91. package/lib/runtime/components/react/mpx-swiper/type.ts +11 -4
  92. package/lib/runtime/components/react/mpx-swiper-item.tsx +5 -3
  93. package/lib/runtime/components/react/mpx-switch.tsx +127 -0
  94. package/lib/runtime/components/react/mpx-text.tsx +52 -68
  95. package/lib/runtime/components/react/mpx-textarea.tsx +2 -2
  96. package/lib/runtime/components/react/mpx-view.tsx +373 -140
  97. package/lib/runtime/components/react/mpx-web-view.tsx +24 -28
  98. package/lib/runtime/components/react/types/common.ts +12 -0
  99. package/lib/runtime/components/react/types/getInnerListeners.ts +2 -1
  100. package/lib/runtime/components/react/types/global.d.ts +4 -0
  101. package/lib/runtime/components/react/useNodesRef.ts +3 -8
  102. package/lib/runtime/components/react/utils.ts +93 -15
  103. package/lib/runtime/optionProcessor.js +19 -17
  104. package/lib/template-compiler/compiler.js +56 -41
  105. package/lib/template-compiler/gen-node-react.js +7 -7
  106. package/package.json +6 -3
@@ -31,16 +31,17 @@
31
31
  * ✔ bindscrolltolower
32
32
  * ✔ bindscroll
33
33
  */
34
- import { ScrollView, RefreshControl } from 'react-native';
35
- import React, { useRef, useState, useEffect, forwardRef } from 'react';
34
+ import { ScrollView } from 'react-native-gesture-handler';
35
+ import { RefreshControl } from 'react-native';
36
+ import { useRef, useState, useEffect, forwardRef } from 'react';
36
37
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
37
38
  import useNodesRef from './useNodesRef';
39
+ import { throwReactWarning } from './utils';
38
40
  const _ScrollView = forwardRef((props = {}, ref) => {
39
41
  const { children, enhanced = false, bounces = true, 'scroll-x': scrollX = false, 'scroll-y': scrollY = false, 'enable-back-to-top': enableBackToTop = false, 'paging-enabled': pagingEnabled = false, 'upper-threshold': upperThreshold = 50, 'lower-threshold': lowerThreshold = 50, 'scroll-with-animation': scrollWithAnimation, 'refresher-enabled': refresherEnabled, 'refresher-default-style': refresherDefaultStyle, 'refresher-background': refresherBackground, 'enable-offset': enableOffset, 'show-scrollbar': showScrollbar = true } = props;
40
- const [snapScrollTop, setSnapScrollTop] = useState(0);
41
- const [snapScrollLeft, setSnapScrollLeft] = useState(0);
42
42
  const [refreshing, setRefreshing] = useState(true);
43
- const [scrollEnabled, setScrollEnabled] = useState(true);
43
+ const snapScrollTop = useRef(0);
44
+ const snapScrollLeft = useRef(0);
44
45
  const layoutRef = useRef({});
45
46
  const scrollOptions = useRef({
46
47
  contentLength: 0,
@@ -56,7 +57,7 @@ const _ScrollView = forwardRef((props = {}, ref) => {
56
57
  const { nodeRef: scrollViewRef } = useNodesRef(props, ref, {
57
58
  scrollOffset: scrollOptions,
58
59
  node: {
59
- scrollEnabled,
60
+ scrollEnabled: scrollX || scrollY,
60
61
  bounces,
61
62
  showScrollbar,
62
63
  pagingEnabled,
@@ -65,11 +66,20 @@ const _ScrollView = forwardRef((props = {}, ref) => {
65
66
  scrollTo: scrollToOffset
66
67
  }
67
68
  });
69
+ if (scrollX && scrollY) {
70
+ throwReactWarning('[Mpx runtime warn]: scroll-x and scroll-y cannot be set to true at the same time, Mpx will use the value of scroll-y as the criterion');
71
+ }
68
72
  useEffect(() => {
69
- if (snapScrollTop !== props['scroll-top'] ||
70
- snapScrollLeft !== props['scroll-left']) {
71
- setSnapScrollTop(props['scroll-top'] || 0);
72
- setSnapScrollLeft(props['scroll-left'] || 0);
73
+ if (snapScrollTop.current !== props['scroll-top'] ||
74
+ snapScrollLeft.current !== props['scroll-left']) {
75
+ snapScrollTop.current = props['scroll-top'] || 0;
76
+ snapScrollLeft.current = props['scroll-left'] || 0;
77
+ initialTimeout.current = setTimeout(() => {
78
+ scrollToOffset(snapScrollLeft.current, snapScrollTop.current);
79
+ }, 0);
80
+ return () => {
81
+ initialTimeout.current && clearTimeout(initialTimeout.current);
82
+ };
73
83
  }
74
84
  }, [props['scroll-top'], props['scroll-left']]);
75
85
  useEffect(() => {
@@ -77,24 +87,6 @@ const _ScrollView = forwardRef((props = {}, ref) => {
77
87
  setRefreshing(!!props['refresher-triggered']);
78
88
  }
79
89
  }, [props['refresher-triggered']]);
80
- useEffect(() => {
81
- if (!props['scroll-x'] && !props['scroll-y']) {
82
- setScrollEnabled(false);
83
- }
84
- else {
85
- setScrollEnabled(true);
86
- }
87
- }, [props['scroll-x'], props['scroll-y']]);
88
- useEffect(() => {
89
- if (snapScrollTop || snapScrollLeft) {
90
- initialTimeout.current = setTimeout(() => {
91
- scrollToOffset(snapScrollLeft, snapScrollTop);
92
- }, 0);
93
- }
94
- return () => {
95
- initialTimeout.current && clearTimeout(initialTimeout.current);
96
- };
97
- }, [snapScrollTop, snapScrollLeft]);
98
90
  function selectLength(size) {
99
91
  return !scrollX ? size.height : size.width;
100
92
  }
@@ -149,6 +141,19 @@ const _ScrollView = forwardRef((props = {}, ref) => {
149
141
  });
150
142
  }
151
143
  }
144
+ function updateScrollOptions(e, position) {
145
+ const visibleLength = selectLength(e.nativeEvent.layoutMeasurement);
146
+ const contentLength = selectLength(e.nativeEvent.contentSize);
147
+ const offset = selectOffset(e.nativeEvent.contentOffset);
148
+ scrollOptions.current = {
149
+ ...scrollOptions.current,
150
+ contentLength,
151
+ offset,
152
+ scrollLeft: position.scrollLeft,
153
+ scrollTop: position.scrollTop,
154
+ visibleLength,
155
+ };
156
+ }
152
157
  function onScroll(e) {
153
158
  const { bindscroll } = props;
154
159
  const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset;
@@ -165,17 +170,23 @@ const _ScrollView = forwardRef((props = {}, ref) => {
165
170
  },
166
171
  layoutRef
167
172
  }, props));
168
- const visibleLength = selectLength(e.nativeEvent.layoutMeasurement);
169
- const contentLength = selectLength(e.nativeEvent.contentSize);
170
- const offset = selectOffset(e.nativeEvent.contentOffset);
171
- scrollOptions.current = {
172
- ...scrollOptions.current,
173
- contentLength,
174
- offset,
175
- scrollLeft,
176
- scrollTop,
177
- visibleLength,
178
- };
173
+ updateScrollOptions(e, { scrollLeft, scrollTop });
174
+ }
175
+ function onScrollEnd(e) {
176
+ const { bindscrollend } = props;
177
+ const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset;
178
+ const { width: scrollWidth, height: scrollHeight } = e.nativeEvent.contentSize;
179
+ bindscrollend &&
180
+ bindscrollend(getCustomEvent('scrollend', e, {
181
+ detail: {
182
+ scrollLeft,
183
+ scrollTop,
184
+ scrollHeight,
185
+ scrollWidth
186
+ },
187
+ layoutRef
188
+ }, props));
189
+ updateScrollOptions(e, { scrollLeft, scrollTop });
179
190
  onStartReached(e);
180
191
  onEndReached(e);
181
192
  }
@@ -198,8 +209,8 @@ const _ScrollView = forwardRef((props = {}, ref) => {
198
209
  binddragstart &&
199
210
  binddragstart(getCustomEvent('dragstart', e, {
200
211
  detail: {
201
- scrollLeft: scrollOptions.current.scrollLeft || 0,
202
- scrollTop: scrollOptions.current.scrollTop || 0,
212
+ scrollLeft: scrollOptions.current.scrollLeft,
213
+ scrollTop: scrollOptions.current.scrollTop,
203
214
  },
204
215
  layoutRef
205
216
  }, props));
@@ -219,35 +230,40 @@ const _ScrollView = forwardRef((props = {}, ref) => {
219
230
  }, props));
220
231
  }
221
232
  }
222
- function onScrollTouchEnd(e) {
223
- const { binddragend, bindtouchend, enhanced } = props;
224
- bindtouchend && bindtouchend(e);
233
+ function onScrollEndDrag(e) {
234
+ const { binddragend, enhanced } = props;
225
235
  if (enhanced) {
236
+ const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset;
237
+ const { width: scrollWidth, height: scrollHeight } = e.nativeEvent.contentSize;
226
238
  binddragend &&
227
239
  binddragend(getCustomEvent('dragend', e, {
228
240
  detail: {
229
- scrollLeft: scrollOptions.current.scrollLeft || 0,
230
- scrollTop: scrollOptions.current.scrollTop || 0,
241
+ scrollLeft: scrollLeft,
242
+ scrollTop: scrollTop,
243
+ scrollHeight,
244
+ scrollWidth
231
245
  },
232
246
  layoutRef
233
247
  }, props));
248
+ updateScrollOptions(e, { scrollLeft, scrollTop });
234
249
  }
235
250
  }
236
251
  let scrollAdditionalProps = {
237
252
  pinchGestureEnabled: false,
238
- horizontal: scrollX || !scrollY,
253
+ horizontal: scrollX && !scrollY,
239
254
  scrollEventThrottle: scrollEventThrottle,
240
255
  scrollsToTop: enableBackToTop,
241
256
  showsHorizontalScrollIndicator: scrollX && showScrollbar,
242
257
  showsVerticalScrollIndicator: scrollY && showScrollbar,
243
- scrollEnabled: scrollEnabled,
258
+ scrollEnabled: scrollX || scrollY,
244
259
  ref: scrollViewRef,
245
260
  onScroll: onScroll,
246
261
  onContentSizeChange: onContentSizeChange,
247
262
  bindtouchstart: onScrollTouchStart,
248
- bindtouchend: onScrollTouchEnd,
249
263
  bindtouchmove: onScrollTouchMove,
250
- onLayout
264
+ onLayout,
265
+ onScrollEndDrag,
266
+ onMomentumScrollEnd: onScrollEnd
251
267
  };
252
268
  if (enhanced) {
253
269
  scrollAdditionalProps = {