@mpxjs/webpack-plugin 2.10.5 → 2.10.6

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 (62) hide show
  1. package/lib/index.js +10 -1
  2. package/lib/json-compiler/helper.js +1 -4
  3. package/lib/platform/template/wx/index.js +21 -1
  4. package/lib/resolver/PackageEntryPlugin.js +3 -1
  5. package/lib/runtime/components/react/dist/mpx-button.jsx +7 -2
  6. package/lib/runtime/components/react/dist/mpx-canvas/Image.js +2 -4
  7. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +20 -17
  8. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +7 -2
  9. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +7 -2
  10. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +7 -2
  11. package/lib/runtime/components/react/dist/mpx-image.jsx +9 -2
  12. package/lib/runtime/components/react/dist/mpx-input.jsx +7 -2
  13. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +1 -1
  14. package/lib/runtime/components/react/dist/mpx-label.jsx +7 -2
  15. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +7 -2
  16. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +76 -42
  17. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +11 -13
  18. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +8 -7
  19. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +26 -8
  20. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +9 -2
  21. package/lib/runtime/components/react/dist/mpx-radio.jsx +7 -2
  22. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +7 -2
  23. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +13 -4
  24. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +11 -9
  25. package/lib/runtime/components/react/dist/mpx-swiper.jsx +82 -36
  26. package/lib/runtime/components/react/dist/mpx-switch.jsx +7 -2
  27. package/lib/runtime/components/react/dist/mpx-text.jsx +7 -2
  28. package/lib/runtime/components/react/dist/mpx-video.jsx +7 -2
  29. package/lib/runtime/components/react/dist/mpx-view.jsx +2 -4
  30. package/lib/runtime/components/react/dist/utils.jsx +2 -2
  31. package/lib/runtime/components/react/mpx-button.tsx +9 -1
  32. package/lib/runtime/components/react/mpx-canvas/Image.ts +4 -4
  33. package/lib/runtime/components/react/mpx-canvas/index.tsx +24 -17
  34. package/lib/runtime/components/react/mpx-checkbox-group.tsx +9 -1
  35. package/lib/runtime/components/react/mpx-checkbox.tsx +9 -1
  36. package/lib/runtime/components/react/mpx-icon/index.tsx +9 -1
  37. package/lib/runtime/components/react/mpx-image.tsx +38 -19
  38. package/lib/runtime/components/react/mpx-input.tsx +10 -1
  39. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +1 -1
  40. package/lib/runtime/components/react/mpx-label.tsx +9 -1
  41. package/lib/runtime/components/react/mpx-movable-area.tsx +7 -1
  42. package/lib/runtime/components/react/mpx-movable-view.tsx +75 -42
  43. package/lib/runtime/components/react/mpx-picker/index.tsx +18 -16
  44. package/lib/runtime/components/react/mpx-picker-view/index.tsx +22 -8
  45. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +34 -30
  46. package/lib/runtime/components/react/mpx-radio-group.tsx +20 -9
  47. package/lib/runtime/components/react/mpx-radio.tsx +9 -1
  48. package/lib/runtime/components/react/mpx-rich-text/index.tsx +10 -2
  49. package/lib/runtime/components/react/mpx-scroll-view.tsx +14 -3
  50. package/lib/runtime/components/react/mpx-swiper-item.tsx +11 -19
  51. package/lib/runtime/components/react/mpx-swiper.tsx +95 -38
  52. package/lib/runtime/components/react/mpx-switch.tsx +10 -2
  53. package/lib/runtime/components/react/mpx-text.tsx +10 -2
  54. package/lib/runtime/components/react/mpx-video.tsx +7 -2
  55. package/lib/runtime/components/react/mpx-view.tsx +8 -4
  56. package/lib/runtime/components/react/utils.tsx +4 -4
  57. package/lib/runtime/components/web/mpx-web-view.vue +1 -1
  58. package/lib/runtime/mpxGlobal.js +1 -0
  59. package/lib/runtime/optionProcessor.d.ts +5 -0
  60. package/lib/template-compiler/bind-this.js +8 -7
  61. package/lib/wxs/pre-loader.js +1 -0
  62. package/package.json +4 -4
package/lib/index.js CHANGED
@@ -17,6 +17,7 @@ const FileSystemInfo = require('webpack/lib/FileSystemInfo')
17
17
  const ImportDependency = require('webpack/lib/dependencies/ImportDependency')
18
18
  const ImportDependencyTemplate = require('./dependencies/ImportDependencyTemplate')
19
19
  const AsyncDependenciesBlock = require('webpack/lib/AsyncDependenciesBlock')
20
+ const ProvidePlugin = require('webpack/lib/ProvidePlugin')
20
21
  const normalize = require('./utils/normalize')
21
22
  const toPosix = require('./utils/to-posix')
22
23
  const addQuery = require('./utils/add-query')
@@ -60,6 +61,7 @@ const templateCompilerPath = normalize.lib('template-compiler/index')
60
61
  const jsonCompilerPath = normalize.lib('json-compiler/index')
61
62
  const jsonThemeCompilerPath = normalize.lib('json-compiler/theme')
62
63
  const jsonPluginCompilerPath = normalize.lib('json-compiler/plugin')
64
+ const mpxGlobalRuntimePath = normalize.lib('runtime/mpxGlobal')
63
65
  const extractorPath = normalize.lib('extractor')
64
66
  const async = require('async')
65
67
  const { parseQuery } = require('loader-utils')
@@ -177,6 +179,7 @@ class MpxWebpackPlugin {
177
179
  options.forceProxyEventRules = options.forceProxyEventRules || {}
178
180
  options.disableRequireAsync = options.disableRequireAsync || false
179
181
  options.miniNpmPackages = options.miniNpmPackages || []
182
+ options.normalNpmPackages = options.normalNpmPackages || []
180
183
  options.fileConditionRules = options.fileConditionRules || {
181
184
  include: () => true
182
185
  }
@@ -325,6 +328,12 @@ class MpxWebpackPlugin {
325
328
  }
326
329
  }
327
330
 
331
+ compiler.options.plugins.push(new ProvidePlugin(
332
+ {
333
+ mpxGlobal: mpxGlobalRuntimePath
334
+ }
335
+ ))
336
+
328
337
  if (!isWeb(this.options.mode) && !isReact(this.options.mode)) {
329
338
  // 强制设置publicPath为'/'
330
339
  if (compiler.options.output.publicPath && compiler.options.output.publicPath !== publicPath) {
@@ -364,7 +373,7 @@ class MpxWebpackPlugin {
364
373
  }
365
374
  const addModePlugin = new AddModePlugin('before-file', this.options.mode, addModeOptions, 'file')
366
375
  const addEnvPlugin = new AddEnvPlugin('before-file', this.options.env, this.options.fileConditionRules, 'file')
367
- const packageEntryPlugin = new PackageEntryPlugin('before-file', this.options.miniNpmPackages, 'file')
376
+ const packageEntryPlugin = new PackageEntryPlugin('before-file', this.options.miniNpmPackages, this.options.normalNpmPackages, 'file')
368
377
  const dynamicPlugin = new DynamicPlugin('result', this.options.dynamicComponentRules)
369
378
 
370
379
  if (Array.isArray(compiler.options.resolve.plugins)) {
@@ -77,12 +77,9 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
77
77
 
78
78
  if (!outputPath) {
79
79
  if (isScript(ext) && resourceName.includes('node_modules') && !isWeb(mode) && !isReact(mode)) {
80
- let root = info.descriptionFileRoot
80
+ const root = info.descriptionFileRoot
81
81
  let name = 'nativeComponent'
82
82
  if (info.descriptionFileData) {
83
- if (info.descriptionFileData.miniprogram) {
84
- root = path.join(root, info.descriptionFileData.miniprogram)
85
- }
86
83
  if (info.descriptionFileData.name) {
87
84
  // 去掉name里面的@符号,因为支付宝不支持文件路径上有@
88
85
  name = info.descriptionFileData.name.replace(/@/g, '')
@@ -43,6 +43,23 @@ module.exports = function getSpec ({ warn, error }) {
43
43
  }
44
44
  }
45
45
 
46
+ function rnAccessibilityRulesHandle ({ name, value }) {
47
+ if (name === 'aria-role') {
48
+ return [
49
+ {
50
+ name: 'accessible',
51
+ value: true
52
+ },
53
+ {
54
+ name: 'accessibilityRole',
55
+ value: value
56
+ }
57
+ ]
58
+ } else {
59
+ return { name, value }
60
+ }
61
+ }
62
+
46
63
  const spec = {
47
64
  supportedModes: ['ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd', 'ios', 'android', 'harmony'],
48
65
  // props预处理
@@ -433,7 +450,10 @@ module.exports = function getSpec ({ warn, error }) {
433
450
  test: /^aria-(role|label)$/,
434
451
  ali () {
435
452
  warn('Ali environment does not support aria-role|label props!')
436
- }
453
+ },
454
+ ios: rnAccessibilityRulesHandle,
455
+ android: rnAccessibilityRulesHandle,
456
+ harmony: rnAccessibilityRulesHandle
437
457
  }
438
458
  ],
439
459
  event: {
@@ -2,10 +2,11 @@ const path = require('path')
2
2
  const toPosix = require('../utils/to-posix')
3
3
 
4
4
  module.exports = class PackageEntryPlugin {
5
- constructor (source, miniNpmPackages, target) {
5
+ constructor (source, miniNpmPackages, normalNpmPackages, target) {
6
6
  this.source = source
7
7
  this.target = target
8
8
  this.miniNpmPackages = miniNpmPackages
9
+ this.normalNpmPackages = normalNpmPackages
9
10
  }
10
11
 
11
12
  /**
@@ -23,6 +24,7 @@ module.exports = class PackageEntryPlugin {
23
24
 
24
25
  let { name, miniprogram } = descriptionFileData
25
26
  if (!miniprogram && this.miniNpmPackages.includes(name)) miniprogram = 'miniprogram_dist'
27
+ if (this.normalNpmPackages.includes(name)) return callback()
26
28
  if (!miniprogram) return callback()
27
29
 
28
30
  let relativePath = path.relative(descriptionFileRoot, resourcePath)
@@ -42,6 +42,7 @@ 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';
45
46
  const LOADING_IMAGE_URI = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAB8hJREFUeJztnVtsFFUch6ltUYrEAi0Qo40xChGM+oAGI0EEKl4QfDVI9AkqqQZ4IVA1RSIvJlwUWwqJUokGKMVYwHJTq4mGuA+SxpJYggJSSgMpVFOtvbh+J84mk+3smXN2znZm2fNLvoQH5uQ/v4+Z2Z3dH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aKVwmJGU56QgREYX7CBHConVvaiRC2RU+MqQPwUxXiAiFH/SRssLozkY94iLtXKxTyRAXeekFNqCQMuiXCBEX/8jc9Mx4KHurz9Hh+yDlIEJEKHyTz1GSGw9SpuxpMCCR0SneKPqtY0BIEXRKhIgj6F4jOx3lUHadz9Gh9DD+oEJEKHyZz1Fy8z+Mn8KPS2Qo/3cVJoSIUHpMIqQ5rZ3MplD6TokQ5f/QxaCQRyVCAt/UjHyca4jXrRKt/83GlBARiq/xkPEn3KOzTtaG8p+FLkfEX7AOtL6bZVhIAbwJ/zgyLkFkP2KOZEwKsTEQKyRi0b39bjMCofhTHjI8n/1uMwI5rvERro2NjY2NjY2NjY2NjY2NjY1+/gNWA2LIOT/TRAAAAABJRU5ErkJggg==';
46
47
  const TypeColorMap = {
47
48
  default: ['#F8F8F8', '#DEDEDE', '35,35,35', '#F7F7F7'],
@@ -167,7 +168,7 @@ const Button = forwardRef((buttonProps, ref) => {
167
168
  const defaultTextStyle = extendObject({}, styles.text, isMiniSize ? styles.textMini : {}, { color: plain ? plainTextColor : normalTextColor });
168
169
  const defaultStyle = extendObject({}, defaultViewStyle, defaultTextStyle);
169
170
  const styleObj = extendObject({}, defaultStyle, style, isHover ? hoverStyle : {});
170
- const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
171
+ const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
171
172
  const nodeRef = useRef(null);
172
173
  useNodesRef(props, ref, nodeRef, { style: normalStyle });
173
174
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
@@ -262,9 +263,13 @@ const Button = forwardRef((buttonProps, ref) => {
262
263
  textStyle,
263
264
  textProps
264
265
  }));
265
- return enableHover
266
+ const finalComponent = enableHover
266
267
  ? createElement(GestureDetector, { gesture: gesture }, baseButton)
267
268
  : baseButton;
269
+ if (hasPositionFixed) {
270
+ return createElement(Portal, null, finalComponent);
271
+ }
272
+ return finalComponent;
268
273
  });
269
274
  Button.displayName = 'MpxButton';
270
275
  export default Button;
@@ -1,4 +1,5 @@
1
1
  import { WEBVIEW_TARGET, registerWebviewProperties } from './utils';
2
+ import { extendObject } from '../utils';
2
3
  const PROPERTIES = {
3
4
  crossOrigin: undefined,
4
5
  height: undefined,
@@ -50,10 +51,7 @@ export class Image {
50
51
  this[key] = value;
51
52
  }
52
53
  }
53
- callbackFn({
54
- ...message.payload,
55
- target: this
56
- });
54
+ callbackFn(extendObject({}, message.payload, { target: this }));
57
55
  }
58
56
  });
59
57
  }
@@ -23,6 +23,7 @@ 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';
26
27
  const stylesheet = StyleSheet.create({
27
28
  container: { overflow: 'hidden', flex: 0 },
28
29
  webview: {
@@ -41,7 +42,7 @@ const _Canvas = forwardRef((props = {}, ref) => {
41
42
  const { style = {}, originWhitelist = ['*'], 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
42
43
  const [isLoaded, setIsLoaded] = useState(false);
43
44
  const nodeRef = useRef(null);
44
- const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(extendObject({}, style, stylesheet.container), {
45
+ const { normalStyle, hasSelfPercent, hasPositionFixed, setWidth, setHeight } = useTransformStyle(extendObject({}, style, stylesheet.container), {
45
46
  enableVar,
46
47
  externalVarContext,
47
48
  parentFontSize,
@@ -110,10 +111,7 @@ const _Canvas = forwardRef((props = {}, ref) => {
110
111
  const postMessage = useCallback(async (message) => {
111
112
  if (!canvasRef.current?.bus)
112
113
  return;
113
- const { type, payload } = await canvasRef.current.bus.post({
114
- id: ID(),
115
- ...message
116
- });
114
+ const { type, payload } = await canvasRef.current.bus.post(extendObject({ id: ID() }, message));
117
115
  switch (type) {
118
116
  case 'error': {
119
117
  const { binderror } = props;
@@ -142,7 +140,7 @@ const _Canvas = forwardRef((props = {}, ref) => {
142
140
  canvasRef.current.listeners.splice(canvasRef.current.listeners.indexOf(listener), 1);
143
141
  };
144
142
  const onMessage = useCallback((e) => {
145
- let data = JSON.parse(e.nativeEvent.data);
143
+ const data = JSON.parse(e.nativeEvent.data);
146
144
  switch (data.type) {
147
145
  case 'error': {
148
146
  const { binderror } = props;
@@ -156,27 +154,27 @@ const _Canvas = forwardRef((props = {}, ref) => {
156
154
  break;
157
155
  }
158
156
  default: {
157
+ const newData = {};
158
+ // createLinearGradient 方法调用需要在 constructors 中需要注册 CanvasGradient
159
+ const constructor = constructors[data.meta.constructor];
159
160
  if (data.payload) {
160
- // createLinearGradient 方法调用需要在 constructors 中需要注册 CanvasGradient
161
- const constructor = constructors[data.meta.constructor];
162
161
  if (constructor) {
163
162
  const { args, payload } = data;
164
163
  // RN 端同步生成一个 CanvasGradient 的实例
165
164
  const object = constructor.constructLocally(canvasRef.current, ...args);
166
- Object.assign(object, payload, {
165
+ extendObject(object, payload, {
167
166
  [WEBVIEW_TARGET]: data.meta.target
168
167
  });
169
- data = {
170
- ...data,
168
+ extendObject(newData, data, {
171
169
  payload: object
172
- };
170
+ });
173
171
  }
174
172
  for (const listener of canvasRef.current.listeners) {
175
- listener(data.payload);
173
+ listener(constructor ? newData.payload : data.payload);
176
174
  }
177
175
  }
178
176
  if (canvasRef.current.bus) {
179
- canvasRef.current.bus.handle(data);
177
+ canvasRef.current.bus.handle(constructor && data.payload ? newData : data);
180
178
  }
181
179
  }
182
180
  }
@@ -192,9 +190,10 @@ const _Canvas = forwardRef((props = {}, ref) => {
192
190
  node: canvasRef.current,
193
191
  context: context2D
194
192
  });
195
- if (__mpx_mode__ !== 'ios') {
193
+ let canvasComponent;
194
+ if (__mpx_mode__ === 'android') {
196
195
  const isAndroid9 = Platform.Version >= 28;
197
- return createElement(View, innerProps, createElement(WebView, {
196
+ canvasComponent = createElement(View, innerProps, createElement(WebView, {
198
197
  ref: (element) => {
199
198
  if (canvasRef.current) {
200
199
  canvasRef.current.webview = element;
@@ -217,7 +216,7 @@ const _Canvas = forwardRef((props = {}, ref) => {
217
216
  allowUniversalAccessFromFileURLs: true
218
217
  }));
219
218
  }
220
- return createElement(View, innerProps, createElement(WebView, {
219
+ canvasComponent = createElement(View, innerProps, createElement(WebView, {
221
220
  ref: (element) => {
222
221
  if (canvasRef.current) {
223
222
  canvasRef.current.webview = element;
@@ -230,6 +229,10 @@ const _Canvas = forwardRef((props = {}, ref) => {
230
229
  onLoad: onLoad,
231
230
  scrollEnabled: false
232
231
  }));
232
+ if (hasPositionFixed) {
233
+ canvasComponent = createElement(Portal, null, canvasComponent);
234
+ }
235
+ return canvasComponent;
233
236
  });
234
237
  _Canvas.displayName = 'mpxCanvas';
235
238
  export default _Canvas;
@@ -8,6 +8,7 @@ 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';
11
12
  const CheckboxGroup = forwardRef((props, ref) => {
12
13
  const propsRef = useRef({});
13
14
  propsRef.current = props;
@@ -23,7 +24,7 @@ const CheckboxGroup = forwardRef((props, ref) => {
23
24
  flexWrap: 'wrap'
24
25
  };
25
26
  const styleObj = extendObject({}, defaultStyle, style);
26
- const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
27
+ const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
27
28
  const nodeRef = useRef(null);
28
29
  useNodesRef(props, ref, nodeRef, { style: normalStyle });
29
30
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
@@ -81,10 +82,14 @@ const CheckboxGroup = forwardRef((props, ref) => {
81
82
  notifyChange
82
83
  };
83
84
  }, []);
84
- return createElement(View, innerProps, createElement(CheckboxGroupContext.Provider, { value: contextValue }, wrapChildren(props, {
85
+ const finalComponent = createElement(View, innerProps, createElement(CheckboxGroupContext.Provider, { value: contextValue }, wrapChildren(props, {
85
86
  hasVarDec,
86
87
  varContext: varContextRef.current
87
88
  })));
89
+ if (hasPositionFixed) {
90
+ return createElement(Portal, null, finalComponent);
91
+ }
92
+ return finalComponent;
88
93
  });
89
94
  CheckboxGroup.displayName = 'MpxCheckboxGroup';
90
95
  export default CheckboxGroup;
@@ -12,6 +12,7 @@ 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';
15
16
  const styles = StyleSheet.create({
16
17
  container: {
17
18
  flexDirection: 'row',
@@ -63,7 +64,7 @@ const Checkbox = forwardRef((checkboxProps, ref) => {
63
64
  bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props));
64
65
  onChange(evt);
65
66
  };
66
- const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
67
+ const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
67
68
  const nodeRef = useRef(null);
68
69
  useNodesRef(props, ref, nodeRef, {
69
70
  style: extendObject({}, defaultStyle, normalStyle),
@@ -114,7 +115,7 @@ const Checkbox = forwardRef((checkboxProps, ref) => {
114
115
  }
115
116
  }
116
117
  }, [checked]);
117
- return createElement(View, innerProps, createElement(View, { style: defaultStyle }, createElement(Icon, {
118
+ const finalComponent = createElement(View, innerProps, createElement(View, { style: defaultStyle }, createElement(Icon, {
118
119
  type: 'success_no_circle',
119
120
  size: 18,
120
121
  color: disabled ? '#ADADAD' : color,
@@ -125,6 +126,10 @@ const Checkbox = forwardRef((checkboxProps, ref) => {
125
126
  textStyle,
126
127
  textProps
127
128
  }));
129
+ if (hasPositionFixed) {
130
+ return createElement(Portal, null, finalComponent);
131
+ }
132
+ return finalComponent;
128
133
  });
129
134
  Checkbox.displayName = 'MpxCheckbox';
130
135
  export default Checkbox;
@@ -17,6 +17,7 @@ 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';
20
21
  const IconTypeMap = new Map([
21
22
  ['success', Success],
22
23
  ['success_no_circle', SuccessNoCircle],
@@ -33,7 +34,7 @@ const Icon = forwardRef((props, ref) => {
33
34
  const source = IconTypeMap.get(type);
34
35
  const defaultStyle = { width: ~~size, height: ~~size };
35
36
  const styleObj = extendObject({}, defaultStyle, style);
36
- const { hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
37
+ const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
37
38
  const nodeRef = useRef(null);
38
39
  useNodesRef(props, ref, nodeRef, { style: normalStyle });
39
40
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
@@ -44,7 +45,11 @@ const Icon = forwardRef((props, ref) => {
44
45
  }), [], {
45
46
  layoutRef
46
47
  });
47
- return createElement(Image, innerProps);
48
+ const finalComponent = createElement(Image, innerProps);
49
+ if (hasPositionFixed) {
50
+ return createElement(Portal, null, finalComponent);
51
+ }
52
+ return finalComponent;
48
53
  });
49
54
  Icon.displayName = 'MpxIcon';
50
55
  export default Icon;
@@ -17,6 +17,7 @@ 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';
20
21
  const DEFAULT_IMAGE_WIDTH = 320;
21
22
  const DEFAULT_IMAGE_HEIGHT = 240;
22
23
  const cropMode = [
@@ -79,7 +80,7 @@ const Image = forwardRef((props, ref) => {
79
80
  setLoaded(true);
80
81
  }
81
82
  };
82
- const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
83
+ const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
83
84
  const { layoutRef, layoutStyle, layoutProps } = useLayout({
84
85
  props,
85
86
  hasSelfPercent,
@@ -255,6 +256,8 @@ const Image = forwardRef((props, ref) => {
255
256
  state.current = {};
256
257
  setLoaded(true);
257
258
  }
259
+ }, () => {
260
+ setLoaded(true);
258
261
  });
259
262
  }
260
263
  }, [src, isSvg, isLayoutMode]);
@@ -286,7 +289,11 @@ const Image = forwardRef((props, ref) => {
286
289
  }, isCropMode ? modeStyle : {})
287
290
  }, isLayoutMode ? {} : innerProps), enableFastImage);
288
291
  const LayoutImage = createElement(View, innerProps, loaded && BaseImage);
289
- return isSvg ? SvgImage : isLayoutMode ? LayoutImage : BaseImage;
292
+ const finalComponent = isSvg ? SvgImage : isLayoutMode ? LayoutImage : BaseImage;
293
+ if (hasPositionFixed) {
294
+ return createElement(Portal, null, finalComponent);
295
+ }
296
+ return finalComponent;
290
297
  });
291
298
  Image.displayName = 'mpx-image';
292
299
  export default Image;
@@ -44,6 +44,7 @@ import { useUpdateEffect, useTransformStyle, useLayout, extendObject, isIOS } fr
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';
47
48
  const keyboardTypeMap = {
48
49
  text: 'default',
49
50
  number: 'numeric',
@@ -83,7 +84,7 @@ const Input = forwardRef((props, ref) => {
83
84
  const styleObj = extendObject({ padding: 0, backgroundColor: '#fff' }, style, multiline && autoHeight
84
85
  ? { height: 'auto', minHeight: Math.max(style?.minHeight || 35, contentHeight) }
85
86
  : {});
86
- const { hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
87
+ const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
87
88
  const nodeRef = useRef(null);
88
89
  useNodesRef(props, ref, nodeRef, {
89
90
  style: normalStyle
@@ -289,7 +290,11 @@ const Input = forwardRef((props, ref) => {
289
290
  ], {
290
291
  layoutRef
291
292
  });
292
- return createElement(TextInput, innerProps);
293
+ const finalComponent = createElement(TextInput, innerProps);
294
+ if (hasPositionFixed) {
295
+ return createElement(Portal, null, finalComponent);
296
+ }
297
+ return finalComponent;
293
298
  });
294
299
  Input.displayName = 'MpxInput';
295
300
  export default Input;
@@ -36,7 +36,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
36
36
  const { ref, cursorSpacing = 0 } = keyboardAvoid.current;
37
37
  setTimeout(() => {
38
38
  ref?.current?.measure((x, y, width, height, pageX, pageY) => {
39
- const aboveOffset = pageY + height - endCoordinates.screenY;
39
+ const aboveOffset = offset.value + pageY + height - endCoordinates.screenY;
40
40
  const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
41
41
  const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing);
42
42
  const value = aboveOffset > 0 ? belowValue : aboveValue;
@@ -8,6 +8,7 @@ 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';
11
12
  const Label = forwardRef((labelProps, ref) => {
12
13
  const { textProps, innerProps: props = {} } = splitProps(labelProps);
13
14
  const propsRef = useRef({});
@@ -17,7 +18,7 @@ const Label = forwardRef((labelProps, ref) => {
17
18
  flexDirection: 'row'
18
19
  };
19
20
  const styleObj = extendObject({}, defaultStyle, style);
20
- const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
21
+ const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
21
22
  const nodeRef = useRef(null);
22
23
  useNodesRef(props, ref, nodeRef, { style: normalStyle });
23
24
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
@@ -40,12 +41,16 @@ const Label = forwardRef((labelProps, ref) => {
40
41
  }), [], {
41
42
  layoutRef
42
43
  });
43
- return createElement(View, innerProps, createElement(LabelContext.Provider, { value: contextRef }, wrapChildren(props, {
44
+ const finalComponent = createElement(View, innerProps, createElement(LabelContext.Provider, { value: contextRef }, wrapChildren(props, {
44
45
  hasVarDec,
45
46
  varContext: varContextRef.current,
46
47
  textStyle,
47
48
  textProps
48
49
  })));
50
+ if (hasPositionFixed) {
51
+ return createElement(Portal, null, finalComponent);
52
+ }
53
+ return finalComponent;
49
54
  });
50
55
  Label.displayName = 'MpxLabel';
51
56
  export default Label;
@@ -7,9 +7,10 @@ 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';
10
11
  const _MovableArea = forwardRef((props, ref) => {
11
12
  const { style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
12
- const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
13
+ const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, hasPositionFixed, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
13
14
  const movableViewRef = useRef(null);
14
15
  useNodesRef(props, ref, movableViewRef, {
15
16
  style: normalStyle
@@ -23,10 +24,14 @@ const _MovableArea = forwardRef((props, ref) => {
23
24
  style: extendObject({ height: contextValue.height, width: contextValue.width, overflow: 'hidden' }, normalStyle, layoutStyle),
24
25
  ref: movableViewRef
25
26
  }), [], { layoutRef });
26
- return createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(View, innerProps, wrapChildren(props, {
27
+ let movableComponent = createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(View, innerProps, wrapChildren(props, {
27
28
  hasVarDec,
28
29
  varContext: varContextRef.current
29
30
  })));
31
+ if (hasPositionFixed) {
32
+ movableComponent = createElement(Portal, null, movableComponent);
33
+ }
34
+ return movableComponent;
30
35
  });
31
36
  _MovableArea.displayName = 'MpxMovableArea';
32
37
  export default _MovableArea;