@mpxjs/webpack-plugin 2.10.4-beta.19-input → 2.10.4-beta.19-input1

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 (34) hide show
  1. package/lib/runtime/components/react/dist/getInnerListeners.js +22 -36
  2. package/lib/runtime/components/react/dist/mpx-button.jsx +2 -7
  3. package/lib/runtime/components/react/dist/mpx-canvas/Image.js +4 -2
  4. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +17 -20
  5. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +2 -7
  6. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +2 -7
  7. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -7
  8. package/lib/runtime/components/react/dist/mpx-image.jsx +20 -33
  9. package/lib/runtime/components/react/dist/mpx-input.jsx +9 -14
  10. package/lib/runtime/components/react/dist/mpx-label.jsx +2 -7
  11. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +3 -8
  12. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +79 -205
  13. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +13 -11
  14. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +7 -8
  15. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +11 -29
  16. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +5 -3
  17. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +2 -9
  18. package/lib/runtime/components/react/dist/mpx-radio.jsx +2 -7
  19. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +2 -10
  20. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +51 -104
  21. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +1 -3
  22. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +9 -11
  23. package/lib/runtime/components/react/dist/mpx-swiper.jsx +141 -203
  24. package/lib/runtime/components/react/dist/mpx-switch.jsx +2 -7
  25. package/lib/runtime/components/react/dist/mpx-text.jsx +2 -7
  26. package/lib/runtime/components/react/dist/mpx-video.jsx +2 -7
  27. package/lib/runtime/components/react/dist/mpx-view.jsx +26 -28
  28. package/lib/runtime/components/react/dist/mpx-web-view.jsx +29 -34
  29. package/lib/runtime/components/react/dist/useAnimationHooks.js +89 -12
  30. package/lib/runtime/components/react/dist/utils.jsx +114 -199
  31. package/package.json +1 -1
  32. package/lib/runtime/components/react/dist/mpx-async-suspense.jsx +0 -145
  33. package/lib/runtime/components/react/dist/mpx-progress.jsx +0 -163
  34. package/lib/runtime/components/react/dist/mpx-slider.jsx +0 -321
@@ -3,13 +3,12 @@ import { collectDataset } from '@mpxjs/utils';
3
3
  import { omit, extendObject, useNavigation } from './utils';
4
4
  import eventConfigMap from './event.config';
5
5
  const globalEventState = {
6
- needPress: true,
7
- identifier: null
6
+ needPress: true
8
7
  };
9
8
  const getTouchEvent = (type, event, config) => {
10
9
  const { navigation, propsRef, layoutRef } = config;
11
10
  const props = propsRef.current;
12
- const { top: navigationY = 0 } = navigation?.layout || {};
11
+ const { y: navigationY = 0 } = navigation?.layout || {};
13
12
  const nativeEvent = event.nativeEvent;
14
13
  const { timestamp, pageX, pageY, touches, changedTouches } = nativeEvent;
15
14
  const { id } = props;
@@ -95,48 +94,36 @@ function checkIsNeedPress(e, type, ref) {
95
94
  ref.current.startTimer[type] = null;
96
95
  }
97
96
  }
98
- function shouldHandleTapEvent(e, eventConfig) {
99
- const { identifier } = e.nativeEvent.changedTouches[0];
100
- return eventConfig.tap && globalEventState.identifier === identifier;
101
- }
102
97
  function handleTouchstart(e, type, eventConfig) {
98
+ // 阻止事件被释放放回对象池,导致对象复用 _stoppedEventTypes 状态被保留
103
99
  e.persist();
104
100
  const { innerRef } = eventConfig;
105
- const touch = e.nativeEvent.changedTouches[0];
106
- const { identifier } = touch;
107
- const isSingle = e.nativeEvent.touches.length <= 1;
108
- if (isSingle) {
109
- // 仅在 touchstart 记录第一个单指触摸点
110
- globalEventState.identifier = identifier;
111
- globalEventState.needPress = true;
112
- innerRef.current.mpxPressInfo.detail = {
113
- x: touch.pageX,
114
- y: touch.pageY
115
- };
116
- }
101
+ globalEventState.needPress = true;
102
+ innerRef.current.mpxPressInfo.detail = {
103
+ x: e.nativeEvent.changedTouches[0].pageX,
104
+ y: e.nativeEvent.changedTouches[0].pageY
105
+ };
117
106
  handleEmitEvent('touchstart', e, type, eventConfig);
118
107
  if (eventConfig.longpress) {
119
- // 只有单指触摸时才启动长按定时器
120
- if (isSingle) {
121
- if (e._stoppedEventTypes?.has('longpress')) {
122
- return;
123
- }
124
- if (eventConfig.longpress.hasCatch) {
125
- e._stoppedEventTypes = e._stoppedEventTypes || new Set();
126
- e._stoppedEventTypes.add('longpress');
127
- }
128
- innerRef.current.startTimer[type] && clearTimeout(innerRef.current.startTimer[type]);
129
- innerRef.current.startTimer[type] = setTimeout(() => {
130
- globalEventState.needPress = false;
131
- handleEmitEvent('longpress', e, type, eventConfig);
132
- }, 350);
108
+ if (e._stoppedEventTypes?.has('longpress')) {
109
+ return;
110
+ }
111
+ if (eventConfig.longpress.hasCatch) {
112
+ e._stoppedEventTypes = e._stoppedEventTypes || new Set();
113
+ e._stoppedEventTypes.add('longpress');
133
114
  }
115
+ innerRef.current.startTimer[type] && clearTimeout(innerRef.current.startTimer[type]);
116
+ innerRef.current.startTimer[type] = setTimeout(() => {
117
+ // 只要触发过longpress, 全局就不再触发tap
118
+ globalEventState.needPress = false;
119
+ handleEmitEvent('longpress', e, type, eventConfig);
120
+ }, 350);
134
121
  }
135
122
  }
136
123
  function handleTouchmove(e, type, eventConfig) {
137
124
  const { innerRef } = eventConfig;
138
125
  handleEmitEvent('touchmove', e, type, eventConfig);
139
- if (shouldHandleTapEvent(e, eventConfig)) {
126
+ if (eventConfig.tap) {
140
127
  checkIsNeedPress(e, type, innerRef);
141
128
  }
142
129
  }
@@ -144,8 +131,7 @@ function handleTouchend(e, type, eventConfig) {
144
131
  const { innerRef, disableTap } = eventConfig;
145
132
  handleEmitEvent('touchend', e, type, eventConfig);
146
133
  innerRef.current.startTimer[type] && clearTimeout(innerRef.current.startTimer[type]);
147
- // 只有单指触摸结束时才触发 tap
148
- if (shouldHandleTapEvent(e, eventConfig)) {
134
+ if (eventConfig.tap) {
149
135
  checkIsNeedPress(e, type, innerRef);
150
136
  if (!globalEventState.needPress || (type === 'bubble' && disableTap) || e._stoppedEventTypes?.has('tap')) {
151
137
  return;
@@ -42,7 +42,6 @@ import { getCurrentPage, splitProps, splitStyle, useLayout, useTransformStyle, w
42
42
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
43
43
  import useNodesRef from './useNodesRef';
44
44
  import { RouteContext, FormContext } from './context';
45
- import Portal from './mpx-portal';
46
45
  const LOADING_IMAGE_URI = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAB8hJREFUeJztnVtsFFUch6ltUYrEAi0Qo40xChGM+oAGI0EEKl4QfDVI9AkqqQZ4IVA1RSIvJlwUWwqJUokGKMVYwHJTq4mGuA+SxpJYggJSSgMpVFOtvbh+J84mk+3smXN2znZm2fNLvoQH5uQ/v4+Z2Z3dHUaNsrGxsbGxsbGxsbGxsbGxsTGSrq6uUqiHqw7iz6Vhz5WzofwYxJP4Mey5cjIUX+4hI0F52PPlXCi9WiKkOuz5ci5WiMFcvHhxOXRCHPpgLdyis4ZJITtqagtgPfRBHH6HV3XWyNpQ/DxHRDJbddYxLKTGEZHMLK2dy8ZQ/O4UQgQzVdcxJYTSZ6aQIfggrZ3MplD6CYmQmOo6BoXEJEK+TGsnsymUXicRIlimso4JIRS+TCJDsD3QzmZDKHwqDEmEdECR3zpBhVB2EVyWyBiC+4zsdNRD4Vt8jpJ3/dYwIGSTz9Gx2cjOZkMofBx0S4SIl8JlsjWCCKHsMuiXyOiGcUZ3Ouqh8BU+R0mjbPuAQg76HB3Lje5sNoTC86DNR8qcVNunK4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ggg==';
47
46
  const TypeColorMap = {
48
47
  default: ['#F8F8F8', '#DEDEDE', '35,35,35', '#F7F7F7'],
@@ -168,7 +167,7 @@ const Button = forwardRef((buttonProps, ref) => {
168
167
  const defaultTextStyle = extendObject({}, styles.text, isMiniSize ? styles.textMini : {}, { color: plain ? plainTextColor : normalTextColor });
169
168
  const defaultStyle = extendObject({}, defaultViewStyle, defaultTextStyle);
170
169
  const styleObj = extendObject({}, defaultStyle, style, isHover ? hoverStyle : {});
171
- const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
170
+ const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
172
171
  const nodeRef = useRef(null);
173
172
  useNodesRef(props, ref, nodeRef, { style: normalStyle });
174
173
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
@@ -263,13 +262,9 @@ const Button = forwardRef((buttonProps, ref) => {
263
262
  textStyle,
264
263
  textProps
265
264
  }));
266
- const finalComponent = enableHover
265
+ return enableHover
267
266
  ? createElement(GestureDetector, { gesture: gesture }, baseButton)
268
267
  : baseButton;
269
- if (hasPositionFixed) {
270
- return createElement(Portal, null, finalComponent);
271
- }
272
- return finalComponent;
273
268
  });
274
269
  Button.displayName = 'MpxButton';
275
270
  export default Button;
@@ -1,5 +1,4 @@
1
1
  import { WEBVIEW_TARGET, registerWebviewProperties } from './utils';
2
- import { extendObject } from '../utils';
3
2
  const PROPERTIES = {
4
3
  crossOrigin: undefined,
5
4
  height: undefined,
@@ -51,7 +50,10 @@ export class Image {
51
50
  this[key] = value;
52
51
  }
53
52
  }
54
- callbackFn(extendObject({}, message.payload, { target: this }));
53
+ callbackFn({
54
+ ...message.payload,
55
+ target: this
56
+ });
55
57
  }
56
58
  });
57
59
  }
@@ -23,7 +23,6 @@ import './CanvasGradient';
23
23
  import { createImage as canvasCreateImage } from './Image';
24
24
  import { createImageData as canvasCreateImageData } from './ImageData';
25
25
  import { useConstructorsRegistry } from './constructorsRegistry';
26
- import Portal from '../mpx-portal';
27
26
  const stylesheet = StyleSheet.create({
28
27
  container: { overflow: 'hidden', flex: 0 },
29
28
  webview: {
@@ -42,7 +41,7 @@ const _Canvas = forwardRef((props = {}, ref) => {
42
41
  const { style = {}, originWhitelist = ['*'], 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
43
42
  const [isLoaded, setIsLoaded] = useState(false);
44
43
  const nodeRef = useRef(null);
45
- const { normalStyle, hasSelfPercent, hasPositionFixed, setWidth, setHeight } = useTransformStyle(extendObject({}, style, stylesheet.container), {
44
+ const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(extendObject({}, style, stylesheet.container), {
46
45
  enableVar,
47
46
  externalVarContext,
48
47
  parentFontSize,
@@ -111,7 +110,10 @@ const _Canvas = forwardRef((props = {}, ref) => {
111
110
  const postMessage = useCallback(async (message) => {
112
111
  if (!canvasRef.current?.bus)
113
112
  return;
114
- const { type, payload } = await canvasRef.current.bus.post(extendObject({ id: ID() }, message));
113
+ const { type, payload } = await canvasRef.current.bus.post({
114
+ id: ID(),
115
+ ...message
116
+ });
115
117
  switch (type) {
116
118
  case 'error': {
117
119
  const { binderror } = props;
@@ -140,7 +142,7 @@ const _Canvas = forwardRef((props = {}, ref) => {
140
142
  canvasRef.current.listeners.splice(canvasRef.current.listeners.indexOf(listener), 1);
141
143
  };
142
144
  const onMessage = useCallback((e) => {
143
- const data = JSON.parse(e.nativeEvent.data);
145
+ let data = JSON.parse(e.nativeEvent.data);
144
146
  switch (data.type) {
145
147
  case 'error': {
146
148
  const { binderror } = props;
@@ -154,27 +156,27 @@ const _Canvas = forwardRef((props = {}, ref) => {
154
156
  break;
155
157
  }
156
158
  default: {
157
- const newData = {};
158
- // createLinearGradient 方法调用需要在 constructors 中需要注册 CanvasGradient
159
- const constructor = constructors[data.meta.constructor];
160
159
  if (data.payload) {
160
+ // createLinearGradient 方法调用需要在 constructors 中需要注册 CanvasGradient
161
+ const constructor = constructors[data.meta.constructor];
161
162
  if (constructor) {
162
163
  const { args, payload } = data;
163
164
  // RN 端同步生成一个 CanvasGradient 的实例
164
165
  const object = constructor.constructLocally(canvasRef.current, ...args);
165
- extendObject(object, payload, {
166
+ Object.assign(object, payload, {
166
167
  [WEBVIEW_TARGET]: data.meta.target
167
168
  });
168
- extendObject(newData, data, {
169
+ data = {
170
+ ...data,
169
171
  payload: object
170
- });
172
+ };
171
173
  }
172
174
  for (const listener of canvasRef.current.listeners) {
173
- listener(constructor ? newData.payload : data.payload);
175
+ listener(data.payload);
174
176
  }
175
177
  }
176
178
  if (canvasRef.current.bus) {
177
- canvasRef.current.bus.handle(constructor && data.payload ? newData : data);
179
+ canvasRef.current.bus.handle(data);
178
180
  }
179
181
  }
180
182
  }
@@ -190,10 +192,9 @@ const _Canvas = forwardRef((props = {}, ref) => {
190
192
  node: canvasRef.current,
191
193
  context: context2D
192
194
  });
193
- let canvasComponent;
194
- if (__mpx_mode__ === 'android') {
195
+ if (__mpx_mode__ !== 'ios') {
195
196
  const isAndroid9 = Platform.Version >= 28;
196
- canvasComponent = createElement(View, innerProps, createElement(WebView, {
197
+ return createElement(View, innerProps, createElement(WebView, {
197
198
  ref: (element) => {
198
199
  if (canvasRef.current) {
199
200
  canvasRef.current.webview = element;
@@ -216,7 +217,7 @@ const _Canvas = forwardRef((props = {}, ref) => {
216
217
  allowUniversalAccessFromFileURLs: true
217
218
  }));
218
219
  }
219
- canvasComponent = createElement(View, innerProps, createElement(WebView, {
220
+ return createElement(View, innerProps, createElement(WebView, {
220
221
  ref: (element) => {
221
222
  if (canvasRef.current) {
222
223
  canvasRef.current.webview = element;
@@ -229,10 +230,6 @@ const _Canvas = forwardRef((props = {}, ref) => {
229
230
  onLoad: onLoad,
230
231
  scrollEnabled: false
231
232
  }));
232
- if (hasPositionFixed) {
233
- canvasComponent = createElement(Portal, null, canvasComponent);
234
- }
235
- return canvasComponent;
236
233
  });
237
234
  _Canvas.displayName = 'mpxCanvas';
238
235
  export default _Canvas;
@@ -8,7 +8,6 @@ import { FormContext, CheckboxGroupContext } from './context';
8
8
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
9
9
  import useNodesRef from './useNodesRef';
10
10
  import { useLayout, useTransformStyle, wrapChildren, extendObject } from './utils';
11
- import Portal from './mpx-portal';
12
11
  const CheckboxGroup = forwardRef((props, ref) => {
13
12
  const propsRef = useRef({});
14
13
  propsRef.current = props;
@@ -24,7 +23,7 @@ const CheckboxGroup = forwardRef((props, ref) => {
24
23
  flexWrap: 'wrap'
25
24
  };
26
25
  const styleObj = extendObject({}, defaultStyle, style);
27
- const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
26
+ const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
28
27
  const nodeRef = useRef(null);
29
28
  useNodesRef(props, ref, nodeRef, { style: normalStyle });
30
29
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
@@ -82,14 +81,10 @@ const CheckboxGroup = forwardRef((props, ref) => {
82
81
  notifyChange
83
82
  };
84
83
  }, []);
85
- const finalComponent = createElement(View, innerProps, createElement(CheckboxGroupContext.Provider, { value: contextValue }, wrapChildren(props, {
84
+ return createElement(View, innerProps, createElement(CheckboxGroupContext.Provider, { value: contextValue }, wrapChildren(props, {
86
85
  hasVarDec,
87
86
  varContext: varContextRef.current
88
87
  })));
89
- if (hasPositionFixed) {
90
- return createElement(Portal, null, finalComponent);
91
- }
92
- return finalComponent;
93
88
  });
94
89
  CheckboxGroup.displayName = 'MpxCheckboxGroup';
95
90
  export default CheckboxGroup;
@@ -12,7 +12,6 @@ import useNodesRef from './useNodesRef';
12
12
  import Icon from './mpx-icon';
13
13
  import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils';
14
14
  import { CheckboxGroupContext, LabelContext } from './context';
15
- import Portal from './mpx-portal';
16
15
  const styles = StyleSheet.create({
17
16
  container: {
18
17
  flexDirection: 'row',
@@ -64,7 +63,7 @@ const Checkbox = forwardRef((checkboxProps, ref) => {
64
63
  bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props));
65
64
  onChange(evt);
66
65
  };
67
- const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
66
+ const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
68
67
  const nodeRef = useRef(null);
69
68
  useNodesRef(props, ref, nodeRef, {
70
69
  style: extendObject({}, defaultStyle, normalStyle),
@@ -115,7 +114,7 @@ const Checkbox = forwardRef((checkboxProps, ref) => {
115
114
  }
116
115
  }
117
116
  }, [checked]);
118
- const finalComponent = createElement(View, innerProps, createElement(View, { style: defaultStyle }, createElement(Icon, {
117
+ return createElement(View, innerProps, createElement(View, { style: defaultStyle }, createElement(Icon, {
119
118
  type: 'success_no_circle',
120
119
  size: 18,
121
120
  color: disabled ? '#ADADAD' : color,
@@ -126,10 +125,6 @@ const Checkbox = forwardRef((checkboxProps, ref) => {
126
125
  textStyle,
127
126
  textProps
128
127
  }));
129
- if (hasPositionFixed) {
130
- return createElement(Portal, null, finalComponent);
131
- }
132
- return finalComponent;
133
128
  });
134
129
  Checkbox.displayName = 'MpxCheckbox';
135
130
  export default Checkbox;
@@ -17,7 +17,6 @@ import Cancel from './icons/cancel.png';
17
17
  import Download from './icons/download.png';
18
18
  import Search from './icons/search.png';
19
19
  import Clear from './icons/clear.png';
20
- import Portal from '../mpx-portal';
21
20
  const IconTypeMap = new Map([
22
21
  ['success', Success],
23
22
  ['success_no_circle', SuccessNoCircle],
@@ -34,7 +33,7 @@ const Icon = forwardRef((props, ref) => {
34
33
  const source = IconTypeMap.get(type);
35
34
  const defaultStyle = { width: ~~size, height: ~~size };
36
35
  const styleObj = extendObject({}, defaultStyle, style);
37
- const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
36
+ const { hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
38
37
  const nodeRef = useRef(null);
39
38
  useNodesRef(props, ref, nodeRef, { style: normalStyle });
40
39
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
@@ -45,11 +44,7 @@ const Icon = forwardRef((props, ref) => {
45
44
  }), [], {
46
45
  layoutRef
47
46
  });
48
- const finalComponent = createElement(Image, innerProps);
49
- if (hasPositionFixed) {
50
- return createElement(Portal, null, finalComponent);
51
- }
52
- return finalComponent;
47
+ return createElement(Image, innerProps);
53
48
  });
54
49
  Icon.displayName = 'MpxIcon';
55
50
  export default Icon;
@@ -17,7 +17,6 @@ import { SvgCssUri } from 'react-native-svg/css';
17
17
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
18
18
  import useNodesRef from './useNodesRef';
19
19
  import { SVG_REGEXP, useLayout, useTransformStyle, renderImage, extendObject } from './utils';
20
- import Portal from './mpx-portal';
21
20
  const DEFAULT_IMAGE_WIDTH = 320;
22
21
  const DEFAULT_IMAGE_HEIGHT = 240;
23
22
  const cropMode = [
@@ -80,7 +79,7 @@ const Image = forwardRef((props, ref) => {
80
79
  setLoaded(true);
81
80
  }
82
81
  };
83
- const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
82
+ const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
84
83
  const { layoutRef, layoutStyle, layoutProps } = useLayout({
85
84
  props,
86
85
  hasSelfPercent,
@@ -256,8 +255,6 @@ const Image = forwardRef((props, ref) => {
256
255
  state.current = {};
257
256
  setLoaded(true);
258
257
  }
259
- }, () => {
260
- setLoaded(true);
261
258
  });
262
259
  }
263
260
  }, [src, isSvg, isLayoutMode]);
@@ -271,35 +268,25 @@ const Image = forwardRef((props, ref) => {
271
268
  ], {
272
269
  layoutRef
273
270
  });
274
- function renderSvgImage() {
275
- return createElement(View, innerProps, createElement(SvgCssUri, {
276
- uri: src,
277
- onLayout: onSvgLoad,
278
- onError: binderror && onSvgError,
279
- style: extendObject({ transformOrigin: 'left top' }, modeStyle)
280
- }));
281
- }
282
- function renderBaseImage() {
283
- return renderImage(extendObject({
284
- source: { uri: src },
285
- resizeMode: resizeMode,
286
- onLoad: bindload && onImageLoad,
287
- onError: binderror && onImageError,
288
- style: extendObject({
289
- transformOrigin: 'left top',
290
- width: isCropMode ? imageWidth : '100%',
291
- height: isCropMode ? imageHeight : '100%'
292
- }, isCropMode ? modeStyle : {})
293
- }, isLayoutMode ? {} : innerProps), enableFastImage);
294
- }
295
- function renderLayoutImage() {
296
- return createElement(View, innerProps, loaded && renderBaseImage());
297
- }
298
- const finalComponent = isSvg ? renderSvgImage() : isLayoutMode ? renderLayoutImage() : renderBaseImage();
299
- if (hasPositionFixed) {
300
- return createElement(Portal, null, finalComponent);
301
- }
302
- return finalComponent;
271
+ const SvgImage = createElement(View, innerProps, createElement(SvgCssUri, {
272
+ uri: src,
273
+ onLayout: onSvgLoad,
274
+ onError: binderror && onSvgError,
275
+ style: extendObject({ transformOrigin: 'left top' }, modeStyle)
276
+ }));
277
+ const BaseImage = renderImage(extendObject({
278
+ source: { uri: src },
279
+ resizeMode: resizeMode,
280
+ onLoad: bindload && onImageLoad,
281
+ onError: binderror && onImageError,
282
+ style: extendObject({
283
+ transformOrigin: 'left top',
284
+ width: isCropMode ? imageWidth : '100%',
285
+ height: isCropMode ? imageHeight : '100%'
286
+ }, isCropMode ? modeStyle : {})
287
+ }, isLayoutMode ? {} : innerProps), enableFastImage);
288
+ const LayoutImage = createElement(View, innerProps, loaded && BaseImage);
289
+ return isSvg ? SvgImage : isLayoutMode ? LayoutImage : BaseImage;
303
290
  });
304
291
  Image.displayName = 'mpx-image';
305
292
  export default Image;
@@ -40,16 +40,15 @@
40
40
  import { forwardRef, useRef, useState, useContext, useEffect, createElement } from 'react';
41
41
  import { TextInput } from 'react-native';
42
42
  import { warn } from '@mpxjs/utils';
43
- import { useUpdateEffect, useTransformStyle, useLayout, extendObject, isIOS } from './utils';
43
+ import { useUpdateEffect, useTransformStyle, useLayout, extendObject } from './utils';
44
44
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
45
45
  import useNodesRef from './useNodesRef';
46
46
  import { FormContext, KeyboardAvoidContext } from './context';
47
- import Portal from './mpx-portal';
48
- const keyboardTypeMap = {
49
- text: 'default',
47
+ const inputModeMap = {
48
+ text: 'text',
50
49
  number: 'numeric',
51
- idcard: 'default',
52
- digit: isIOS ? 'decimal-pad' : 'numeric'
50
+ idcard: 'text',
51
+ digit: 'decimal'
53
52
  };
54
53
  const Input = forwardRef((props, ref) => {
55
54
  const { style = {}, allowFontScaling = false, type = 'text', value, password, 'placeholder-style': placeholderStyle = {}, disabled, maxlength = 140, 'cursor-spacing': cursorSpacing = 0, 'auto-focus': autoFocus, focus, 'confirm-type': confirmType = 'done', 'confirm-hold': confirmHold = false, cursor, 'cursor-color': cursorColor, 'selection-start': selectionStart = -1, 'selection-end': selectionEnd = -1, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'adjust-position': adjustPosition = true, bindinput, bindfocus, bindblur, bindconfirm, bindselectionchange,
@@ -72,7 +71,7 @@ const Input = forwardRef((props, ref) => {
72
71
  return value + '';
73
72
  return '';
74
73
  };
75
- const keyboardType = keyboardTypeMap[type];
74
+ const inputMode = inputModeMap[type];
76
75
  const defaultValue = parseValue(value);
77
76
  const textAlignVertical = multiline ? 'top' : 'auto';
78
77
  const tmpValue = useRef(defaultValue);
@@ -84,7 +83,7 @@ const Input = forwardRef((props, ref) => {
84
83
  const styleObj = extendObject({ padding: 0, backgroundColor: '#fff' }, style, multiline && autoHeight
85
84
  ? { height: 'auto', minHeight: Math.max(style?.minHeight || 35, contentHeight) }
86
85
  : {});
87
- const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
86
+ const { hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
88
87
  const nodeRef = useRef(null);
89
88
  useNodesRef(props, ref, nodeRef, {
90
89
  style: normalStyle
@@ -252,7 +251,7 @@ const Input = forwardRef((props, ref) => {
252
251
  ref: nodeRef,
253
252
  style: extendObject({}, normalStyle, layoutStyle),
254
253
  allowFontScaling,
255
- keyboardType: keyboardType,
254
+ inputMode: inputMode,
256
255
  secureTextEntry: !!password,
257
256
  defaultValue: defaultValue,
258
257
  value: inputValue,
@@ -290,11 +289,7 @@ const Input = forwardRef((props, ref) => {
290
289
  ], {
291
290
  layoutRef
292
291
  });
293
- const finalComponent = createElement(TextInput, innerProps);
294
- if (hasPositionFixed) {
295
- return createElement(Portal, null, finalComponent);
296
- }
297
- return finalComponent;
292
+ return createElement(TextInput, innerProps);
298
293
  });
299
294
  Input.displayName = 'MpxInput';
300
295
  export default Input;
@@ -8,7 +8,6 @@ import useInnerProps, { getCustomEvent } from './getInnerListeners';
8
8
  import useNodesRef from './useNodesRef';
9
9
  import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils';
10
10
  import { LabelContext } from './context';
11
- import Portal from './mpx-portal';
12
11
  const Label = forwardRef((labelProps, ref) => {
13
12
  const { textProps, innerProps: props = {} } = splitProps(labelProps);
14
13
  const propsRef = useRef({});
@@ -18,7 +17,7 @@ const Label = forwardRef((labelProps, ref) => {
18
17
  flexDirection: 'row'
19
18
  };
20
19
  const styleObj = extendObject({}, defaultStyle, style);
21
- const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
20
+ const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
22
21
  const nodeRef = useRef(null);
23
22
  useNodesRef(props, ref, nodeRef, { style: normalStyle });
24
23
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
@@ -41,16 +40,12 @@ const Label = forwardRef((labelProps, ref) => {
41
40
  }), [], {
42
41
  layoutRef
43
42
  });
44
- const finalComponent = createElement(View, innerProps, createElement(LabelContext.Provider, { value: contextRef }, wrapChildren(props, {
43
+ return createElement(View, innerProps, createElement(LabelContext.Provider, { value: contextRef }, wrapChildren(props, {
45
44
  hasVarDec,
46
45
  varContext: varContextRef.current,
47
46
  textStyle,
48
47
  textProps
49
48
  })));
50
- if (hasPositionFixed) {
51
- return createElement(Portal, null, finalComponent);
52
- }
53
- return finalComponent;
54
49
  });
55
50
  Label.displayName = 'MpxLabel';
56
51
  export default Label;
@@ -7,10 +7,9 @@ import useNodesRef from './useNodesRef';
7
7
  import useInnerProps from './getInnerListeners';
8
8
  import { MovableAreaContext } from './context';
9
9
  import { useTransformStyle, wrapChildren, useLayout, extendObject } from './utils';
10
- import Portal from './mpx-portal';
11
10
  const _MovableArea = forwardRef((props, ref) => {
12
11
  const { style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
13
- const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, hasPositionFixed, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
12
+ const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
14
13
  const movableViewRef = useRef(null);
15
14
  useNodesRef(props, ref, movableViewRef, {
16
15
  style: normalStyle
@@ -21,17 +20,13 @@ const _MovableArea = forwardRef((props, ref) => {
21
20
  }), [normalStyle.width, normalStyle.height]);
22
21
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: movableViewRef });
23
22
  const innerProps = useInnerProps(extendObject({}, props, layoutProps, {
24
- style: extendObject({ height: contextValue.height, width: contextValue.width }, normalStyle, layoutStyle),
23
+ style: extendObject({ height: contextValue.height, width: contextValue.width, overflow: 'hidden' }, normalStyle, layoutStyle),
25
24
  ref: movableViewRef
26
25
  }), [], { layoutRef });
27
- let movableComponent = createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(View, innerProps, wrapChildren(props, {
26
+ return createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(View, innerProps, wrapChildren(props, {
28
27
  hasVarDec,
29
28
  varContext: varContextRef.current
30
29
  })));
31
- if (hasPositionFixed) {
32
- movableComponent = createElement(Portal, null, movableComponent);
33
- }
34
- return movableComponent;
35
30
  });
36
31
  _MovableArea.displayName = 'MpxMovableArea';
37
32
  export default _MovableArea;