@mpxjs/webpack-plugin 2.9.62 → 2.9.64

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 (86) hide show
  1. package/lib/index.js +1 -3
  2. package/lib/platform/style/wx/index.js +67 -53
  3. package/lib/react/processStyles.js +1 -0
  4. package/lib/react/processTemplate.js +2 -3
  5. package/lib/react/style-helper.js +12 -7
  6. package/lib/runtime/components/react/context.ts +9 -7
  7. package/lib/runtime/components/react/dist/context.js +1 -0
  8. package/lib/runtime/components/react/dist/getInnerListeners.js +12 -1
  9. package/lib/runtime/components/react/dist/mpx-button.jsx +52 -74
  10. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +19 -18
  11. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +28 -41
  12. package/lib/runtime/components/react/dist/mpx-form.jsx +16 -14
  13. package/lib/runtime/components/react/dist/mpx-icon.jsx +14 -17
  14. package/lib/runtime/components/react/dist/mpx-image/index.jsx +34 -33
  15. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +3 -1
  16. package/lib/runtime/components/react/dist/mpx-input.jsx +35 -31
  17. package/lib/runtime/components/react/dist/mpx-label.jsx +29 -37
  18. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -18
  19. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +8 -8
  20. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +9 -9
  21. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +7 -4
  22. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +11 -7
  23. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +1 -1
  24. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +18 -18
  25. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +102 -10
  26. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +147 -53
  27. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +19 -18
  28. package/lib/runtime/components/react/dist/mpx-radio.jsx +28 -43
  29. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +8 -4
  30. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +33 -26
  31. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +139 -74
  32. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +14 -6
  33. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +19 -11
  34. package/lib/runtime/components/react/dist/mpx-switch.jsx +17 -14
  35. package/lib/runtime/components/react/dist/mpx-text.jsx +19 -35
  36. package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -1
  37. package/lib/runtime/components/react/dist/mpx-view.jsx +284 -209
  38. package/lib/runtime/components/react/dist/mpx-web-view.jsx +8 -5
  39. package/lib/runtime/components/react/dist/parser.js +218 -0
  40. package/lib/runtime/components/react/dist/utils.jsx +433 -0
  41. package/lib/runtime/components/react/getInnerListeners.ts +18 -8
  42. package/lib/runtime/components/react/mpx-button.tsx +81 -91
  43. package/lib/runtime/components/react/mpx-checkbox-group.tsx +48 -43
  44. package/lib/runtime/components/react/mpx-checkbox.tsx +52 -63
  45. package/lib/runtime/components/react/mpx-form.tsx +49 -21
  46. package/lib/runtime/components/react/mpx-icon.tsx +30 -27
  47. package/lib/runtime/components/react/mpx-image/index.tsx +52 -46
  48. package/lib/runtime/components/react/mpx-image/svg.tsx +5 -3
  49. package/lib/runtime/components/react/mpx-input.tsx +58 -38
  50. package/lib/runtime/components/react/mpx-label.tsx +54 -59
  51. package/lib/runtime/components/react/mpx-movable-area.tsx +38 -24
  52. package/lib/runtime/components/react/mpx-movable-view.tsx +27 -28
  53. package/lib/runtime/components/react/mpx-navigator.tsx +2 -2
  54. package/lib/runtime/components/react/mpx-picker/date.tsx +2 -3
  55. package/lib/runtime/components/react/mpx-picker/index.tsx +10 -10
  56. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +15 -12
  57. package/lib/runtime/components/react/mpx-picker/region.tsx +21 -18
  58. package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -6
  59. package/lib/runtime/components/react/mpx-picker/time.tsx +25 -29
  60. package/lib/runtime/components/react/mpx-picker/type.ts +1 -1
  61. package/lib/runtime/components/react/mpx-picker-view-column.tsx +148 -20
  62. package/lib/runtime/components/react/mpx-picker-view.tsx +179 -63
  63. package/lib/runtime/components/react/mpx-radio-group.tsx +50 -47
  64. package/lib/runtime/components/react/mpx-radio.tsx +56 -72
  65. package/lib/runtime/components/react/mpx-root-portal.tsx +10 -8
  66. package/lib/runtime/components/react/mpx-scroll-view.tsx +133 -103
  67. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +174 -96
  68. package/lib/runtime/components/react/mpx-swiper/index.tsx +18 -9
  69. package/lib/runtime/components/react/mpx-swiper/type.ts +16 -5
  70. package/lib/runtime/components/react/mpx-swiper-item.tsx +46 -13
  71. package/lib/runtime/components/react/mpx-switch.tsx +44 -23
  72. package/lib/runtime/components/react/mpx-text.tsx +37 -45
  73. package/lib/runtime/components/react/mpx-textarea.tsx +1 -1
  74. package/lib/runtime/components/react/mpx-view.tsx +388 -240
  75. package/lib/runtime/components/react/mpx-web-view.tsx +19 -20
  76. package/lib/runtime/components/react/parser.ts +245 -0
  77. package/lib/runtime/components/react/types/common.ts +4 -4
  78. package/lib/runtime/components/react/types/global.d.ts +14 -2
  79. package/lib/runtime/components/react/useNodesRef.ts +1 -2
  80. package/lib/runtime/components/react/utils.tsx +505 -0
  81. package/lib/template-compiler/compiler.js +28 -20
  82. package/lib/template-compiler/gen-node-react.js +1 -3
  83. package/lib/web/processStyles.js +2 -5
  84. package/package.json +6 -4
  85. package/lib/runtime/components/react/dist/utils.js +0 -148
  86. package/lib/runtime/components/react/utils.ts +0 -170
@@ -4,51 +4,35 @@
4
4
  * ✘ decode
5
5
  */
6
6
  import { Text } from 'react-native';
7
- import { useRef, useEffect, forwardRef } from 'react';
7
+ import { useRef, forwardRef } from 'react';
8
8
  import useInnerProps from './getInnerListeners';
9
9
  import useNodesRef from './useNodesRef'; // 引入辅助函数
10
- import { transformTextStyle, DEFAULT_STYLE } from './utils';
10
+ import { useTransformStyle, wrapChildren } from './utils';
11
11
  const _Text = forwardRef((props, ref) => {
12
- const { style = {}, children, selectable, 'enable-offset': enableOffset, 'user-select': userSelect, 'disable-default-style': disableDefaultStyle = false, } = props;
12
+ const { style = {}, selectable, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'user-select': userSelect, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
13
13
  const layoutRef = useRef({});
14
- let defaultStyle = {};
15
- if (!disableDefaultStyle) {
16
- defaultStyle = DEFAULT_STYLE;
17
- transformTextStyle(style);
18
- }
19
- const { nodeRef } = useNodesRef(props, ref, {
20
- defaultStyle
14
+ const { normalStyle, hasVarDec, varContextRef } = useTransformStyle(style, {
15
+ enableVar,
16
+ externalVarContext,
17
+ parentFontSize,
18
+ parentWidth,
19
+ parentHeight
21
20
  });
21
+ const { nodeRef } = useNodesRef(props, ref);
22
22
  const innerProps = useInnerProps(props, {
23
- ref: nodeRef
23
+ ref: nodeRef,
24
+ style: normalStyle,
25
+ selectable: !!selectable || !!userSelect
24
26
  }, [
25
- 'style',
26
- 'children',
27
- 'selectable',
28
- 'user-select',
29
- 'useInherit',
30
- 'enable-offset'
27
+ 'user-select'
31
28
  ], {
32
29
  layoutRef
33
30
  });
34
- useEffect(() => {
35
- let measureTimeout = null;
36
- if (enableOffset) {
37
- measureTimeout = setTimeout(() => {
38
- nodeRef.current?.measure((x, y, width, height, offsetLeft, offsetTop) => {
39
- layoutRef.current = { x, y, width, height, offsetLeft, offsetTop };
40
- });
41
- });
42
- return () => {
43
- if (measureTimeout) {
44
- clearTimeout(measureTimeout);
45
- measureTimeout = null;
46
- }
47
- };
48
- }
49
- }, []);
50
- return (<Text style={{ ...defaultStyle, ...style }} selectable={!!selectable || !!userSelect} {...innerProps}>
51
- {children}
31
+ return (<Text {...innerProps}>
32
+ {wrapChildren(props, {
33
+ hasVarDec,
34
+ varContext: varContextRef.current
35
+ })}
52
36
  </Text>);
53
37
  });
54
38
  _Text.displayName = 'mpx-text';
@@ -19,7 +19,7 @@ const Textarea = forwardRef((props, ref) => {
19
19
  'type',
20
20
  'password',
21
21
  'multiline',
22
- 'confirm-hold',
22
+ 'confirm-hold'
23
23
  ]);
24
24
  return (<Input ref={ref} multiline confirm-type='next' bindblur={() => Keyboard.dismiss()} {...restProps}/>);
25
25
  });