@mpxjs/webpack-plugin 2.9.69 → 2.9.70-alpha.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 (144) hide show
  1. package/README.md +1 -1
  2. package/lib/config.js +14 -0
  3. package/lib/dependencies/AddEntryDependency.js +24 -0
  4. package/lib/dependencies/ResolveDependency.js +5 -0
  5. package/lib/index.js +38 -7
  6. package/lib/json-compiler/helper.js +3 -3
  7. package/lib/loader.js +52 -0
  8. package/lib/platform/template/wx/component-config/button.js +14 -2
  9. package/lib/platform/template/wx/component-config/image.js +4 -0
  10. package/lib/platform/template/wx/component-config/input.js +5 -1
  11. package/lib/platform/template/wx/component-config/rich-text.js +4 -0
  12. package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
  13. package/lib/platform/template/wx/component-config/swiper.js +1 -1
  14. package/lib/platform/template/wx/component-config/switch.js +4 -0
  15. package/lib/platform/template/wx/component-config/text.js +4 -0
  16. package/lib/platform/template/wx/component-config/textarea.js +6 -1
  17. package/lib/platform/template/wx/component-config/view.js +4 -0
  18. package/lib/platform/template/wx/index.js +127 -1
  19. package/lib/react/processTemplate.js +3 -0
  20. package/lib/resolve-loader.js +4 -1
  21. package/lib/runtime/components/react/context.ts +4 -0
  22. package/lib/runtime/components/react/dist/context.js +5 -0
  23. package/lib/runtime/components/react/dist/event.config.js +24 -24
  24. package/lib/runtime/components/react/dist/getInnerListeners.js +183 -166
  25. package/lib/runtime/components/react/dist/locale-provider.jsx +15 -0
  26. package/lib/runtime/components/react/dist/mpx-button.jsx +39 -74
  27. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +30 -12
  28. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
  29. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
  30. package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
  31. package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
  32. package/lib/runtime/components/react/dist/mpx-image.jsx +295 -0
  33. package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
  34. package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
  35. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
  36. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +14 -14
  37. package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
  38. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
  39. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
  40. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
  41. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
  42. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
  43. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -14
  44. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
  45. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +126 -112
  46. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +32 -29
  47. package/lib/runtime/components/react/dist/mpx-portal/portal-consumer.jsx +23 -0
  48. package/lib/runtime/components/react/dist/mpx-portal/portal-host.jsx +124 -0
  49. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +40 -0
  50. package/lib/runtime/components/react/dist/mpx-portal.jsx +12 -0
  51. package/lib/runtime/components/react/dist/mpx-provider.jsx +31 -0
  52. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
  53. package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
  54. package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
  55. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +62 -0
  56. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +7 -5
  57. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +62 -47
  58. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
  59. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +28 -9
  60. package/lib/runtime/components/react/dist/mpx-swiper.jsx +613 -0
  61. package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
  62. package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
  63. package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
  64. package/lib/runtime/components/react/dist/mpx-view.jsx +37 -89
  65. package/lib/runtime/components/react/dist/mpx-web-view.jsx +205 -46
  66. package/lib/runtime/components/react/dist/pickerFaces.js +12 -6
  67. package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
  68. package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
  69. package/lib/runtime/components/react/dist/{pickerOverlay.jsx → pickerViewOverlay.jsx} +5 -3
  70. package/lib/runtime/components/react/dist/useAnimationHooks.js +50 -12
  71. package/lib/runtime/components/react/dist/utils.jsx +83 -28
  72. package/lib/runtime/components/react/getInnerListeners.ts +35 -28
  73. package/lib/runtime/components/react/mpx-button.tsx +55 -36
  74. package/lib/runtime/components/react/mpx-canvas/index.tsx +2 -2
  75. package/lib/runtime/components/react/mpx-checkbox-group.tsx +13 -12
  76. package/lib/runtime/components/react/mpx-checkbox.tsx +28 -28
  77. package/lib/runtime/components/react/mpx-form.tsx +10 -8
  78. package/lib/runtime/components/react/mpx-icon.tsx +10 -15
  79. package/lib/runtime/components/react/mpx-image.tsx +396 -0
  80. package/lib/runtime/components/react/mpx-input.tsx +61 -33
  81. package/lib/runtime/components/react/mpx-label.tsx +14 -13
  82. package/lib/runtime/components/react/mpx-movable-area.tsx +8 -7
  83. package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
  84. package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
  85. package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
  86. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
  87. package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
  88. package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
  89. package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
  90. package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
  91. package/lib/runtime/components/react/mpx-picker-view-column.tsx +4 -1
  92. package/lib/runtime/components/react/mpx-picker-view.tsx +7 -1
  93. package/lib/runtime/components/react/mpx-radio-group.tsx +11 -12
  94. package/lib/runtime/components/react/mpx-radio.tsx +26 -29
  95. package/lib/runtime/components/react/mpx-scroll-view.tsx +32 -30
  96. package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
  97. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
  98. package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
  99. package/lib/runtime/components/react/mpx-switch.tsx +10 -8
  100. package/lib/runtime/components/react/mpx-text.tsx +6 -2
  101. package/lib/runtime/components/react/mpx-view.tsx +37 -45
  102. package/lib/runtime/components/react/mpx-web-view.tsx +25 -15
  103. package/lib/runtime/components/react/types/global.d.ts +1 -16
  104. package/lib/runtime/components/react/utils.tsx +24 -24
  105. package/lib/runtime/components/tenon/getInnerListeners.js +334 -0
  106. package/lib/runtime/components/tenon/tenon-button.vue +309 -0
  107. package/lib/runtime/components/tenon/tenon-image.vue +66 -0
  108. package/lib/runtime/components/tenon/tenon-input.vue +171 -0
  109. package/lib/runtime/components/tenon/tenon-rich-text.vue +26 -0
  110. package/lib/runtime/components/tenon/tenon-scroll-view.vue +127 -0
  111. package/lib/runtime/components/tenon/tenon-switch.vue +96 -0
  112. package/lib/runtime/components/tenon/tenon-text.vue +70 -0
  113. package/lib/runtime/components/tenon/tenon-textarea.vue +86 -0
  114. package/lib/runtime/components/tenon/tenon-view.vue +93 -0
  115. package/lib/runtime/components/web/getInnerListeners.js +6 -6
  116. package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
  117. package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
  118. package/lib/runtime/components/web/mpx-picker.vue +382 -385
  119. package/lib/runtime/components/web/mpx-web-view.vue +162 -162
  120. package/lib/runtime/optionProcessor.js +7 -16
  121. package/lib/runtime/optionProcessor.tenon.js +84 -0
  122. package/lib/runtime/utils.js +2 -0
  123. package/lib/style-compiler/index.js +1 -1
  124. package/lib/style-compiler/plugins/hm.js +20 -0
  125. package/lib/template-compiler/bind-this.js +7 -2
  126. package/lib/template-compiler/compiler.js +67 -40
  127. package/lib/template-compiler/gen-node-react.js +2 -2
  128. package/lib/tenon/index.js +112 -0
  129. package/lib/tenon/processJSON.js +352 -0
  130. package/lib/tenon/processScript.js +198 -0
  131. package/lib/tenon/processStyles.js +21 -0
  132. package/lib/tenon/processTemplate.js +125 -0
  133. package/lib/tenon/script-helper.js +223 -0
  134. package/lib/utils/env.js +6 -1
  135. package/lib/utils/get-relative-path.js +25 -0
  136. package/package.json +7 -3
  137. package/LICENSE +0 -433
  138. package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
  139. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
  140. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -478
  141. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
  142. package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
  143. package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
  144. package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
@@ -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 } 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
- import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, flatGesture } from './utils';
42
- import { IntersectionObserverContext } from './context';
41
+ import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, extendObject, flatGesture } from './utils';
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;
@@ -60,11 +60,12 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
60
60
  const hasCallScrollToLower = useRef(false);
61
61
  const initialTimeout = useRef(null);
62
62
  const intersectionObservers = useContext(IntersectionObserverContext);
63
- const snapScrollIntoView = useRef('');
63
+ const firstScrollIntoViewChange = useRef(false);
64
64
  const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
65
- const { textStyle, innerStyle } = splitStyle(normalStyle);
65
+ const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
66
66
  const scrollViewRef = useAnimatedRef();
67
67
  useNodesRef(props, ref, scrollViewRef, {
68
+ style: normalStyle,
68
69
  scrollOffset: scrollOptions,
69
70
  node: {
70
71
  scrollEnabled: scrollX || scrollY,
@@ -77,6 +78,11 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
77
78
  },
78
79
  gestureRef: scrollViewRef
79
80
  });
81
+ const contextValue = useMemo(() => {
82
+ return {
83
+ gestureRef: scrollViewRef
84
+ };
85
+ }, []);
80
86
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: scrollViewRef, onLayout });
81
87
  if (scrollX && scrollY) {
82
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');
@@ -97,19 +103,25 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
97
103
  }
98
104
  }, [refresherTriggered]);
99
105
  useEffect(() => {
100
- if (scrollIntoView && __selectRef && snapScrollIntoView.current !== scrollIntoView) {
101
- snapScrollIntoView.current = scrollIntoView || '';
102
- setTimeout(() => {
103
- const refs = __selectRef(`#${scrollIntoView}`, 'node');
104
- if (refs) {
105
- const { nodeRef } = refs.getNodeInstance();
106
- nodeRef.current?.measureLayout(scrollViewRef.current, (left, top) => {
107
- scrollToOffset(left, top);
108
- });
109
- }
110
- });
106
+ if (scrollIntoView && __selectRef) {
107
+ if (!firstScrollIntoViewChange.current) {
108
+ setTimeout(handleScrollIntoView);
109
+ }
110
+ else {
111
+ handleScrollIntoView();
112
+ }
111
113
  }
114
+ firstScrollIntoViewChange.current = true;
112
115
  }, [scrollIntoView]);
116
+ function handleScrollIntoView() {
117
+ const refs = __selectRef(`#${scrollIntoView}`, 'node');
118
+ if (!refs)
119
+ return;
120
+ const { nodeRef } = refs.getNodeInstance();
121
+ nodeRef.current?.measureLayout(scrollViewRef.current, (left, top) => {
122
+ scrollToOffset(left, top);
123
+ });
124
+ }
113
125
  function selectLength(size) {
114
126
  return !scrollX ? size.height : size.width;
115
127
  }
@@ -164,14 +176,13 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
164
176
  const visibleLength = selectLength(e.nativeEvent.layoutMeasurement);
165
177
  const contentLength = selectLength(e.nativeEvent.contentSize);
166
178
  const offset = selectOffset(e.nativeEvent.contentOffset);
167
- scrollOptions.current = {
168
- ...scrollOptions.current,
179
+ extendObject(scrollOptions.current, {
169
180
  contentLength,
170
181
  offset,
171
182
  scrollLeft: position.scrollLeft,
172
183
  scrollTop: position.scrollTop,
173
184
  visibleLength
174
- };
185
+ });
175
186
  }
176
187
  function onScroll(e) {
177
188
  const { bindscroll } = props;
@@ -190,11 +201,6 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
190
201
  layoutRef
191
202
  }, props));
192
203
  updateScrollOptions(e, { scrollLeft, scrollTop });
193
- if (enableTriggerIntersectionObserver && intersectionObservers) {
194
- for (const key in intersectionObservers) {
195
- intersectionObservers[key].throttleMeasure();
196
- }
197
- }
198
204
  }
199
205
  function onScrollEnd(e) {
200
206
  const { bindscrollend } = props;
@@ -213,6 +219,14 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
213
219
  updateScrollOptions(e, { scrollLeft, scrollTop });
214
220
  onStartReached(e);
215
221
  onEndReached(e);
222
+ updateIntersection();
223
+ }
224
+ function updateIntersection() {
225
+ if (enableTriggerIntersectionObserver && intersectionObservers) {
226
+ for (const key in intersectionObservers) {
227
+ intersectionObservers[key].throttleMeasure();
228
+ }
229
+ }
216
230
  }
217
231
  function scrollToOffset(x = 0, y = 0) {
218
232
  if (scrollViewRef.current) {
@@ -271,9 +285,10 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
271
285
  function onScrollDrag(e) {
272
286
  const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset;
273
287
  updateScrollOptions(e, { scrollLeft, scrollTop });
288
+ updateIntersection();
274
289
  }
275
- let scrollAdditionalProps = {
276
- style: { ...innerStyle, ...layoutStyle },
290
+ const scrollAdditionalProps = extendObject({
291
+ style: extendObject({}, innerStyle, layoutStyle),
277
292
  pinchGestureEnabled: false,
278
293
  horizontal: scrollX && !scrollY,
279
294
  scrollEventThrottle: scrollEventThrottle,
@@ -284,22 +299,18 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
284
299
  ref: scrollViewRef,
285
300
  onScroll: onScroll,
286
301
  onContentSizeChange: onContentSizeChange,
287
- bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) ? onScrollTouchStart : undefined,
288
- bindtouchmove: ((enhanced && binddragging) || bindtouchend) ? onScrollTouchMove : undefined,
289
- bindtouchend: ((enhanced && binddragend) || bindtouchend) ? onScrollTouchEnd : undefined,
302
+ bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) && onScrollTouchStart,
303
+ bindtouchmove: ((enhanced && binddragging) || bindtouchend) && onScrollTouchMove,
304
+ bindtouchend: ((enhanced && binddragend) || bindtouchend) && onScrollTouchEnd,
290
305
  onScrollBeginDrag: onScrollDrag,
291
306
  onScrollEndDrag: onScrollDrag,
292
- onMomentumScrollEnd: onScrollEnd,
293
- ...layoutProps,
294
- ...(simultaneousHandlers ? { simultaneousHandlers } : {}),
295
- ...(waitForHandlers ? { waitFor: waitForHandlers } : {})
296
- };
307
+ onMomentumScrollEnd: onScrollEnd
308
+ }, (simultaneousHandlers ? { simultaneousHandlers } : {}), (waitForHandlers ? { waitFor: waitForHandlers } : {}), layoutProps);
297
309
  if (enhanced) {
298
- scrollAdditionalProps = {
299
- ...scrollAdditionalProps,
310
+ Object.assign(scrollAdditionalProps, {
300
311
  bounces,
301
312
  pagingEnabled
302
- };
313
+ });
303
314
  }
304
315
  const innerProps = useInnerProps(props, scrollAdditionalProps, [
305
316
  'id',
@@ -332,16 +343,20 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
332
343
  black: ['#000'],
333
344
  white: ['#fff']
334
345
  };
335
- return (<ScrollView {...innerProps} refreshControl={refresherEnabled
336
- ? (<RefreshControl progressBackgroundColor={refresherBackground} refreshing={refreshing} onRefresh={onRefresh} {...(refresherDefaultStyle && refresherDefaultStyle !== 'none' ? { colors: refreshColor[refresherDefaultStyle] } : {})}/>)
337
- : undefined}>
338
- {wrapChildren(props, {
339
- hasVarDec,
340
- varContext: varContextRef.current,
341
- textStyle,
342
- textProps
343
- })}
344
- </ScrollView>);
346
+ return createElement(ScrollView, extendObject({}, innerProps, {
347
+ refreshControl: refresherEnabled
348
+ ? createElement(RefreshControl, extendObject({
349
+ progressBackgroundColor: refresherBackground,
350
+ refreshing: refreshing,
351
+ onRefresh: onRefresh
352
+ }, (refresherDefaultStyle && refresherDefaultStyle !== 'none' ? { colors: refreshColor[refresherDefaultStyle] } : null)))
353
+ : undefined
354
+ }), createElement(ScrollViewContext.Provider, { value: contextValue }, wrapChildren(props, {
355
+ hasVarDec,
356
+ varContext: varContextRef.current,
357
+ textStyle,
358
+ textProps
359
+ })));
345
360
  });
346
361
  _ScrollView.displayName = 'MpxScrollView';
347
362
  export default _ScrollView;
@@ -0,0 +1,11 @@
1
+ import { Text } from 'react-native';
2
+ import { createElement } from 'react';
3
+ import { extendObject } from './utils';
4
+ const _Text2 = (props) => {
5
+ const { allowFontScaling = false } = props;
6
+ return createElement(Text, extendObject({}, props, {
7
+ allowFontScaling
8
+ }));
9
+ };
10
+ _Text2.displayName = 'MpxSimpleText';
11
+ export default _Text2;
@@ -1,34 +1,53 @@
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-offset': enableOffset, '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;
8
13
  const { textProps } = splitProps(props);
9
14
  const nodeRef = useRef(null);
10
- useNodesRef(props, ref, nodeRef, {});
11
15
  const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext });
12
16
  const { textStyle, innerStyle } = splitStyle(normalStyle);
17
+ useNodesRef(props, ref, nodeRef, {
18
+ style: normalStyle
19
+ });
13
20
  const {
14
21
  // 存储layout布局信息
15
22
  layoutRef, layoutProps, layoutStyle } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: nodeRef });
16
23
  const innerProps = useInnerProps(props, {
17
- style: { ...innerStyle, ...layoutStyle },
18
24
  ref: nodeRef,
19
25
  ...layoutProps
20
26
  }, [
21
27
  'children',
22
- 'enable-offset'
28
+ 'enable-offset',
29
+ 'style'
23
30
  ], { layoutRef });
24
- return (<View data-itemId={props['item-id']} {...innerProps}>
25
- {wrapChildren(props, {
31
+ const itemAnimatedStyle = useAnimatedStyle(() => {
32
+ if (!step.value)
33
+ return {};
34
+ const inputRange = [step.value, 0];
35
+ const outputRange = [0.7, 1];
36
+ return {
37
+ transform: [{
38
+ scale: interpolate(Math.abs(Math.abs(offset.value) - itemIndex * step.value), inputRange, outputRange)
39
+ }]
40
+ };
41
+ });
42
+ const mergeStyle = [innerStyle, layoutStyle, { width: '100%', height: '100%' }, scale ? itemAnimatedStyle : {}].concat(customStyle);
43
+ return (<Animated.View {...innerProps} style={mergeStyle} data-itemId={props['item-id']}>
44
+ {wrapChildren(props, {
26
45
  hasVarDec,
27
46
  varContext: varContextRef.current,
28
47
  textStyle,
29
48
  textProps
30
49
  })}
31
- </View>);
50
+ </Animated.View>);
32
51
  });
33
52
  _SwiperItem.displayName = 'MpxSwiperItem';
34
53
  export default _SwiperItem;