@mpxjs/webpack-plugin 2.10.14-beta.5 → 2.10.14-beta.7

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 (183) hide show
  1. package/lib/platform/template/wx/component-config/button.js +12 -3
  2. package/lib/runtime/components/react/context.ts +0 -1
  3. package/lib/runtime/components/react/dist/context.d.ts +3 -6
  4. package/lib/runtime/components/react/dist/context.d.ts.map +1 -0
  5. package/lib/runtime/components/react/dist/context.js +1 -1
  6. package/lib/runtime/components/react/dist/event.config.d.ts +1 -0
  7. package/lib/runtime/components/react/dist/event.config.d.ts.map +1 -0
  8. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +1 -0
  9. package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +1 -0
  10. package/lib/runtime/components/react/dist/getInnerListeners.js +35 -21
  11. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +1 -0
  12. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +1 -0
  13. package/lib/runtime/components/react/dist/mpx-async-suspense.jsx +2 -2
  14. package/lib/runtime/components/react/dist/mpx-button.d.ts +1 -0
  15. package/lib/runtime/components/react/dist/mpx-button.d.ts.map +1 -0
  16. package/lib/runtime/components/react/dist/mpx-camera.d.ts +27 -0
  17. package/lib/runtime/components/react/dist/mpx-camera.d.ts.map +1 -0
  18. package/lib/runtime/components/react/dist/mpx-camera.jsx +197 -0
  19. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +1 -0
  20. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +1 -0
  21. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +1 -0
  22. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +1 -0
  23. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +1 -0
  24. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +1 -0
  25. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +1 -0
  26. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +1 -0
  27. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +1 -0
  28. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +1 -0
  29. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +1 -0
  30. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +1 -0
  31. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +1 -0
  32. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +1 -0
  33. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +1 -0
  34. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +1 -0
  35. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +1 -0
  36. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +1 -0
  37. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +1 -0
  38. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +1 -0
  39. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +1 -0
  40. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +1 -0
  41. package/lib/runtime/components/react/dist/mpx-form.d.ts +1 -0
  42. package/lib/runtime/components/react/dist/mpx-form.d.ts.map +1 -0
  43. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +1 -0
  44. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +1 -0
  45. package/lib/runtime/components/react/dist/mpx-image.d.ts +1 -0
  46. package/lib/runtime/components/react/dist/mpx-image.d.ts.map +1 -0
  47. package/lib/runtime/components/react/dist/mpx-image.jsx +81 -37
  48. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +1 -0
  49. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +1 -0
  50. package/lib/runtime/components/react/dist/mpx-input.d.ts +2 -7
  51. package/lib/runtime/components/react/dist/mpx-input.d.ts.map +1 -0
  52. package/lib/runtime/components/react/dist/mpx-input.jsx +19 -12
  53. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +1 -0
  54. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +1 -0
  55. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +15 -22
  56. package/lib/runtime/components/react/dist/mpx-label.d.ts +1 -0
  57. package/lib/runtime/components/react/dist/mpx-label.d.ts.map +1 -0
  58. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +1 -0
  59. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +1 -0
  60. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +5 -2
  61. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +1 -0
  62. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +102 -34
  63. package/lib/runtime/components/react/dist/mpx-nav.d.ts +9 -0
  64. package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +1 -0
  65. package/lib/runtime/components/react/dist/mpx-nav.jsx +132 -0
  66. package/lib/runtime/components/react/dist/mpx-navigator.d.ts +1 -0
  67. package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +1 -0
  68. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +1 -0
  69. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +1 -0
  70. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +1 -0
  71. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +1 -0
  72. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +1 -0
  73. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +1 -0
  74. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +1 -0
  75. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +1 -0
  76. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +1 -0
  77. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +1 -0
  78. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +1 -0
  79. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +1 -0
  80. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +1 -0
  81. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +1 -0
  82. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +1 -0
  83. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +1 -0
  84. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +1 -0
  85. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +1 -0
  86. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +2 -0
  87. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +1 -0
  88. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +4 -3
  89. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +1 -0
  90. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +1 -0
  91. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +2 -0
  92. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +1 -0
  93. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +15 -21
  94. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +1 -0
  95. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +1 -0
  96. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +8 -11
  97. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +14 -0
  98. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +1 -0
  99. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +20 -0
  100. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +1 -0
  101. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +1 -0
  102. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +1 -0
  103. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +1 -0
  104. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +1 -0
  105. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +1 -0
  106. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +1 -0
  107. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +1 -0
  108. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +1 -0
  109. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +1 -0
  110. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +1 -0
  111. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +1 -0
  112. package/lib/runtime/components/react/dist/mpx-portal/index.jsx +5 -1
  113. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +1 -0
  114. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +1 -0
  115. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +1 -0
  116. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +1 -0
  117. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +3 -5
  118. package/lib/runtime/components/react/dist/mpx-progress.d.ts +24 -0
  119. package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +1 -0
  120. package/lib/runtime/components/react/dist/mpx-progress.jsx +163 -0
  121. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +1 -0
  122. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +1 -0
  123. package/lib/runtime/components/react/dist/mpx-radio.d.ts +1 -0
  124. package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +1 -0
  125. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +1 -0
  126. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +1 -0
  127. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +1 -0
  128. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +1 -0
  129. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +1 -0
  130. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +1 -0
  131. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +1 -0
  132. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +1 -0
  133. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +69 -51
  134. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +1 -0
  135. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +1 -0
  136. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +1 -0
  137. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +1 -0
  138. package/lib/runtime/components/react/dist/mpx-slider.d.ts +31 -0
  139. package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +1 -0
  140. package/lib/runtime/components/react/dist/mpx-slider.jsx +321 -0
  141. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +1 -0
  142. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +1 -0
  143. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +1 -0
  144. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +1 -0
  145. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +1 -0
  146. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +1 -0
  147. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -0
  148. package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +1 -0
  149. package/lib/runtime/components/react/dist/mpx-swiper.jsx +9 -16
  150. package/lib/runtime/components/react/dist/mpx-switch.d.ts +1 -0
  151. package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +1 -0
  152. package/lib/runtime/components/react/dist/mpx-text.d.ts +3 -1
  153. package/lib/runtime/components/react/dist/mpx-text.d.ts.map +1 -0
  154. package/lib/runtime/components/react/dist/mpx-text.jsx +33 -5
  155. package/lib/runtime/components/react/dist/mpx-textarea.d.ts +1 -0
  156. package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +1 -0
  157. package/lib/runtime/components/react/dist/mpx-video.d.ts +1 -0
  158. package/lib/runtime/components/react/dist/mpx-video.d.ts.map +1 -0
  159. package/lib/runtime/components/react/dist/mpx-view.d.ts +1 -0
  160. package/lib/runtime/components/react/dist/mpx-view.d.ts.map +1 -0
  161. package/lib/runtime/components/react/dist/mpx-view.jsx +1 -1
  162. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +1 -0
  163. package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +1 -0
  164. package/lib/runtime/components/react/dist/mpx-web-view.jsx +21 -2
  165. package/lib/runtime/components/react/dist/parser.d.ts +1 -0
  166. package/lib/runtime/components/react/dist/parser.d.ts.map +1 -0
  167. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +1 -0
  168. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +1 -0
  169. package/lib/runtime/components/react/dist/useNodesRef.d.ts +1 -0
  170. package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +1 -0
  171. package/lib/runtime/components/react/dist/utils.d.ts +1 -0
  172. package/lib/runtime/components/react/dist/utils.d.ts.map +1 -0
  173. package/lib/runtime/components/react/dist/utils.jsx +16 -6
  174. package/lib/runtime/components/react/mpx-input.tsx +1 -9
  175. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +15 -13
  176. package/lib/runtime/components/react/nav.tsx +67 -76
  177. package/package.json +1 -1
  178. package/lib/runtime/components/react/dist/mpx-nav-container.d.ts +0 -9
  179. package/lib/runtime/components/react/dist/mpx-nav-container.jsx +0 -23
  180. package/lib/runtime/components/react/dist/nav.d.ts +0 -11
  181. package/lib/runtime/components/react/dist/nav.jsx +0 -141
  182. package/lib/runtime/components/react/dist/useNavShared.d.ts +0 -2
  183. package/lib/runtime/components/react/dist/useNavShared.js +0 -6
@@ -120,8 +120,6 @@ const SwiperWrapper = forwardRef((props, ref) => {
120
120
  const strVelocity = 'velocity' + dir.toUpperCase();
121
121
  // 标识手指触摸和抬起, 起点在onBegin
122
122
  const touchfinish = useSharedValue(true);
123
- // 记录onUpdate时的方向,用于进行onFinalize中的值修正
124
- const preUpdateTransDir = useSharedValue(0);
125
123
  // 记录上一帧的绝对定位坐标
126
124
  const preAbsolutePos = useSharedValue(0);
127
125
  // 记录从onBegin 到 onTouchesUp 时移动的距离
@@ -327,9 +325,11 @@ const SwiperWrapper = forwardRef((props, ref) => {
327
325
  resumeLoop
328
326
  };
329
327
  }, []);
330
- function handleSwiperChange(current) {
331
- const eventData = getCustomEvent('change', {}, { detail: { current, source: 'touch' }, layoutRef: layoutRef });
332
- bindchange && bindchange(eventData);
328
+ function handleSwiperChange(current, pCurrent) {
329
+ if (pCurrent !== currentIndex.value) {
330
+ const eventData = getCustomEvent('change', {}, { detail: { current, source: 'touch' }, layoutRef: layoutRef });
331
+ bindchange && bindchange(eventData);
332
+ }
333
333
  }
334
334
  const runOnJSCallbackRef = useRef({
335
335
  loop,
@@ -379,7 +379,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
379
379
  // 1. 用户在当前页切换选中项,动画;用户携带选中index打开到swiper页直接选中不走动画
380
380
  useAnimatedReaction(() => currentIndex.value, (newIndex, preIndex) => {
381
381
  // 这里必须传递函数名, 直接写()=> {}形式会报 访问了未sharedValue信息
382
- if (newIndex !== preIndex && preIndex !== null && preIndex !== undefined && bindchange) {
382
+ if (newIndex !== preIndex && bindchange) {
383
383
  runOnJS(runOnJSCallback)('handleSwiperChange', newIndex, propCurrent);
384
384
  }
385
385
  });
@@ -411,9 +411,9 @@ const SwiperWrapper = forwardRef((props, ref) => {
411
411
  }
412
412
  }, [children.length]);
413
413
  useEffect(() => {
414
- // 1. 如果用户在touch的过程中, 外部更新了current以内部为准(小程序表现)
414
+ // 1. 如果用户在touch的过程中, 外部更新了current以外部为准(小程序表现)
415
415
  // 2. 手指滑动过程中更新索引,外部会把current再传入进来,导致offset直接更新,增加判断不同才更新
416
- if (propCurrent !== currentIndex.value && touchfinish.value) {
416
+ if (propCurrent !== currentIndex.value) {
417
417
  updateCurrent(propCurrent, step.value);
418
418
  }
419
419
  }, [propCurrent]);
@@ -662,7 +662,6 @@ const SwiperWrapper = forwardRef((props, ref) => {
662
662
  translation: moveDistance,
663
663
  transdir: moveDistance
664
664
  };
665
- preUpdateTransDir.value = moveDistance;
666
665
  // 1. 支持滑动中超出一半更新索引的能力:只更新索引并不会影响onFinalize依据当前offset计算的索引
667
666
  const { half } = computeHalf(eventData);
668
667
  if (childrenLength.value > 1 && half) {
@@ -703,17 +702,11 @@ const SwiperWrapper = forwardRef((props, ref) => {
703
702
  if (touchfinish.value)
704
703
  return;
705
704
  touchfinish.value = true;
706
- /**
707
- * 安卓修正
708
- * 问题:部分安卓机型onFinalize中拿到的absoluteX 有问题
709
- * 案例:比如手指从右向左滑的时候,onUpdate拿到的是241.64346313476562, 而onFinalize中拿到的是241.81817626953125,理论上onFinalize中应该比onUpdate小才对吧
710
- * 解决方式:修正
711
- */
712
705
  // 触发过onUpdate正常情况下e[strAbso] - preAbsolutePos.value=0; 未触发过onUpdate的情况下e[strAbso] - preAbsolutePos.value 不为0
713
706
  const moveDistance = e[strAbso] - preAbsolutePos.value;
714
707
  const eventData = {
715
708
  translation: moveDistance,
716
- transdir: Math.abs(moveDistance) > 1 ? moveDistance : preUpdateTransDir.value
709
+ transdir: moveDistance !== 0 ? moveDistance : e[strAbso] - moveTranstion.value
717
710
  };
718
711
  // 1. 只有一个元素:循环 和 非循环状态,都走回弹效果
719
712
  if (childrenLength.value === 1) {
@@ -24,3 +24,4 @@ interface _SwitchProps extends SwitchProps {
24
24
  }
25
25
  declare const _Switch: import("react").ForwardRefExoticComponent<_SwitchProps & import("react").RefAttributes<HandlerRef<Switch, _SwitchProps>>>;
26
26
  export default _Switch;
27
+ //# sourceMappingURL=mpx-switch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-switch.d.ts","sourceRoot":"","sources":["../mpx-switch.tsx"],"names":[],"mappings":";AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAGnF,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAQvD,UAAU,YAAa,SAAQ,WAAW;IACxC,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAA;IAC3B,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5C,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;IACxE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;CAC1E;AAED,QAAA,MAAM,OAAO,2HA0IX,CAAA;AAIF,eAAe,OAAO,CAAA"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * ✔ selectable
3
3
  * ✘ space
4
- * decode
4
+ * decode
5
5
  */
6
6
  import { Text, TextStyle, TextProps } from 'react-native';
7
7
  import { ReactNode } from 'react';
@@ -16,6 +16,8 @@ interface _TextProps extends TextProps {
16
16
  'parent-font-size'?: number;
17
17
  'parent-width'?: number;
18
18
  'parent-height'?: number;
19
+ decode?: boolean;
19
20
  }
20
21
  declare const _Text: import("react").ForwardRefExoticComponent<_TextProps & import("react").RefAttributes<HandlerRef<Text, _TextProps>>>;
21
22
  export default _Text;
23
+ //# sourceMappingURL=mpx-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-text.d.ts","sourceRoot":"","sources":["../mpx-text.tsx"],"names":[],"mappings":"AACA;;;;GAIG;AACH,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAsB,SAAS,EAAgC,MAAM,OAAO,CAAA;AAGnF,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AA6BvD,UAAU,UAAW,SAAQ,SAAS;IACpC,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5C,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,QAAA,MAAM,KAAK,qHAkET,CAAA;AAIF,eAAe,KAAK,CAAA"}
@@ -1,16 +1,40 @@
1
1
  /**
2
2
  * ✔ selectable
3
3
  * ✘ space
4
- * decode
4
+ * decode
5
5
  */
6
6
  import { Text } from 'react-native';
7
- import { useRef, forwardRef, createElement } from 'react';
7
+ import { useRef, forwardRef, createElement, Children } from 'react';
8
8
  import Portal from './mpx-portal';
9
9
  import useInnerProps from './getInnerListeners';
10
10
  import useNodesRef from './useNodesRef'; // 引入辅助函数
11
11
  import { useTransformStyle, wrapChildren, extendObject } from './utils';
12
+ const decodeMap = {
13
+ '&lt;': '<',
14
+ '&gt;': '>',
15
+ '&quot;': '"',
16
+ '&amp;': '&',
17
+ '&#39;': '\'',
18
+ '&nbsp;': ' '
19
+ };
20
+ const encodedRe = /&(?:lt|gt|quot|amp|#39|nbsp);/g;
21
+ function decode(value) {
22
+ if (value != null) {
23
+ return value.replace(encodedRe, function (match) {
24
+ return decodeMap[match];
25
+ });
26
+ }
27
+ }
28
+ function getDecodedChildren(children) {
29
+ return Children.map(children, (child) => {
30
+ if (typeof child === 'string') {
31
+ return decode(child);
32
+ }
33
+ return child;
34
+ });
35
+ }
12
36
  const _Text = forwardRef((props, ref) => {
13
- const { style = {}, allowFontScaling = false, selectable, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'user-select': userSelect, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
37
+ const { style = {}, allowFontScaling = false, selectable, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'user-select': userSelect, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, decode } = props;
14
38
  const { normalStyle, hasVarDec, varContextRef, hasPositionFixed } = useTransformStyle(style, {
15
39
  enableVar,
16
40
  externalVarContext,
@@ -28,9 +52,13 @@ const _Text = forwardRef((props, ref) => {
28
52
  selectable: !!selectable || !!userSelect,
29
53
  allowFontScaling
30
54
  }), [
31
- 'user-select'
55
+ 'user-select',
56
+ 'decode'
32
57
  ]);
33
- let finalComponent = createElement(Text, innerProps, wrapChildren(props, {
58
+ const children = decode ? getDecodedChildren(props.children) : props.children;
59
+ let finalComponent = createElement(Text, innerProps, wrapChildren(extendObject({}, props, {
60
+ children
61
+ }), {
34
62
  hasVarDec,
35
63
  varContext: varContextRef.current
36
64
  }));
@@ -5,3 +5,4 @@ import { HandlerRef } from './useNodesRef';
5
5
  export type TextareProps = Omit<InputProps & PrivateInputProps, 'type' | 'password' | 'multiline' | 'confirm-hold'>;
6
6
  declare const Textarea: import("react").ForwardRefExoticComponent<TextareProps & import("react").RefAttributes<HandlerRef<TextInput, TextareProps>>>;
7
7
  export default Textarea;
8
+ //# sourceMappingURL=mpx-textarea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-textarea.d.ts","sourceRoot":"","sources":["../mpx-textarea.tsx"],"names":[],"mappings":";AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,UAAU,GAAG,iBAAiB,EAC9B,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,cAAc,CACnD,CAAA;AAKD,QAAA,MAAM,QAAQ,8HA+Bb,CAAA;AAID,eAAe,QAAQ,CAAA"}
@@ -99,3 +99,4 @@ interface VideoProps {
99
99
  }
100
100
  declare const MpxVideo: import("react").ForwardRefExoticComponent<VideoProps & import("react").RefAttributes<HandlerRef<View, VideoProps>>>;
101
101
  export default MpxVideo;
102
+ //# sourceMappingURL=mpx-video.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-video.d.ts","sourceRoot":"","sources":["../mpx-video.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;;AAIH,OAAO,EAAc,IAAI,EAAY,SAAS,EAAE,MAAM,cAAc,CAAA;AAQpE,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAGvD,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,OAAO,C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AW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAA;IAClD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAA;IAChD,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAA;IACzD,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAA;IACzD,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAA;CACxD;AAmBD,QAAA,MAAM,QAAQ,qHAuQZ,CAAA;AAEF,eAAe,QAAQ,CAAA"}
@@ -32,3 +32,4 @@ export interface _ViewProps extends ViewProps {
32
32
  }
33
33
  declare const _View: import("react").ForwardRefExoticComponent<_ViewProps & import("react").RefAttributes<HandlerRef<View, _ViewProps>>>;
34
34
  export default _View;
35
+ //# sourceMappingURL=mpx-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-view.d.ts","sourceRoot":"","sources":["../mpx-view.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAAa,oBAAoB,EAAE,SAAS,EAAoD,MAAM,cAAc,CAAA;AACjI,OAAO,EAA2C,SAAS,EAAsB,MAAM,OAAO,CAAA;AAI9F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAOvD,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,KAAK,CAAC,EAAE,iBAAiB,CAAA;IACzB,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB,QAAQ,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAA;IAClC,aAAa,CAAC,EAAE,iBAAiB,CAAA;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5C,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;IAC5E,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;IAC3E,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;IAC1E,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;IAC/E,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;CACjF;AAsoBD,QAAA,MAAM,KAAK,qHAiIT,CAAA;AAIF,eAAe,KAAK,CAAA"}
@@ -398,7 +398,7 @@ function parseLinearGradient(text) {
398
398
  });
399
399
  }
400
400
  function parseBgImage(text) {
401
- if (!text)
401
+ if (!text || text === 'none')
402
402
  return {};
403
403
  const src = parseUrl(text);
404
404
  if (src)
@@ -20,3 +20,4 @@ interface WebViewProps {
20
20
  }
21
21
  declare const _WebView: import("react").ForwardRefExoticComponent<Omit<WebViewProps, "ref"> & import("react").RefAttributes<HandlerRef<WebView<{}>, WebViewProps>>>;
22
22
  export default _WebView;
23
+ //# sourceMappingURL=mpx-web-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-web-view.d.ts","sourceRoot":"","sources":["../mpx-web-view.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAMvD,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE;QACN,IAAI,EAAE,GAAG,EAAE,CAAA;KACZ,CAAA;CACF,CAAA;AAED,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE;QACN,GAAG,CAAC,EAAE,MAAM,CAAA;KACb,CAAA;CACF,CAAA;AAED,UAAU,YAAY;IACpB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAA;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAA;IAC/C,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAA;IAChD,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CACjB;AAgDD,QAAA,MAAM,QAAQ,6IA0RZ,CAAA;AAIF,eAAe,QAAQ,CAAA"}
@@ -80,9 +80,25 @@ const _WebView = forwardRef((props, ref) => {
80
80
  useNodesRef(props, ref, webViewRef, {
81
81
  style: defaultWebViewStyle
82
82
  });
83
+ const hostValidate = (url) => {
84
+ const host = url && new URL(url).host;
85
+ const hostWhitelists = mpx.config.rnConfig?.webviewConfig?.hostWhitelists || [];
86
+ if (hostWhitelists.length) {
87
+ return hostWhitelists.some((item) => {
88
+ return host.endsWith(item);
89
+ });
90
+ }
91
+ else {
92
+ return true;
93
+ }
94
+ };
83
95
  if (!src) {
84
96
  return null;
85
97
  }
98
+ if (!hostValidate(src)) {
99
+ console.error('访问页面域名不符合domainWhiteLists白名单配置,请确认是否正确配置该域名白名单');
100
+ return null;
101
+ }
86
102
  const _reload = function () {
87
103
  if (__mpx_mode__ !== 'ios') {
88
104
  fristLoaded.current = false; // 安卓需要重新设置
@@ -133,6 +149,9 @@ const _WebView = forwardRef((props, ref) => {
133
149
  }
134
150
  };
135
151
  const _message = function (res) {
152
+ if (!hostValidate(res.nativeEvent?.url)) {
153
+ return;
154
+ }
136
155
  let data = {};
137
156
  let asyncCallback;
138
157
  const navObj = promisify({ redirectTo, navigateTo, navigateBack, reLaunch, switchTab });
@@ -157,7 +176,7 @@ const _WebView = forwardRef((props, ref) => {
157
176
  }
158
177
  break;
159
178
  case 'postMessage':
160
- bindmessage && bindmessage(getCustomEvent('messsage', {}, {
179
+ bindmessage && bindmessage(getCustomEvent('message', {}, {
161
180
  detail: {
162
181
  data: params[0]?.data
163
182
  }
@@ -184,7 +203,7 @@ const _WebView = forwardRef((props, ref) => {
184
203
  break;
185
204
  default:
186
205
  if (type) {
187
- const implement = mpx.config.webviewConfig.apiImplementations && mpx.config.webviewConfig.apiImplementations[type];
206
+ const implement = mpx.config.rnConfig.webviewConfig && mpx.config.rnConfig.webviewConfig.apiImplementations && mpx.config.rnConfig.webviewConfig.apiImplementations[type];
188
207
  if (isFunction(implement)) {
189
208
  asyncCallback = Promise.resolve(implement(...params));
190
209
  }
@@ -37,3 +37,4 @@ export declare class ReplaceSource {
37
37
  source(): string;
38
38
  }
39
39
  export {};
40
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../parser.ts"],"names":[],"mappings":"AAAA,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,GAAG,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9,4 @@ export type HandlerRef<T, P> = {
9
9
  };
10
10
  export default function useNodesRef<T, P>(props: P, ref: ForwardedRef<HandlerRef<T, P>>, nodeRef: RefObject<T>, instance?: Obj): void;
11
11
  export {};
12
+ //# sourceMappingURL=useNodesRef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNodesRef.d.ts","sourceRoot":"","sources":["../useNodesRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAE5E,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAE9B,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI;IAC7B,eAAe,IAAI;QACjB,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;QACpB,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;QACtB,QAAQ,EAAE,GAAG,CAAA;KACd,CAAA;CACF,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,EAAE,CAAC,EAAG,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,GAAC,GAAQ,QAejI"}
@@ -120,3 +120,4 @@ export declare function useHover({ enableHover, hoverStartTime, hoverStayTime, d
120
120
  };
121
121
  export declare function useRunOnJSCallback(callbackMapRef: MutableRefObject<Record<string, AnyFunc>>): (key: string, ...args: any) => any;
122
122
  export {};
123
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../utils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA2C,SAAS,EAAE,YAAY,EAAwC,QAAQ,EAAE,cAAc,EAAyC,gBAAgB,EAAE,MAAM,OAAO,CAAA;AACjN,OAAO,EA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IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE;;;;;;EA4D9K;AAED,wBAAgB,kBAAkB,CAAE,cAAc,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,SAClD,MAAM,WAAW,GAAG,SAa9D"}
@@ -169,24 +169,34 @@ function transformPercent(styleObj, percentKeyPaths, percentConfig) {
169
169
  function resolveVar(input, varContext) {
170
170
  const parsed = parseFunc(input, 'var');
171
171
  const replaced = new ReplaceSource(input);
172
- parsed.forEach(({ start, end, args }) => {
172
+ for (const { start, end, args } of parsed) {
173
173
  const varName = args[0];
174
- const fallback = args[1] || '';
174
+ const fallback = args[1];
175
175
  let varValue = hasOwn(varContext, varName) ? varContext[varName] : fallback;
176
+ if (varValue === undefined)
177
+ return;
176
178
  if (varUseRegExp.test(varValue)) {
177
- varValue = '' + resolveVar(varValue, varContext);
179
+ varValue = resolveVar(varValue, varContext);
180
+ if (varValue === undefined)
181
+ return;
178
182
  }
179
183
  else {
180
- varValue = '' + global.__formatValue(varValue);
184
+ varValue = global.__formatValue(varValue);
181
185
  }
182
186
  replaced.replace(start, end - 1, varValue);
183
- });
187
+ }
184
188
  return global.__formatValue(replaced.source());
185
189
  }
186
190
  function transformVar(styleObj, varKeyPaths, varContext, visitOther) {
187
191
  varKeyPaths.forEach((varKeyPath) => {
188
192
  setStyle(styleObj, varKeyPath, ({ target, key, value }) => {
189
- target[key] = resolveVar(value, varContext);
193
+ const resolved = resolveVar(value, varContext);
194
+ if (resolved === undefined) {
195
+ delete target[key];
196
+ error(`Can not resolve css var at ${varKeyPath.join('.')}:${value}.`);
197
+ return;
198
+ }
199
+ target[key] = resolved;
190
200
  visitOther({ target, key, value: target[key], keyPath: varKeyPath });
191
201
  });
192
202
  });
@@ -102,13 +102,6 @@ export interface InputProps {
102
102
  'parent-width'?: number
103
103
  'parent-height'?: number
104
104
  'adjust-position': boolean,
105
- /**
106
- * @default true
107
- * @platform android
108
- *
109
- * adnroid 是否开启原生键盘遮挡
110
- */
111
- 'enable-native-keyboard-avoiding'?: boolean,
112
105
  bindinput?: (evt: NativeSyntheticEvent<TextInputTextInputEventData> | unknown) => void
113
106
  bindfocus?: (evt: NativeSyntheticEvent<TextInputFocusEventData> | unknown) => void
114
107
  bindblur?: (evt: NativeSyntheticEvent<TextInputFocusEventData> | unknown) => void
@@ -157,7 +150,6 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
157
150
  'parent-width': parentWidth,
158
151
  'parent-height': parentHeight,
159
152
  'adjust-position': adjustPosition = true,
160
- 'enable-native-keyboard-avoiding': enableNativeKeyboardAvoiding = true,
161
153
  bindinput,
162
154
  bindfocus,
163
155
  bindblur,
@@ -289,7 +281,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
289
281
 
290
282
  const setKeyboardAvoidContext = () => {
291
283
  if (keyboardAvoid) {
292
- keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition, enableNativeKeyboardAvoiding }
284
+ keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition }
293
285
  }
294
286
  }
295
287
 
@@ -25,7 +25,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
25
25
  const timerRef = useRef<NodeJS.Timeout | null>(null)
26
26
 
27
27
  const animatedStyle = useAnimatedStyle(() => ({
28
- // translate/position top可能会导致地步渲染区域缺失
28
+ // translate/position top可能会导致底部渲染区域缺失
29
29
  marginTop: -offset.value,
30
30
  flexBasis: basic.value as DimensionValue
31
31
  }))
@@ -73,26 +73,27 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
73
73
  }
74
74
 
75
75
  const { endCoordinates } = evt
76
- const { ref, cursorSpacing = 0, adjustPosition, onKeyboardShow, enableNativeKeyboardAvoiding } = keyboardAvoid.current
76
+ const { ref, cursorSpacing = 0, adjustPosition, onKeyboardShow } = keyboardAvoid.current
77
77
  keyboardAvoid.current.keyboardHeight = endCoordinates.height
78
78
  onKeyboardShow?.()
79
79
  if (adjustPosition) {
80
- timerRef.current = setTimeout(() => {
80
+ // 默认沿用旧版本逻辑,在 android 原生关闭键盘避让的情况下应该将该配置设置为 false,走 mpx 的键盘避让逻辑,否则bundle内的所有input都会无法避让键盘
81
+ const enableNativeKeyboardAvoiding = mpxGlobal?.__mpx?.config?.rnConfig?.enableNativeKeyboardAvoiding ?? true
82
+ const callback = () => {
81
83
  ref?.current?.measure((x: number, y: number, width: number, height: number, pageX: number, pageY: number) => {
82
84
  function calculateOffset() {
83
85
  // enableNativeKeyboardAvoding 默认开启
84
86
  if (enableNativeKeyboardAvoiding && isAndroid) {
85
- const aboveOffset = pageY + height - endCoordinates.screenY
86
- const belowOffset = endCoordinates.height - aboveOffset
87
- const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing
88
- const belowValue = Math.min(belowOffset, cursorSpacing)
89
- return aboveOffset > 0 ? belowValue : aboveValue
87
+ const aboveOffset = offset.value + pageY + height - endCoordinates.screenY;
88
+ const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
89
+ const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing);
90
+ return aboveOffset > 0 ? belowValue : aboveValue;
90
91
  }
91
92
 
92
- const aboveOffset = offset.value + pageY + height - endCoordinates.screenY
93
- const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing
94
- const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing)
95
- return aboveOffset > 0 ? belowValue : aboveValue
93
+ const aboveOffset = offset.value + pageY + height - endCoordinates.screenY;
94
+ const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
95
+ const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing);
96
+ return aboveOffset > 0 ? belowValue : aboveValue;
96
97
  }
97
98
 
98
99
  cancelAnimation(offset)
@@ -103,7 +104,8 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
103
104
  }
104
105
  })
105
106
  })
106
- })
107
+ };
108
+ (isIOS ? () => (timerRef.current = setTimeout(callback)) : callback)();
107
109
  }
108
110
  }
109
111
 
@@ -84,89 +84,80 @@ export interface MpxNavProps {
84
84
  navigation: any
85
85
  }
86
86
 
87
- export interface MpxNavFactorOptions {
88
- Mpx: any
89
- }
90
-
91
87
  const BACK_ICON =
92
88
  'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABICAYAAACqT5alAAAA2UlEQVR4nO3bMQrCUBRE0Yla6AYEN2nnBrTL+izcitW3MRDkEUWSvPzJvfCqgMwhZbAppWhNbbIHzB1g9wATERFRVyvpkj1irlpJ5X326D7WHh1hbdFD2CLpLmmftm7kfsEe09aNHFiBrT+wAlt/YAW2/sAKbP2BFdj6Ayuwy+ufz6XPL893krZ//O6iu2n4LT8kndLWTRTo4EC7BDo40C6BDg60S6CDA+0S6OBAuwQ6uNWiD2nrJmoIfU7cNWkR2hbb1UfbY7uuWhGWiIg+a/iHuHmA3QPs3gu4JW9Gan+OJAAAAABJRU5ErkJggg=='
93
89
 
94
- function createMpxNav(options: MpxNavFactorOptions) {
95
- const { Mpx } = options
96
- const innerNav = memo(({ pageConfig, navigation }: MpxNavProps) => {
97
- const [innerPageConfig, setPageConfig] = useState<PageConfig>(pageConfig || {})
98
- const [customNav] = useNavShared()
99
- const safeAreaTop = useSafeAreaInsets()?.top || 0
100
-
101
- navigation.setPageConfig = (config: PageConfig) => {
102
- setPageConfig(Object.assign({}, innerPageConfig, config))
103
- }
104
- const isCustom = innerPageConfig.navigationStyle === 'custom'
105
- const navigationBarTextStyle = useMemo(() => validBarTextStyle(innerPageConfig.navigationBarTextStyle), [innerPageConfig.navigationBarTextStyle])
106
- // 状态栏的颜色
107
- const statusBarElement = (
108
- <StatusBar
109
- translucent
110
- backgroundColor='transparent'
111
- barStyle={navigationBarTextStyle === NavColor.White ? 'light-content' : 'dark-content'}></StatusBar>
112
- )
90
+ const MpxNav = memo(({ pageConfig, navigation }: MpxNavProps) => {
91
+ const [innerPageConfig, setPageConfig] = useState<PageConfig>(pageConfig || {})
92
+ const [customNav] = useNavShared()
93
+ const safeAreaTop = useSafeAreaInsets()?.top || 0
113
94
 
114
- if (isCustom)
115
- return (
116
- <>
117
- {statusBarElement}
118
- {customNav}
119
- </>
120
- )
121
- // 假设是栈导航,获取栈的长度
122
- const stackLength = navigation.getState()?.routes?.length
123
- const onStackTopBack = Mpx.config?.rnConfig?.onStackTopBack
124
- const isHandleStackTopBack = typeof onStackTopBack === 'function'
125
-
126
- // 回退按钮与图标
127
- // prettier-ignore
128
- const backElement = stackLength > 1 || isHandleStackTopBack
129
- ? (
130
- <TouchableWithoutFeedback
131
- onPress={() => {
132
- if (stackLength <= 1 && isHandleStackTopBack) {
133
- onStackTopBack()
134
- return
135
- }
136
- navigation.goBack()
137
- }}>
138
- <View style={[styles.backButton]}>
139
- <Image style={[styles.backButtonImage, { tintColor: navigationBarTextStyle }]} source={{ uri: BACK_ICON }}></Image>
140
- </View>
141
- </TouchableWithoutFeedback>
142
- )
143
- : null
95
+ navigation.setPageConfig = (config: PageConfig) => {
96
+ setPageConfig(Object.assign({}, innerPageConfig, config))
97
+ }
98
+ const isCustom = innerPageConfig.navigationStyle === 'custom'
99
+ const navigationBarTextStyle = useMemo(() => validBarTextStyle(innerPageConfig.navigationBarTextStyle), [innerPageConfig.navigationBarTextStyle])
100
+ // 状态栏的颜色
101
+ const statusBarElement = (
102
+ <StatusBar
103
+ translucent
104
+ backgroundColor='transparent'
105
+ barStyle={navigationBarTextStyle === NavColor.White ? 'light-content' : 'dark-content'}></StatusBar>
106
+ )
144
107
 
108
+ if (isCustom)
145
109
  return (
146
- <View
147
- style={[
148
- styles.header,
149
- {
150
- paddingTop: safeAreaTop,
151
- backgroundColor: innerPageConfig.navigationBarBackgroundColor || '#000000'
152
- }
153
- ]}>
110
+ <>
154
111
  {statusBarElement}
155
- {/* TODO: 确定 height 的有效性 */}
156
- {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
157
- {/* @ts-expect-error */}
158
- <View style={styles.headerContent} height={titleHeight}>
159
- {backElement}
160
- <Text style={[styles.title, { color: navigationBarTextStyle }]} numberOfLines={1}>
161
- {innerPageConfig.navigationBarTitleText?.trim() || ''}
162
- </Text>
163
- </View>
164
- </View>
112
+ {customNav}
113
+ </>
165
114
  )
166
- })
115
+ // 假设是栈导航,获取栈的长度
116
+ const stackLength = navigation.getState()?.routes?.length
117
+ const onStackTopBack = mpxGlobal?.__mpx?.config?.rnConfig?.onStackTopBack
118
+ const isHandleStackTopBack = typeof onStackTopBack === 'function'
167
119
 
168
- innerNav.displayName = 'MpxNav'
169
- return innerNav
170
- }
120
+ // 回退按钮与图标
121
+ // prettier-ignore
122
+ const backElement = stackLength > 1 || isHandleStackTopBack
123
+ ? (
124
+ <TouchableWithoutFeedback
125
+ onPress={() => {
126
+ if (stackLength <= 1 && isHandleStackTopBack) {
127
+ onStackTopBack()
128
+ return
129
+ }
130
+ navigation.goBack()
131
+ }}>
132
+ <View style={[styles.backButton]}>
133
+ <Image style={[styles.backButtonImage, { tintColor: navigationBarTextStyle }]} source={{ uri: BACK_ICON }}></Image>
134
+ </View>
135
+ </TouchableWithoutFeedback>
136
+ )
137
+ : null
138
+
139
+ return (
140
+ <View
141
+ style={[
142
+ styles.header,
143
+ {
144
+ paddingTop: safeAreaTop,
145
+ backgroundColor: innerPageConfig.navigationBarBackgroundColor || '#000000'
146
+ }
147
+ ]}>
148
+ {statusBarElement}
149
+ {/* TODO: 确定 height 的有效性 */}
150
+ {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
151
+ {/* @ts-expect-error */}
152
+ <View style={styles.headerContent} height={titleHeight}>
153
+ {backElement}
154
+ <Text style={[styles.title, { color: navigationBarTextStyle }]} numberOfLines={1}>
155
+ {innerPageConfig.navigationBarTitleText?.trim() || ''}
156
+ </Text>
157
+ </View>
158
+ </View>
159
+ )
160
+ })
171
161
 
172
- export default createMpxNav
162
+ MpxNav.displayName = 'MpxNav'
163
+ export default MpxNav
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.10.14-beta.5",
3
+ "version": "2.10.14-beta.7",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- interface MpxNavContainerProps {
3
- children?: React.ReactNode;
4
- }
5
- export default function MpxNavContainer(props: MpxNavContainerProps): import("react").ReactNode;
6
- export declare function NavSharedProvider({ children }: {
7
- children?: React.ReactNode;
8
- }): import("react").JSX.Element;
9
- export {};