@mpxjs/webpack-plugin 2.9.70-alpha.0 → 2.9.70-alpha.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 (122) hide show
  1. package/lib/config.js +3 -1
  2. package/lib/file-loader.js +5 -0
  3. package/lib/index.js +1 -1
  4. package/lib/loader.js +0 -1
  5. package/lib/parser.js +1 -1
  6. package/lib/platform/json/wx/index.js +21 -8
  7. package/lib/platform/style/wx/index.js +51 -54
  8. package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
  9. package/lib/platform/template/wx/component-config/index.js +1 -1
  10. package/lib/platform/template/wx/component-config/movable-view.js +8 -1
  11. package/lib/platform/template/wx/component-config/picker-view.js +1 -5
  12. package/lib/platform/template/wx/component-config/rich-text.js +8 -0
  13. package/lib/platform/template/wx/component-config/scroll-view.js +1 -1
  14. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  15. package/lib/platform/template/wx/index.js +3 -5
  16. package/lib/react/processScript.js +6 -3
  17. package/lib/react/script-helper.js +5 -1
  18. package/lib/runtime/components/react/context.ts +8 -0
  19. package/lib/runtime/components/react/dist/context.js +2 -0
  20. package/lib/runtime/components/react/dist/getInnerListeners.js +39 -37
  21. package/lib/runtime/components/react/dist/mpx-button.jsx +16 -44
  22. package/lib/runtime/components/react/dist/mpx-canvas/html.js +2 -4
  23. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +5 -1
  24. package/lib/runtime/components/react/dist/mpx-icon/icons/cancel.png +0 -0
  25. package/lib/runtime/components/react/dist/mpx-icon/icons/clear.png +0 -0
  26. package/lib/runtime/components/react/dist/mpx-icon/icons/download.png +0 -0
  27. package/lib/runtime/components/react/dist/mpx-icon/icons/info.png +0 -0
  28. package/lib/runtime/components/react/dist/mpx-icon/icons/search.png +0 -0
  29. package/lib/runtime/components/react/dist/mpx-icon/icons/success.png +0 -0
  30. package/lib/runtime/components/react/dist/mpx-icon/icons/success_no_circle.png +0 -0
  31. package/lib/runtime/components/react/dist/mpx-icon/icons/waiting.png +0 -0
  32. package/lib/runtime/components/react/dist/mpx-icon/icons/warn.png +0 -0
  33. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +50 -0
  34. package/lib/runtime/components/react/dist/mpx-image.jsx +19 -18
  35. package/lib/runtime/components/react/dist/mpx-input.jsx +11 -9
  36. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +93 -58
  37. package/lib/runtime/components/react/dist/mpx-navigator.jsx +1 -1
  38. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +10 -14
  39. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +94 -81
  40. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +19 -16
  41. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +10 -11
  42. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +20 -9
  43. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +31 -8
  44. package/lib/runtime/components/react/dist/mpx-swiper.jsx +435 -371
  45. package/lib/runtime/components/react/dist/mpx-view.jsx +18 -53
  46. package/lib/runtime/components/react/dist/pickerFaces.js +3 -8
  47. package/lib/runtime/components/react/dist/pickerVIewContext.js +5 -0
  48. package/lib/runtime/components/react/dist/{pickerViewOverlay.jsx → pickerViewIndicator.jsx} +6 -6
  49. package/lib/runtime/components/react/dist/pickerViewMask.jsx +2 -2
  50. package/lib/runtime/components/react/dist/useAnimationHooks.js +27 -10
  51. package/lib/runtime/components/react/dist/utils.jsx +162 -70
  52. package/lib/runtime/components/react/event.config.ts +25 -26
  53. package/lib/runtime/components/react/getInnerListeners.ts +236 -182
  54. package/lib/runtime/components/react/mpx-button.tsx +27 -69
  55. package/lib/runtime/components/react/mpx-canvas/html.ts +2 -4
  56. package/lib/runtime/components/react/mpx-canvas/index.tsx +44 -46
  57. package/lib/runtime/components/react/mpx-checkbox-group.tsx +15 -13
  58. package/lib/runtime/components/react/mpx-checkbox.tsx +20 -21
  59. package/lib/runtime/components/react/mpx-form.tsx +15 -20
  60. package/lib/runtime/components/react/mpx-icon/icons/cancel.png +0 -0
  61. package/lib/runtime/components/react/mpx-icon/icons/clear.png +0 -0
  62. package/lib/runtime/components/react/mpx-icon/icons/download.png +0 -0
  63. package/lib/runtime/components/react/mpx-icon/icons/info.png +0 -0
  64. package/lib/runtime/components/react/mpx-icon/icons/search.png +0 -0
  65. package/lib/runtime/components/react/mpx-icon/icons/success.png +0 -0
  66. package/lib/runtime/components/react/mpx-icon/icons/success_no_circle.png +0 -0
  67. package/lib/runtime/components/react/mpx-icon/icons/waiting.png +0 -0
  68. package/lib/runtime/components/react/mpx-icon/icons/warn.png +0 -0
  69. package/lib/runtime/components/react/mpx-icon/index.tsx +111 -0
  70. package/lib/runtime/components/react/mpx-image.tsx +99 -47
  71. package/lib/runtime/components/react/mpx-input.tsx +33 -39
  72. package/lib/runtime/components/react/mpx-label.tsx +12 -14
  73. package/lib/runtime/components/react/mpx-movable-area.tsx +10 -16
  74. package/lib/runtime/components/react/mpx-movable-view.tsx +133 -92
  75. package/lib/runtime/components/react/mpx-navigator.tsx +3 -9
  76. package/lib/runtime/components/react/mpx-picker-view-column-item.tsx +76 -0
  77. package/lib/runtime/components/react/mpx-picker-view-column.tsx +206 -183
  78. package/lib/runtime/components/react/mpx-picker-view.tsx +49 -48
  79. package/lib/runtime/components/react/mpx-radio-group.tsx +13 -15
  80. package/lib/runtime/components/react/mpx-radio.tsx +19 -25
  81. package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
  82. package/lib/runtime/components/react/mpx-rich-text/index.tsx +115 -0
  83. package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
  84. package/lib/runtime/components/react/mpx-scroll-view.tsx +62 -49
  85. package/lib/runtime/components/react/mpx-swiper-item.tsx +45 -11
  86. package/lib/runtime/components/react/mpx-swiper.tsx +742 -0
  87. package/lib/runtime/components/react/mpx-switch.tsx +19 -15
  88. package/lib/runtime/components/react/mpx-text.tsx +8 -16
  89. package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
  90. package/lib/runtime/components/react/mpx-view.tsx +28 -77
  91. package/lib/runtime/components/react/mpx-web-view.tsx +94 -59
  92. package/lib/runtime/components/react/pickerFaces.ts +10 -7
  93. package/lib/runtime/components/react/pickerVIewContext.ts +27 -0
  94. package/lib/runtime/components/react/pickerViewIndicator.tsx +34 -0
  95. package/lib/runtime/components/react/pickerViewMask.tsx +30 -0
  96. package/lib/runtime/components/react/types/{getInnerListeners.ts → getInnerListeners.d.ts} +4 -5
  97. package/lib/runtime/components/react/types/global.d.ts +14 -1
  98. package/lib/runtime/components/react/useAnimationHooks.ts +60 -15
  99. package/lib/runtime/components/react/utils.tsx +175 -71
  100. package/lib/runtime/components/web/mpx-checkbox.vue +1 -1
  101. package/lib/runtime/components/web/mpx-picker-view-column.vue +9 -4
  102. package/lib/runtime/components/web/mpx-web-view.vue +34 -20
  103. package/lib/runtime/optionProcessor.js +0 -22
  104. package/lib/runtime/optionProcessor.tenon.js +3 -3
  105. package/lib/style-compiler/plugins/scope-id.js +30 -2
  106. package/lib/template-compiler/compiler.js +96 -29
  107. package/lib/tenon/index.js +2 -7
  108. package/lib/tenon/processScript.js +0 -5
  109. package/lib/tenon/processTemplate.js +1 -2
  110. package/lib/utils/pre-process-json.js +9 -5
  111. package/lib/wxss/loader.js +15 -2
  112. package/package.json +4 -3
  113. package/lib/runtime/components/react/dist/mpx-icon.jsx +0 -41
  114. package/lib/runtime/components/react/dist/types/common.js +0 -1
  115. package/lib/runtime/components/react/dist/types/getInnerListeners.js +0 -1
  116. package/lib/runtime/components/react/mpx-icon.tsx +0 -102
  117. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +0 -527
  118. package/lib/runtime/components/react/mpx-swiper/index.tsx +0 -80
  119. package/lib/runtime/components/react/mpx-swiper/type.ts +0 -87
  120. package/lib/runtime/components/react/pickerOverlay.tsx +0 -32
  121. package/lib/runtime/components/web/event.js +0 -105
  122. /package/lib/runtime/components/react/types/{common.ts → common.d.ts} +0 -0
@@ -2,10 +2,10 @@
2
2
  * ✔ nodes
3
3
  */
4
4
  import { View } from 'react-native';
5
- import { useRef, forwardRef, useState } from 'react';
5
+ import { useRef, forwardRef, useState, createElement } from 'react';
6
6
  import useInnerProps from '../getInnerListeners';
7
7
  import useNodesRef from '../useNodesRef'; // 引入辅助函数
8
- import { useTransformStyle, useLayout } from '../utils';
8
+ import { useTransformStyle, useLayout, extendObject } from '../utils';
9
9
  import { WebView } from 'react-native-webview';
10
10
  import { generateHTML } from './html';
11
11
  function jsonToHtmlStr(elements) {
@@ -44,20 +44,19 @@ const _RichText = forwardRef((props, ref) => {
44
44
  useNodesRef(props, ref, nodeRef, {
45
45
  layoutRef
46
46
  });
47
- const innerProps = useInnerProps(props, {
47
+ const innerProps = useInnerProps(props, extendObject({
48
48
  ref: nodeRef,
49
- style: { ...normalStyle, ...layoutStyle },
50
- ...layoutProps
51
- }, [], {
49
+ style: extendObject(normalStyle, layoutStyle)
50
+ }, layoutProps), [], {
52
51
  layoutRef
53
52
  });
54
53
  const html = typeof nodes === 'string' ? nodes : jsonToHtmlStr(nodes);
55
- return (<View {...innerProps}>
56
- <WebView source={{ html: generateHTML(html) }} onMessage={(event) => {
54
+ return createElement(View, innerProps, createElement(WebView, {
55
+ source: { html: generateHTML(html) },
56
+ onMessage: (event) => {
57
57
  setWebViewHeight(+event.nativeEvent.data);
58
- }}>
59
- </WebView>
60
- </View>);
58
+ }
59
+ }));
61
60
  });
62
61
  _RichText.displayName = 'mpx-rich-text';
63
62
  export default _RichText;
@@ -33,13 +33,13 @@
33
33
  */
34
34
  import { ScrollView } from 'react-native-gesture-handler';
35
35
  import { RefreshControl } from 'react-native';
36
- import { useRef, useState, useEffect, forwardRef, useContext, createElement } from 'react';
36
+ import { useRef, useState, useEffect, forwardRef, useContext, createElement, useMemo } from 'react';
37
37
  import { useAnimatedRef } from 'react-native-reanimated';
38
38
  import { warn } from '@mpxjs/utils';
39
39
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
40
40
  import useNodesRef from './useNodesRef';
41
41
  import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, extendObject, flatGesture } from './utils';
42
- import { IntersectionObserverContext } from './context';
42
+ import { IntersectionObserverContext, ScrollViewContext } from './context';
43
43
  const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
44
44
  const { textProps, innerProps: props = {} } = splitProps(scrollViewProps);
45
45
  const { enhanced = false, bounces = true, style = {}, binddragstart, binddragging, binddragend, bindtouchstart, bindtouchmove, bindtouchend, 'scroll-x': scrollX = false, 'scroll-y': scrollY = false, 'enable-back-to-top': enableBackToTop = false, 'enable-trigger-intersection-observer': enableTriggerIntersectionObserver = false, 'paging-enabled': pagingEnabled = false, 'upper-threshold': upperThreshold = 50, 'lower-threshold': lowerThreshold = 50, 'scroll-with-animation': scrollWithAnimation, 'refresher-enabled': refresherEnabled, 'refresher-default-style': refresherDefaultStyle, 'refresher-background': refresherBackground, 'show-scrollbar': showScrollbar = true, 'scroll-into-view': scrollIntoView = '', 'scroll-top': scrollTop = 0, 'scroll-left': scrollLeft = 0, 'refresher-triggered': refresherTriggered, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'simultaneous-handlers': originSimultaneousHandlers, 'wait-for': waitFor, __selectRef } = props;
@@ -78,6 +78,11 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
78
78
  },
79
79
  gestureRef: scrollViewRef
80
80
  });
81
+ const contextValue = useMemo(() => {
82
+ return {
83
+ gestureRef: scrollViewRef
84
+ };
85
+ }, []);
81
86
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: scrollViewRef, onLayout });
82
87
  if (scrollX && scrollY) {
83
88
  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');
@@ -196,11 +201,8 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
196
201
  layoutRef
197
202
  }, props));
198
203
  updateScrollOptions(e, { scrollLeft, scrollTop });
199
- if (enableTriggerIntersectionObserver && intersectionObservers) {
200
- for (const key in intersectionObservers) {
201
- intersectionObservers[key].throttleMeasure();
202
- }
203
- }
204
+ onStartReached(e);
205
+ onEndReached(e);
204
206
  }
205
207
  function onScrollEnd(e) {
206
208
  const { bindscrollend } = props;
@@ -219,6 +221,14 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
219
221
  updateScrollOptions(e, { scrollLeft, scrollTop });
220
222
  onStartReached(e);
221
223
  onEndReached(e);
224
+ updateIntersection();
225
+ }
226
+ function updateIntersection() {
227
+ if (enableTriggerIntersectionObserver && intersectionObservers) {
228
+ for (const key in intersectionObservers) {
229
+ intersectionObservers[key].throttleMeasure();
230
+ }
231
+ }
222
232
  }
223
233
  function scrollToOffset(x = 0, y = 0) {
224
234
  if (scrollViewRef.current) {
@@ -277,6 +287,7 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
277
287
  function onScrollDrag(e) {
278
288
  const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset;
279
289
  updateScrollOptions(e, { scrollLeft, scrollTop });
290
+ updateIntersection();
280
291
  }
281
292
  const scrollAdditionalProps = extendObject({
282
293
  style: extendObject({}, innerStyle, layoutStyle),
@@ -342,12 +353,12 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
342
353
  onRefresh: onRefresh
343
354
  }, (refresherDefaultStyle && refresherDefaultStyle !== 'none' ? { colors: refreshColor[refresherDefaultStyle] } : null)))
344
355
  : undefined
345
- }), wrapChildren(props, {
356
+ }), createElement(ScrollViewContext.Provider, { value: contextValue }, wrapChildren(props, {
346
357
  hasVarDec,
347
358
  varContext: varContextRef.current,
348
359
  textStyle,
349
360
  textProps
350
- }));
361
+ })));
351
362
  });
352
363
  _ScrollView.displayName = 'MpxScrollView';
353
364
  export default _ScrollView;
@@ -1,10 +1,16 @@
1
- import { View } from 'react-native';
2
- import { forwardRef, useRef } from 'react';
1
+ import Animated, { useAnimatedStyle, interpolate } from 'react-native-reanimated';
2
+ import { forwardRef, useRef, useContext } from 'react';
3
3
  import useInnerProps from './getInnerListeners';
4
4
  import useNodesRef from './useNodesRef'; // 引入辅助函数
5
5
  import { useTransformStyle, splitStyle, splitProps, wrapChildren, useLayout } from './utils';
6
+ import { SwiperContext } from './context';
6
7
  const _SwiperItem = forwardRef((props, ref) => {
7
- const { 'enable-var': enableVar, 'external-var-context': externalVarContext, style } = props;
8
+ const { 'enable-var': enableVar, 'external-var-context': externalVarContext, style, customStyle, itemIndex } = props;
9
+ const contextValue = useContext(SwiperContext);
10
+ const offset = contextValue.offset || 0;
11
+ const step = contextValue.step || 0;
12
+ const scale = contextValue.scale || false;
13
+ const dir = contextValue.dir || 'x';
8
14
  const { textProps } = splitProps(props);
9
15
  const nodeRef = useRef(null);
10
16
  const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext });
@@ -16,21 +22,38 @@ const _SwiperItem = forwardRef((props, ref) => {
16
22
  // 存储layout布局信息
17
23
  layoutRef, layoutProps, layoutStyle } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: nodeRef });
18
24
  const innerProps = useInnerProps(props, {
19
- style: { ...innerStyle, ...layoutStyle },
20
25
  ref: nodeRef,
21
26
  ...layoutProps
22
27
  }, [
23
28
  'children',
24
- 'enable-offset'
29
+ 'enable-offset',
30
+ 'style'
25
31
  ], { layoutRef });
26
- return (<View data-itemId={props['item-id']} {...innerProps}>
27
- {wrapChildren(props, {
32
+ const itemAnimatedStyle = useAnimatedStyle(() => {
33
+ if (!step.value)
34
+ return {};
35
+ const inputRange = [step.value, 0];
36
+ const outputRange = [0.7, 1];
37
+ // 实现元素的宽度跟随step从0到真实宽度,且不能触发重新渲染整个组件,通过AnimatedStyle的方式实现
38
+ const outerLayoutStyle = dir === 'x' ? { width: step.value, height: '100%' } : { width: '100%', height: step.value };
39
+ const transformStyle = [];
40
+ if (scale) {
41
+ transformStyle.push({
42
+ scale: interpolate(Math.abs(Math.abs(offset.value) - itemIndex * step.value), inputRange, outputRange)
43
+ });
44
+ }
45
+ return Object.assign(outerLayoutStyle, {
46
+ transform: transformStyle
47
+ });
48
+ });
49
+ return (<Animated.View {...innerProps} style={[innerStyle, layoutStyle, itemAnimatedStyle, customStyle]} data-itemId={props['item-id']}>
50
+ {wrapChildren(props, {
28
51
  hasVarDec,
29
52
  varContext: varContextRef.current,
30
53
  textStyle,
31
54
  textProps
32
55
  })}
33
- </View>);
56
+ </Animated.View>);
34
57
  });
35
58
  _SwiperItem.displayName = 'MpxSwiperItem';
36
59
  export default _SwiperItem;