@mpxjs/webpack-plugin 2.9.69 → 2.9.70-alpha.0

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 (138) 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 +53 -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 +1 -0
  23. package/lib/runtime/components/react/dist/event.config.js +24 -24
  24. package/lib/runtime/components/react/dist/getInnerListeners.js +183 -165
  25. package/lib/runtime/components/react/dist/mpx-button.jsx +35 -42
  26. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +30 -12
  27. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
  28. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
  29. package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
  30. package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
  31. package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
  32. package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
  33. package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
  34. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
  35. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
  36. package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
  37. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
  38. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
  39. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
  40. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
  41. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
  42. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
  43. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
  44. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +110 -97
  45. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +32 -29
  46. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
  47. package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
  48. package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
  49. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
  50. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
  51. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
  52. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
  53. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
  54. package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
  55. package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
  56. package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
  57. package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
  58. package/lib/runtime/components/react/dist/mpx-view.jsx +29 -44
  59. package/lib/runtime/components/react/dist/mpx-web-view.jsx +105 -42
  60. package/lib/runtime/components/react/dist/pickerFaces.js +12 -6
  61. package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
  62. package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
  63. package/lib/runtime/components/react/dist/{pickerOverlay.jsx → pickerViewOverlay.jsx} +5 -3
  64. package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -9
  65. package/lib/runtime/components/react/dist/utils.jsx +20 -24
  66. package/lib/runtime/components/react/getInnerListeners.ts +35 -28
  67. package/lib/runtime/components/react/mpx-button.tsx +55 -36
  68. package/lib/runtime/components/react/mpx-canvas/index.tsx +2 -2
  69. package/lib/runtime/components/react/mpx-checkbox-group.tsx +13 -12
  70. package/lib/runtime/components/react/mpx-checkbox.tsx +28 -28
  71. package/lib/runtime/components/react/mpx-form.tsx +10 -8
  72. package/lib/runtime/components/react/mpx-icon.tsx +10 -15
  73. package/lib/runtime/components/react/mpx-image.tsx +396 -0
  74. package/lib/runtime/components/react/mpx-input.tsx +61 -33
  75. package/lib/runtime/components/react/mpx-label.tsx +14 -13
  76. package/lib/runtime/components/react/mpx-movable-area.tsx +8 -7
  77. package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
  78. package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
  79. package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
  80. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
  81. package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
  82. package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
  83. package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
  84. package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
  85. package/lib/runtime/components/react/mpx-picker-view-column.tsx +4 -1
  86. package/lib/runtime/components/react/mpx-picker-view.tsx +7 -1
  87. package/lib/runtime/components/react/mpx-radio-group.tsx +11 -12
  88. package/lib/runtime/components/react/mpx-radio.tsx +26 -29
  89. package/lib/runtime/components/react/mpx-scroll-view.tsx +32 -30
  90. package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
  91. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
  92. package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
  93. package/lib/runtime/components/react/mpx-switch.tsx +10 -8
  94. package/lib/runtime/components/react/mpx-text.tsx +6 -2
  95. package/lib/runtime/components/react/mpx-view.tsx +37 -45
  96. package/lib/runtime/components/react/mpx-web-view.tsx +25 -15
  97. package/lib/runtime/components/react/types/global.d.ts +1 -16
  98. package/lib/runtime/components/react/utils.tsx +24 -24
  99. package/lib/runtime/components/tenon/getInnerListeners.js +334 -0
  100. package/lib/runtime/components/tenon/tenon-button.vue +309 -0
  101. package/lib/runtime/components/tenon/tenon-image.vue +66 -0
  102. package/lib/runtime/components/tenon/tenon-input.vue +171 -0
  103. package/lib/runtime/components/tenon/tenon-rich-text.vue +26 -0
  104. package/lib/runtime/components/tenon/tenon-scroll-view.vue +127 -0
  105. package/lib/runtime/components/tenon/tenon-switch.vue +96 -0
  106. package/lib/runtime/components/tenon/tenon-text.vue +70 -0
  107. package/lib/runtime/components/tenon/tenon-textarea.vue +86 -0
  108. package/lib/runtime/components/tenon/tenon-view.vue +93 -0
  109. package/lib/runtime/components/web/getInnerListeners.js +6 -6
  110. package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
  111. package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
  112. package/lib/runtime/components/web/mpx-picker.vue +382 -385
  113. package/lib/runtime/components/web/mpx-web-view.vue +162 -162
  114. package/lib/runtime/optionProcessor.js +7 -16
  115. package/lib/runtime/optionProcessor.tenon.js +84 -0
  116. package/lib/runtime/utils.js +2 -0
  117. package/lib/style-compiler/index.js +1 -1
  118. package/lib/style-compiler/plugins/hm.js +20 -0
  119. package/lib/template-compiler/bind-this.js +7 -2
  120. package/lib/template-compiler/compiler.js +67 -40
  121. package/lib/template-compiler/gen-node-react.js +2 -2
  122. package/lib/tenon/index.js +117 -0
  123. package/lib/tenon/processJSON.js +352 -0
  124. package/lib/tenon/processScript.js +203 -0
  125. package/lib/tenon/processStyles.js +21 -0
  126. package/lib/tenon/processTemplate.js +126 -0
  127. package/lib/tenon/script-helper.js +223 -0
  128. package/lib/utils/env.js +6 -1
  129. package/lib/utils/get-relative-path.js +25 -0
  130. package/package.json +7 -3
  131. package/LICENSE +0 -433
  132. package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
  133. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
  134. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -478
  135. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
  136. package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
  137. package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
  138. package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
@@ -4,13 +4,13 @@
4
4
  * ✔ checked
5
5
  * ✔ color
6
6
  */
7
- import { useRef, useState, forwardRef, useEffect, useContext } from 'react';
7
+ import { useRef, useState, forwardRef, useEffect, useContext, createElement } from 'react';
8
8
  import { View, StyleSheet } from 'react-native';
9
9
  import { warn } from '@mpxjs/utils';
10
10
  import { LabelContext, RadioGroupContext } from './context';
11
11
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
12
12
  import useNodesRef from './useNodesRef';
13
- import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren } from './utils';
13
+ import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils';
14
14
  import Icon from './mpx-icon';
15
15
  const styles = StyleSheet.create({
16
16
  container: {
@@ -47,21 +47,14 @@ const styles = StyleSheet.create({
47
47
  });
48
48
  const Radio = forwardRef((radioProps, ref) => {
49
49
  const { textProps, innerProps: props = {} } = splitProps(radioProps);
50
- const { value = '', disabled = false, checked = false, color = '#09BB07', style = [], 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, bindtap, catchtap } = props;
50
+ const { value = '', disabled = false, checked = false, color = '#09BB07', style = [], 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, bindtap } = props;
51
51
  const [isChecked, setIsChecked] = useState(!!checked);
52
52
  const groupContext = useContext(RadioGroupContext);
53
53
  let groupValue;
54
54
  let notifyChange;
55
55
  const labelContext = useContext(LabelContext);
56
- const defaultStyle = {
57
- ...styles.wrapper,
58
- ...(isChecked && styles.wrapperChecked),
59
- ...(disabled && styles.wrapperDisabled)
60
- };
61
- const styleObj = {
62
- ...styles.container,
63
- ...style
64
- };
56
+ const defaultStyle = extendObject({}, styles.wrapper, isChecked ? styles.wrapperChecked : {}, disabled ? styles.wrapperDisabled : {});
57
+ const styleObj = extendObject({}, styles.container, style);
65
58
  const onChange = (evt) => {
66
59
  if (disabled || isChecked)
67
60
  return;
@@ -77,24 +70,17 @@ const Radio = forwardRef((radioProps, ref) => {
77
70
  notifyChange && notifyChange(evt);
78
71
  };
79
72
  const onTap = (evt) => {
80
- if (disabled)
81
- return;
82
73
  bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props));
83
74
  onChange(evt);
84
75
  };
85
- const catchTap = (evt) => {
86
- if (disabled)
87
- return;
88
- catchtap && catchtap(getCustomEvent('tap', evt, { layoutRef }, props));
89
- };
90
76
  const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
91
- const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle);
77
+ const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle);
92
78
  if (backgroundStyle) {
93
79
  warn('Radio does not support background image-related styles!');
94
80
  }
95
81
  const nodeRef = useRef(null);
96
82
  useNodesRef(props, ref, nodeRef, {
97
- defaultStyle,
83
+ style: extendObject({}, defaultStyle, normalStyle),
98
84
  change: onChange
99
85
  });
100
86
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
@@ -105,13 +91,16 @@ const Radio = forwardRef((radioProps, ref) => {
105
91
  if (labelContext) {
106
92
  labelContext.current.triggerChange = onChange;
107
93
  }
108
- const innerProps = useInnerProps(props, {
94
+ const innerProps = useInnerProps(props, extendObject({
109
95
  ref: nodeRef,
110
- style: { ...innerStyle, ...layoutStyle },
111
- ...layoutProps,
112
- bindtap: onTap,
113
- catchtap: catchTap
114
- }, [], {
96
+ style: extendObject({}, innerStyle, layoutStyle)
97
+ }, layoutProps, {
98
+ bindtap: !disabled && onTap
99
+ }), [
100
+ 'value',
101
+ 'disabled',
102
+ 'checked'
103
+ ], {
115
104
  layoutRef
116
105
  });
117
106
  useEffect(() => {
@@ -135,21 +124,17 @@ const Radio = forwardRef((radioProps, ref) => {
135
124
  }
136
125
  }
137
126
  }, [checked]);
138
- return (<View {...innerProps}>
139
- <View style={defaultStyle}>
140
- <Icon type='success' size={24} color={disabled ? '#E1E1E1' : color} style={{
141
- ...styles.icon,
142
- ...(isChecked && styles.iconChecked),
143
- ...(disabled && styles.iconDisabled)
144
- }}/>
145
- </View>
146
- {wrapChildren(props, {
147
- hasVarDec,
148
- varContext: varContextRef.current,
149
- textStyle,
150
- textProps
151
- })}
152
- </View>);
127
+ return createElement(View, innerProps, createElement(View, { style: defaultStyle }, createElement(Icon, {
128
+ type: 'success',
129
+ size: 24,
130
+ color: disabled ? '#E1E1E1' : color,
131
+ style: extendObject({}, styles.icon, isChecked && styles.iconChecked, disabled && styles.iconDisabled)
132
+ })), wrapChildren(props, {
133
+ hasVarDec,
134
+ varContext: varContextRef.current,
135
+ textStyle,
136
+ textProps
137
+ }));
153
138
  });
154
139
  Radio.displayName = 'MpxRadio';
155
140
  export default Radio;
@@ -0,0 +1,39 @@
1
+ export const generateHTML = (html) => {
2
+ return `<html><head>
3
+ <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scaleable=no" name="viewport">
4
+ <style>
5
+ html {
6
+ -ms-content-zooming: none;
7
+ -ms-touch-action: pan-x pan-y;
8
+ }
9
+ body {
10
+ position: fixed;
11
+ top: 0;
12
+ right: 0;
13
+ bottom: 0;
14
+ left: 0;
15
+ overflow: hidden;
16
+ }
17
+ html,body {
18
+ margin: 0;
19
+ padding: 0;
20
+ }
21
+ * {
22
+ user-select: none;
23
+ -ms-user-select: none;
24
+ -moz-user-select: none;
25
+ -webkit-user-select: none;
26
+ }
27
+ </style>
28
+ </head>
29
+ <body><div id="rich-text">${html}</div>
30
+ <script>
31
+ function sendHeight() {
32
+ const dom = document.getElementById('rich-text')
33
+ window.ReactNativeWebView.postMessage(dom.scrollHeight);
34
+ }
35
+ window.onload = sendHeight;
36
+ </script>
37
+ </body
38
+ ></html>`;
39
+ };
@@ -0,0 +1,63 @@
1
+ /**
2
+ * ✔ nodes
3
+ */
4
+ import { View } from 'react-native';
5
+ import { useRef, forwardRef, useState } from 'react';
6
+ import useInnerProps from '../getInnerListeners';
7
+ import useNodesRef from '../useNodesRef'; // 引入辅助函数
8
+ import { useTransformStyle, useLayout } from '../utils';
9
+ import { WebView } from 'react-native-webview';
10
+ import { generateHTML } from './html';
11
+ function jsonToHtmlStr(elements) {
12
+ let htmlStr = '';
13
+ for (const element of elements) {
14
+ if (element.type === 'text') {
15
+ htmlStr += element.text;
16
+ return htmlStr;
17
+ }
18
+ const { name, attrs = {}, children = [] } = element;
19
+ let attrStr = '';
20
+ for (const [key, value] of Object.entries(attrs))
21
+ attrStr += ` ${key}="${value}"`;
22
+ let childrenStr = '';
23
+ for (const child of children)
24
+ childrenStr += jsonToHtmlStr([child]);
25
+ htmlStr += `<${name}${attrStr}>${childrenStr}</${name}>`;
26
+ }
27
+ return htmlStr;
28
+ }
29
+ const _RichText = forwardRef((props, ref) => {
30
+ const { style = {}, nodes, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
31
+ const nodeRef = useRef(null);
32
+ const [webViewHeight, setWebViewHeight] = useState(0);
33
+ const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(Object.assign({
34
+ width: '100%',
35
+ height: webViewHeight
36
+ }, style), {
37
+ enableVar,
38
+ externalVarContext,
39
+ parentFontSize,
40
+ parentWidth,
41
+ parentHeight
42
+ });
43
+ const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
44
+ useNodesRef(props, ref, nodeRef, {
45
+ layoutRef
46
+ });
47
+ const innerProps = useInnerProps(props, {
48
+ ref: nodeRef,
49
+ style: { ...normalStyle, ...layoutStyle },
50
+ ...layoutProps
51
+ }, [], {
52
+ layoutRef
53
+ });
54
+ const html = typeof nodes === 'string' ? nodes : jsonToHtmlStr(nodes);
55
+ return (<View {...innerProps}>
56
+ <WebView source={{ html: generateHTML(html) }} onMessage={(event) => {
57
+ setWebViewHeight(+event.nativeEvent.data);
58
+ }}>
59
+ </WebView>
60
+ </View>);
61
+ });
62
+ _RichText.displayName = 'mpx-rich-text';
63
+ export default _RichText;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * ✔ enable
3
+ */
4
+ import { createElement, Fragment } from 'react';
1
5
  import { Portal } from '@ant-design/react-native';
2
6
  import { warn } from '@mpxjs/utils';
3
7
  const _RootPortal = (props) => {
@@ -6,10 +10,8 @@ const _RootPortal = (props) => {
6
10
  warn('The root-portal component does not support the style prop.');
7
11
  }
8
12
  return enable
9
- ? <Portal>
10
- {children}
11
- </Portal>
12
- : <>{children}</>;
13
+ ? createElement(Portal, null, children)
14
+ : createElement(Fragment, null, children);
13
15
  };
14
16
  _RootPortal.displayName = 'MpxRootPortal';
15
17
  export default _RootPortal;
@@ -33,12 +33,12 @@
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 } 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';
41
+ import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, extendObject, flatGesture } from './utils';
42
42
  import { IntersectionObserverContext } from './context';
43
43
  const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
44
44
  const { textProps, innerProps: props = {} } = splitProps(scrollViewProps);
@@ -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,
@@ -97,19 +98,25 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
97
98
  }
98
99
  }, [refresherTriggered]);
99
100
  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
- });
101
+ if (scrollIntoView && __selectRef) {
102
+ if (!firstScrollIntoViewChange.current) {
103
+ setTimeout(handleScrollIntoView);
104
+ }
105
+ else {
106
+ handleScrollIntoView();
107
+ }
111
108
  }
109
+ firstScrollIntoViewChange.current = true;
112
110
  }, [scrollIntoView]);
111
+ function handleScrollIntoView() {
112
+ const refs = __selectRef(`#${scrollIntoView}`, 'node');
113
+ if (!refs)
114
+ return;
115
+ const { nodeRef } = refs.getNodeInstance();
116
+ nodeRef.current?.measureLayout(scrollViewRef.current, (left, top) => {
117
+ scrollToOffset(left, top);
118
+ });
119
+ }
113
120
  function selectLength(size) {
114
121
  return !scrollX ? size.height : size.width;
115
122
  }
@@ -164,14 +171,13 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
164
171
  const visibleLength = selectLength(e.nativeEvent.layoutMeasurement);
165
172
  const contentLength = selectLength(e.nativeEvent.contentSize);
166
173
  const offset = selectOffset(e.nativeEvent.contentOffset);
167
- scrollOptions.current = {
168
- ...scrollOptions.current,
174
+ extendObject(scrollOptions.current, {
169
175
  contentLength,
170
176
  offset,
171
177
  scrollLeft: position.scrollLeft,
172
178
  scrollTop: position.scrollTop,
173
179
  visibleLength
174
- };
180
+ });
175
181
  }
176
182
  function onScroll(e) {
177
183
  const { bindscroll } = props;
@@ -272,8 +278,8 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
272
278
  const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset;
273
279
  updateScrollOptions(e, { scrollLeft, scrollTop });
274
280
  }
275
- let scrollAdditionalProps = {
276
- style: { ...innerStyle, ...layoutStyle },
281
+ const scrollAdditionalProps = extendObject({
282
+ style: extendObject({}, innerStyle, layoutStyle),
277
283
  pinchGestureEnabled: false,
278
284
  horizontal: scrollX && !scrollY,
279
285
  scrollEventThrottle: scrollEventThrottle,
@@ -284,22 +290,18 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
284
290
  ref: scrollViewRef,
285
291
  onScroll: onScroll,
286
292
  onContentSizeChange: onContentSizeChange,
287
- bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) ? onScrollTouchStart : undefined,
288
- bindtouchmove: ((enhanced && binddragging) || bindtouchend) ? onScrollTouchMove : undefined,
289
- bindtouchend: ((enhanced && binddragend) || bindtouchend) ? onScrollTouchEnd : undefined,
293
+ bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) && onScrollTouchStart,
294
+ bindtouchmove: ((enhanced && binddragging) || bindtouchend) && onScrollTouchMove,
295
+ bindtouchend: ((enhanced && binddragend) || bindtouchend) && onScrollTouchEnd,
290
296
  onScrollBeginDrag: onScrollDrag,
291
297
  onScrollEndDrag: onScrollDrag,
292
- onMomentumScrollEnd: onScrollEnd,
293
- ...layoutProps,
294
- ...(simultaneousHandlers ? { simultaneousHandlers } : {}),
295
- ...(waitForHandlers ? { waitFor: waitForHandlers } : {})
296
- };
298
+ onMomentumScrollEnd: onScrollEnd
299
+ }, (simultaneousHandlers ? { simultaneousHandlers } : {}), (waitForHandlers ? { waitFor: waitForHandlers } : {}), layoutProps);
297
300
  if (enhanced) {
298
- scrollAdditionalProps = {
299
- ...scrollAdditionalProps,
301
+ Object.assign(scrollAdditionalProps, {
300
302
  bounces,
301
303
  pagingEnabled
302
- };
304
+ });
303
305
  }
304
306
  const innerProps = useInnerProps(props, scrollAdditionalProps, [
305
307
  'id',
@@ -332,16 +334,20 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
332
334
  black: ['#000'],
333
335
  white: ['#fff']
334
336
  };
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>);
337
+ return createElement(ScrollView, extendObject({}, innerProps, {
338
+ refreshControl: refresherEnabled
339
+ ? createElement(RefreshControl, extendObject({
340
+ progressBackgroundColor: refresherBackground,
341
+ refreshing: refreshing,
342
+ onRefresh: onRefresh
343
+ }, (refresherDefaultStyle && refresherDefaultStyle !== 'none' ? { colors: refreshColor[refresherDefaultStyle] } : null)))
344
+ : undefined
345
+ }), wrapChildren(props, {
346
+ hasVarDec,
347
+ varContext: varContextRef.current,
348
+ textStyle,
349
+ textProps
350
+ }));
345
351
  });
346
352
  _ScrollView.displayName = 'MpxScrollView';
347
353
  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;
@@ -4,12 +4,14 @@ import useInnerProps from './getInnerListeners';
4
4
  import useNodesRef from './useNodesRef'; // 引入辅助函数
5
5
  import { useTransformStyle, splitStyle, splitProps, wrapChildren, useLayout } from './utils';
6
6
  const _SwiperItem = forwardRef((props, ref) => {
7
- const { 'enable-offset': enableOffset, 'enable-var': enableVar, 'external-var-context': externalVarContext, style } = props;
7
+ const { 'enable-var': enableVar, 'external-var-context': externalVarContext, style } = props;
8
8
  const { textProps } = splitProps(props);
9
9
  const nodeRef = useRef(null);
10
- useNodesRef(props, ref, nodeRef, {});
11
10
  const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext });
12
11
  const { textStyle, innerStyle } = splitStyle(normalStyle);
12
+ useNodesRef(props, ref, nodeRef, {
13
+ style: normalStyle
14
+ });
13
15
  const {
14
16
  // 存储layout布局信息
15
17
  layoutRef, layoutProps, layoutStyle } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: nodeRef });