@mpxjs/webpack-plugin 2.10.22 → 2.10.24-test.1

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 (123) hide show
  1. package/lib/loader.js +2 -0
  2. package/lib/platform/style/wx/index.js +395 -104
  3. package/lib/react/index.js +3 -1
  4. package/lib/react/processTemplate.js +3 -1
  5. package/lib/react/style-helper.js +6 -6
  6. package/lib/runtime/components/react/animationHooks/index.ts +7 -3
  7. package/lib/runtime/components/react/dist/animationHooks/index.d.ts +0 -2
  8. package/lib/runtime/components/react/dist/animationHooks/index.js +6 -1
  9. package/lib/runtime/components/react/dist/event.config.d.ts +2 -6
  10. package/lib/runtime/components/react/dist/event.config.js +28 -24
  11. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +1 -1
  12. package/lib/runtime/components/react/dist/getInnerListeners.js +74 -56
  13. package/lib/runtime/components/react/dist/mpx-button.d.ts +1 -1
  14. package/lib/runtime/components/react/dist/mpx-button.jsx +16 -9
  15. package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -1
  16. package/lib/runtime/components/react/dist/mpx-camera.jsx +1 -2
  17. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
  18. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +1 -2
  19. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +1 -1
  20. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
  21. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +3 -4
  22. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +1 -1
  23. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +8 -9
  24. package/lib/runtime/components/react/dist/mpx-form.d.ts +1 -1
  25. package/lib/runtime/components/react/dist/mpx-form.jsx +5 -5
  26. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
  27. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
  28. package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
  29. package/lib/runtime/components/react/dist/mpx-image.jsx +59 -43
  30. package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -1
  31. package/lib/runtime/components/react/dist/mpx-input.jsx +2 -2
  32. package/lib/runtime/components/react/dist/mpx-label.d.ts +1 -1
  33. package/lib/runtime/components/react/dist/mpx-label.jsx +5 -6
  34. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
  35. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +3 -3
  36. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +1 -1
  37. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +6 -6
  38. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +1 -1
  39. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +5 -7
  40. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -1
  41. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +2 -2
  42. package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
  43. package/lib/runtime/components/react/dist/mpx-progress.jsx +1 -2
  44. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
  45. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +3 -4
  46. package/lib/runtime/components/react/dist/mpx-radio.d.ts +1 -1
  47. package/lib/runtime/components/react/dist/mpx-radio.jsx +8 -9
  48. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
  49. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +1 -2
  50. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +1 -1
  51. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -6
  52. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +36 -31
  53. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +4 -2
  54. package/lib/runtime/components/react/dist/mpx-simple-view.jsx +24 -17
  55. package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
  56. package/lib/runtime/components/react/dist/mpx-slider.jsx +6 -6
  57. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +1 -1
  58. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +5 -5
  59. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +1 -1
  60. package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +6 -6
  61. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +1 -1
  62. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -5
  63. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -1
  64. package/lib/runtime/components/react/dist/mpx-swiper.jsx +4 -7
  65. package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
  66. package/lib/runtime/components/react/dist/mpx-switch.jsx +1 -2
  67. package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
  68. package/lib/runtime/components/react/dist/mpx-text.jsx +44 -40
  69. package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
  70. package/lib/runtime/components/react/dist/mpx-video.jsx +4 -4
  71. package/lib/runtime/components/react/dist/mpx-view.d.ts +2 -1
  72. package/lib/runtime/components/react/dist/mpx-view.jsx +229 -128
  73. package/lib/runtime/components/react/dist/mpx-web-view.jsx +5 -1
  74. package/lib/runtime/components/react/dist/namedColorSet.d.ts +2 -0
  75. package/lib/runtime/components/react/dist/namedColorSet.js +149 -0
  76. package/lib/runtime/components/react/dist/utils.d.ts +73 -69
  77. package/lib/runtime/components/react/dist/utils.jsx +1295 -442
  78. package/lib/runtime/components/react/event.config.ts +32 -25
  79. package/lib/runtime/components/react/getInnerListeners.ts +84 -60
  80. package/lib/runtime/components/react/mpx-button.tsx +18 -16
  81. package/lib/runtime/components/react/mpx-camera.tsx +0 -3
  82. package/lib/runtime/components/react/mpx-canvas/index.tsx +1 -3
  83. package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -1
  84. package/lib/runtime/components/react/mpx-checkbox-group.tsx +2 -6
  85. package/lib/runtime/components/react/mpx-checkbox.tsx +9 -11
  86. package/lib/runtime/components/react/mpx-form.tsx +6 -6
  87. package/lib/runtime/components/react/mpx-icon/index.tsx +1 -3
  88. package/lib/runtime/components/react/mpx-image.tsx +65 -54
  89. package/lib/runtime/components/react/mpx-input.tsx +1 -3
  90. package/lib/runtime/components/react/mpx-label.tsx +6 -8
  91. package/lib/runtime/components/react/mpx-movable-area.tsx +3 -4
  92. package/lib/runtime/components/react/mpx-movable-view.tsx +7 -7
  93. package/lib/runtime/components/react/mpx-picker-view/index.tsx +6 -8
  94. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +2 -4
  95. package/lib/runtime/components/react/mpx-progress.tsx +0 -3
  96. package/lib/runtime/components/react/mpx-radio-group.tsx +2 -6
  97. package/lib/runtime/components/react/mpx-radio.tsx +9 -11
  98. package/lib/runtime/components/react/mpx-rich-text/index.tsx +0 -3
  99. package/lib/runtime/components/react/mpx-scroll-view.tsx +7 -7
  100. package/lib/runtime/components/react/mpx-simple-text.tsx +36 -38
  101. package/lib/runtime/components/react/mpx-simple-view.tsx +29 -17
  102. package/lib/runtime/components/react/mpx-slider.tsx +15 -10
  103. package/lib/runtime/components/react/mpx-sticky-header.tsx +6 -6
  104. package/lib/runtime/components/react/mpx-sticky-section.tsx +7 -7
  105. package/lib/runtime/components/react/mpx-swiper-item.tsx +6 -6
  106. package/lib/runtime/components/react/mpx-swiper.tsx +5 -8
  107. package/lib/runtime/components/react/mpx-switch.tsx +0 -3
  108. package/lib/runtime/components/react/mpx-text.tsx +46 -49
  109. package/lib/runtime/components/react/mpx-video.tsx +3 -5
  110. package/lib/runtime/components/react/mpx-view.tsx +250 -141
  111. package/lib/runtime/components/react/mpx-web-view.tsx +8 -3
  112. package/lib/runtime/components/react/namedColorSet.ts +150 -0
  113. package/lib/runtime/components/react/types/getInnerListeners.d.ts +21 -1
  114. package/lib/runtime/components/react/types/global.d.ts +1 -0
  115. package/lib/runtime/components/react/utils.tsx +1347 -539
  116. package/lib/runtime/i18n.wxs +15 -9
  117. package/lib/style-compiler/strip-conditional.js +19 -4
  118. package/lib/template-compiler/compiler.js +5 -1
  119. package/lib/utils/source-location.js +9 -13
  120. package/lib/web/index.js +3 -1
  121. package/lib/web/processTemplate.js +3 -1
  122. package/package.json +5 -4
  123. package/LICENSE +0 -433
@@ -12,7 +12,7 @@ interface FormProps {
12
12
  children?: ReactNode;
13
13
  'enable-offset'?: boolean;
14
14
  'enable-var'?: boolean;
15
- 'external-var-context'?: Record<string, any>;
15
+ 'enable-text-pass-through'?: boolean;
16
16
  'parent-font-size'?: number;
17
17
  'parent-width'?: number;
18
18
  'parent-height'?: number;
@@ -9,13 +9,13 @@ import { useRef, forwardRef, useMemo, createElement } from 'react';
9
9
  import useNodesRef from './useNodesRef';
10
10
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
11
11
  import { FormContext } from './context';
12
- import { useTransformStyle, splitProps, splitStyle, useLayout, wrapChildren, extendObject, useTextPassThroughValue } from './utils';
12
+ import { useTransformStyle, splitProps, splitStyle, useLayout, wrapChildren, extendObject, useTextPassThrough } from './utils';
13
13
  const _Form = forwardRef((fromProps, ref) => {
14
14
  const { textProps, innerProps: props = {} } = splitProps(fromProps);
15
- const { style, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
16
- const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
15
+ const { style, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
16
+ const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight });
17
17
  const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
18
- const textPassThrough = useTextPassThroughValue(textStyle, textProps);
18
+ const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
19
19
  const formRef = useRef(null);
20
20
  useNodesRef(props, ref, formRef, {
21
21
  style: normalStyle
@@ -58,7 +58,7 @@ const _Form = forwardRef((fromProps, ref) => {
58
58
  reset
59
59
  };
60
60
  }, []);
61
- return createElement(View, innerProps, createElement(FormContext.Provider, { value: contextValue }, wrapChildren(props, {
61
+ return createElement(View, innerProps, createElement(FormContext.Provider, { value: contextValue }, wrapChildren(props.children, {
62
62
  hasVarDec,
63
63
  varContext: varContextRef.current,
64
64
  textPassThrough
@@ -9,7 +9,6 @@ export interface IconProps {
9
9
  style?: TextStyle & Record<string, any>;
10
10
  'enable-offset'?: boolean;
11
11
  'enable-var'?: boolean;
12
- 'external-var-context'?: Record<string, any>;
13
12
  'parent-font-size'?: number;
14
13
  'parent-width'?: number;
15
14
  'parent-height'?: number;
@@ -30,11 +30,11 @@ const IconTypeMap = new Map([
30
30
  ['clear', Clear]
31
31
  ]);
32
32
  const Icon = forwardRef((props, ref) => {
33
- const { type, size = 23, color, style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
33
+ const { type, size = 23, color, style = {}, 'enable-var': enableVar, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
34
34
  const source = IconTypeMap.get(type);
35
35
  const defaultStyle = { width: ~~size, height: ~~size };
36
36
  const styleObj = extendObject({}, defaultStyle, style);
37
- const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
37
+ const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, parentFontSize, parentWidth, parentHeight });
38
38
  const nodeRef = useRef(null);
39
39
  useNodesRef(props, ref, nodeRef, { style: normalStyle });
40
40
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
@@ -8,7 +8,6 @@ export interface ImageProps {
8
8
  style?: ImageStyle & Record<string, any>;
9
9
  'enable-offset'?: boolean;
10
10
  'enable-var'?: boolean;
11
- 'external-var-context'?: Record<string, any>;
12
11
  'parent-font-size'?: number;
13
12
  'parent-width'?: number;
14
13
  'parent-height'?: number;
@@ -12,33 +12,52 @@
12
12
  */
13
13
  import { useEffect, useMemo, useState, useRef, forwardRef, createElement } from 'react';
14
14
  import { Image as RNImage, View } from 'react-native';
15
- import { noop } from '@mpxjs/utils';
15
+ import { hasOwn, noop } from '@mpxjs/utils';
16
16
  import { LocalSvg, SvgCssUri } from 'react-native-svg/css';
17
17
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
18
18
  import useNodesRef from './useNodesRef';
19
- import { SVG_REGEXP, useLayout, useTransformStyle, renderImage, extendObject, isAndroid } from './utils';
19
+ import { svgRegExp, useLayout, useTransformStyle, renderImage, extendObject, isAndroid } from './utils';
20
20
  import Portal from './mpx-portal';
21
21
  const DEFAULT_IMAGE_WIDTH = 320;
22
22
  const DEFAULT_IMAGE_HEIGHT = 240;
23
- const cropMode = [
24
- 'top',
25
- 'bottom',
26
- 'center',
27
- 'right',
28
- 'left',
29
- 'top left',
30
- 'top right',
31
- 'bottom left',
32
- 'bottom right'
33
- ];
34
- const ModeMap = new Map([
35
- ['scaleToFill', 'stretch'],
36
- ['aspectFit', 'contain'],
37
- ['aspectFill', 'cover'],
38
- ['widthFix', 'stretch'],
39
- ['heightFix', 'stretch'],
40
- ...cropMode.map(mode => [mode, 'stretch'])
41
- ]);
23
+ const cropModeMap = {
24
+ top: true,
25
+ bottom: true,
26
+ center: true,
27
+ right: true,
28
+ left: true,
29
+ 'top left': true,
30
+ 'top right': true,
31
+ 'bottom left': true,
32
+ 'bottom right': true
33
+ };
34
+ const modeResizeMap = {
35
+ scaleToFill: 'stretch',
36
+ aspectFit: 'contain',
37
+ aspectFill: 'cover',
38
+ widthFix: 'stretch',
39
+ heightFix: 'stretch',
40
+ top: 'stretch',
41
+ bottom: 'stretch',
42
+ center: 'stretch',
43
+ right: 'stretch',
44
+ left: 'stretch',
45
+ 'top left': 'stretch',
46
+ 'top right': 'stretch',
47
+ 'bottom left': 'stretch',
48
+ 'bottom right': 'stretch'
49
+ };
50
+ const DEFAULT_IMAGE_STYLE = {
51
+ width: DEFAULT_IMAGE_WIDTH,
52
+ height: DEFAULT_IMAGE_HEIGHT
53
+ };
54
+ const OVERFLOW_HIDDEN_STYLE = { overflow: 'hidden' };
55
+ const SVG_TRANSFORM_ORIGIN_STYLE = { transformOrigin: 'left top' };
56
+ const BASE_IMAGE_FILL_STYLE = {
57
+ transformOrigin: 'left top',
58
+ width: '100%',
59
+ height: '100%'
60
+ };
42
61
  const isNumber = (value) => typeof value === 'number';
43
62
  const relativeCenteredSize = (viewSize, imageSize) => {
44
63
  return (viewSize - imageSize) / 2;
@@ -51,7 +70,7 @@ function getImageUri(src) {
51
70
  }
52
71
  function isSvgSource(src) {
53
72
  const uri = getImageUri(src);
54
- return SVG_REGEXP.test(uri);
73
+ return svgRegExp.test(uri);
55
74
  }
56
75
  function getImageSize(src, success, fail = noop) {
57
76
  if (typeof src === 'string') {
@@ -92,22 +111,16 @@ const getFixedHeight = (viewWidth, viewHeight, ratio) => {
92
111
  return !fixed ? viewHeight : fixed;
93
112
  };
94
113
  const Image = forwardRef((props, ref) => {
95
- const { src = '', mode = 'scaleToFill', style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'enable-fast-image': enableFastImage, 'parent-width': parentWidth, 'parent-height': parentHeight, 'is-svg': isSvgProp, bindload, binderror } = props;
96
- const defaultStyle = {
97
- width: DEFAULT_IMAGE_WIDTH,
98
- height: DEFAULT_IMAGE_HEIGHT
99
- };
100
- const styleObj = extendObject({}, defaultStyle, style, { overflow: 'hidden' });
114
+ const { src = '', mode = 'scaleToFill', style = {}, 'enable-var': enableVar, 'parent-font-size': parentFontSize, 'enable-fast-image': enableFastImage, 'parent-width': parentWidth, 'parent-height': parentHeight, 'is-svg': isSvgProp, bindload, binderror } = props;
115
+ const styleObj = extendObject({}, style, OVERFLOW_HIDDEN_STYLE);
101
116
  const nodeRef = useRef(null);
102
- useNodesRef(props, ref, nodeRef, {
103
- defaultStyle
104
- });
105
- const isSvg = isSvgProp || isSvgSource(src);
117
+ const isSvg = useMemo(() => isSvgProp || isSvgSource(src), [isSvgProp, src]);
118
+ const imageSource = useMemo(() => normalizeImageSource(src), [src]);
106
119
  const isWidthFixMode = mode === 'widthFix';
107
120
  const isHeightFixMode = mode === 'heightFix';
108
- const isCropMode = cropMode.includes(mode);
121
+ const isCropMode = hasOwn(cropModeMap, mode);
109
122
  const isLayoutMode = isWidthFixMode || isHeightFixMode || isCropMode;
110
- const resizeMode = ModeMap.get(mode) || 'stretch';
123
+ const resizeMode = hasOwn(modeResizeMap, mode) ? modeResizeMap[mode] : 'stretch';
111
124
  const onLayout = ({ nativeEvent: { layout: { width, height } } }) => {
112
125
  state.current.viewWidth = width;
113
126
  state.current.viewHeight = height;
@@ -127,14 +140,18 @@ const Image = forwardRef((props, ref) => {
127
140
  setLoaded(true);
128
141
  }
129
142
  };
130
- const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, transformRadiusPercent: isAndroid && !isSvg && !isLayoutMode, externalVarContext, parentFontSize, parentWidth, parentHeight });
143
+ const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, transformRadiusPercent: isAndroid && !isSvg && !isLayoutMode, parentFontSize, parentWidth, parentHeight, defaultStyle: DEFAULT_IMAGE_STYLE });
144
+ // normalStyle 已合入 DEFAULT_IMAGE_STYLE,对外暴露完整 style(含 default 兜底的 width/height)
145
+ useNodesRef(props, ref, nodeRef, {
146
+ style: normalStyle
147
+ });
131
148
  const { layoutRef, layoutStyle, layoutProps } = useLayout({
132
149
  props,
133
150
  hasSelfPercent,
134
151
  setWidth,
135
152
  setHeight,
136
153
  nodeRef,
137
- onLayout: isLayoutMode ? onLayout : noop
154
+ onLayout: isLayoutMode ? onLayout : undefined
138
155
  });
139
156
  const { width, height } = normalStyle;
140
157
  const [viewWidth, setViewWidth] = useState(isNumber(width) ? width : 0);
@@ -350,23 +367,22 @@ const Image = forwardRef((props, ref) => {
350
367
  function renderSvgImage() {
351
368
  const svgProps = {
352
369
  onLayout: onSvgLoad,
353
- style: extendObject({ transformOrigin: 'left top' }, modeStyle)
370
+ style: extendObject({}, SVG_TRANSFORM_ORIGIN_STYLE, modeStyle)
354
371
  };
355
372
  return createElement(View, innerProps, typeof src === 'string'
356
373
  ? createElement(SvgCssUri, extendObject({ uri: src, onError: binderror && onSvgError }, svgProps))
357
374
  : createElement(LocalSvg, extendObject({ asset: src }, svgProps)));
358
375
  }
359
376
  function renderBaseImage() {
377
+ const baseImageStyle = isCropMode
378
+ ? extendObject({ transformOrigin: 'left top', width: imageWidth, height: imageHeight }, modeStyle)
379
+ : BASE_IMAGE_FILL_STYLE;
360
380
  return renderImage(extendObject({
361
- source: normalizeImageSource(src),
381
+ source: imageSource,
362
382
  resizeMode: resizeMode,
363
383
  onLoad: bindload && onImageLoad,
364
384
  onError: binderror && onImageError,
365
- style: extendObject({
366
- transformOrigin: 'left top',
367
- width: isCropMode ? imageWidth : '100%',
368
- height: isCropMode ? imageHeight : '100%'
369
- }, isCropMode ? modeStyle : {})
385
+ style: baseImageStyle
370
386
  }, isLayoutMode ? {} : innerProps), enableFastImage);
371
387
  }
372
388
  function renderLayoutImage() {
@@ -27,7 +27,6 @@ export interface InputProps {
27
27
  };
28
28
  'enable-offset'?: boolean;
29
29
  'enable-var'?: boolean;
30
- 'external-var-context'?: Record<string, any>;
31
30
  'parent-font-size'?: number;
32
31
  'parent-width'?: number;
33
32
  'parent-height'?: number;
@@ -52,7 +52,7 @@ const inputModeMap = {
52
52
  digit: 'decimal'
53
53
  };
54
54
  const Input = forwardRef((props, ref) => {
55
- const { style = {}, allowFontScaling, 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, 'keyboard-type': originalKeyboardType, 'hold-keyboard': holdKeyboard = false, bindinput, bindfocus, bindblur, bindconfirm, bindselectionchange,
55
+ const { style = {}, allowFontScaling, 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, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'adjust-position': adjustPosition = true, 'keyboard-type': originalKeyboardType, 'hold-keyboard': holdKeyboard = false, bindinput, bindfocus, bindblur, bindconfirm, bindselectionchange,
56
56
  // private
57
57
  multiline, 'auto-height': autoHeight, bindlinechange } = props;
58
58
  const formContext = useContext(FormContext);
@@ -84,7 +84,7 @@ const Input = forwardRef((props, ref) => {
84
84
  const [contentHeight, setContentHeight] = useState(0);
85
85
  const [selection, setSelection] = useState({ start: -1, end: tmpValue.current.length });
86
86
  const styleObj = extendObject({ padding: 0, backgroundColor: '#fff' }, style, multiline && autoHeight ? { height: 'auto' } : {});
87
- const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
87
+ const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, parentFontSize, parentWidth, parentHeight });
88
88
  const nodeRef = useRef(null);
89
89
  useNodesRef(props, ref, nodeRef, {
90
90
  style: normalStyle
@@ -9,7 +9,7 @@ export interface LabelProps {
9
9
  style?: ViewStyle & Record<string, any>;
10
10
  'enable-offset'?: boolean;
11
11
  'enable-var'?: boolean;
12
- 'external-var-context'?: Record<string, any>;
12
+ 'enable-text-pass-through'?: boolean;
13
13
  'parent-font-size'?: number;
14
14
  'parent-width'?: number;
15
15
  'parent-height'?: number;
@@ -6,24 +6,23 @@ import { View } from 'react-native';
6
6
  import { noop, warn } from '@mpxjs/utils';
7
7
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
8
8
  import useNodesRef from './useNodesRef';
9
- import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useTextPassThroughValue } from './utils';
9
+ import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useTextPassThrough } from './utils';
10
10
  import { LabelContext } from './context';
11
11
  import Portal from './mpx-portal';
12
12
  const Label = forwardRef((labelProps, ref) => {
13
13
  const { textProps, innerProps: props = {} } = splitProps(labelProps);
14
14
  const propsRef = useRef({});
15
- const { style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
15
+ const { style = {}, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
16
16
  propsRef.current = props;
17
17
  const defaultStyle = {
18
18
  flexDirection: 'row'
19
19
  };
20
- const styleObj = extendObject({}, defaultStyle, style);
21
- const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
20
+ const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight, defaultStyle });
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 });
25
24
  const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle);
26
- const textPassThrough = useTextPassThroughValue(textStyle, textProps);
25
+ const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
27
26
  if (backgroundStyle) {
28
27
  warn('Label does not support background image-related styles!');
29
28
  }
@@ -44,7 +43,7 @@ const Label = forwardRef((labelProps, ref) => {
44
43
  ], {
45
44
  layoutRef
46
45
  });
47
- const finalComponent = createElement(View, innerProps, createElement(LabelContext.Provider, { value: contextRef }, wrapChildren(props, {
46
+ const finalComponent = createElement(View, innerProps, createElement(LabelContext.Provider, { value: contextRef }, wrapChildren(props.children, {
48
47
  hasVarDec,
49
48
  varContext: varContextRef.current,
50
49
  textPassThrough
@@ -11,7 +11,6 @@ interface MovableAreaProps {
11
11
  height?: number;
12
12
  'enable-offset'?: boolean;
13
13
  'enable-var'?: boolean;
14
- 'external-var-context'?: Record<string, any>;
15
14
  'parent-font-size'?: number;
16
15
  'parent-width'?: number;
17
16
  'parent-height'?: number;
@@ -9,8 +9,8 @@ import { MovableAreaContext } from './context';
9
9
  import { useTransformStyle, wrapChildren, useLayout, extendObject } from './utils';
10
10
  import Portal from './mpx-portal';
11
11
  const _MovableArea = forwardRef((props, ref) => {
12
- 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 { style = {}, 'enable-var': enableVar, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
13
+ const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, hasPositionFixed, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight });
14
14
  const movableViewRef = useRef(null);
15
15
  useNodesRef(props, ref, movableViewRef, {
16
16
  style: normalStyle
@@ -24,7 +24,7 @@ const _MovableArea = forwardRef((props, ref) => {
24
24
  style: extendObject({ height: contextValue.height, width: contextValue.width }, normalStyle, layoutStyle),
25
25
  ref: movableViewRef
26
26
  }), [], { layoutRef });
27
- let movableComponent = createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(View, innerProps, wrapChildren(props, {
27
+ let movableComponent = createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(View, innerProps, wrapChildren(props.children, {
28
28
  hasVarDec,
29
29
  varContext: varContextRef.current
30
30
  })));
@@ -55,7 +55,7 @@ interface MovableViewProps {
55
55
  'simultaneous-handlers'?: Array<GestureHandler>;
56
56
  inertia?: boolean;
57
57
  'enable-var'?: boolean;
58
- 'external-var-context'?: Record<string, any>;
58
+ 'enable-text-pass-through'?: boolean;
59
59
  'parent-font-size'?: number;
60
60
  'parent-width'?: number;
61
61
  'parent-height'?: number;
@@ -22,7 +22,7 @@ import { StyleSheet } from 'react-native';
22
22
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
23
23
  import useNodesRef from './useNodesRef';
24
24
  import { MovableAreaContext } from './context';
25
- import { useTransformStyle, splitProps, splitStyle, HIDDEN_STYLE, wrapChildren, flatGesture, extendObject, omit, useNavigation, useRunOnJSCallback, useTextPassThroughValue } from './utils';
25
+ import { useTransformStyle, splitProps, splitStyle, hiddenStyle, wrapChildren, flatGesture, extendObject, omit, useNavigation, useRunOnJSCallback, useTextPassThrough } from './utils';
26
26
  import { GestureDetector, Gesture } from 'react-native-gesture-handler';
27
27
  import Animated, { useSharedValue, useAnimatedStyle, runOnJS, runOnUI, withTiming, Easing } from 'react-native-reanimated';
28
28
  import { collectDataset, noop } from '@mpxjs/utils';
@@ -129,14 +129,14 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
129
129
  const hasLayoutRef = useRef(false);
130
130
  const propsRef = useRef({});
131
131
  propsRef.current = (props || {});
132
- const { x = 0, y = 0, inertia = false, disabled = false, animation = true, damping = 20, friction = 2, 'out-of-bounds': outOfBounds = false, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, direction = 'none', 'disable-event-passthrough': disableEventPassthrough = false, 'simultaneous-handlers': originSimultaneousHandlers = [], 'wait-for': waitFor = [], style = {}, changeThrottleTime = 60, bindtouchstart, catchtouchstart, bindhtouchmove, bindvtouchmove, bindtouchmove, catchhtouchmove, catchvtouchmove, catchtouchmove, bindtouchend, catchtouchend, bindchange } = props;
133
- const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(Object.assign({}, style, styles.container), { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
132
+ const { x = 0, y = 0, inertia = false, disabled = false, animation = true, damping = 20, friction = 2, 'out-of-bounds': outOfBounds = false, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, direction = 'none', 'disable-event-passthrough': disableEventPassthrough = false, 'simultaneous-handlers': originSimultaneousHandlers = [], 'wait-for': waitFor = [], style = {}, changeThrottleTime = 60, bindtouchstart, catchtouchstart, bindhtouchmove, bindvtouchmove, bindtouchmove, catchhtouchmove, catchvtouchmove, catchtouchmove, bindtouchend, catchtouchend, bindchange } = props;
133
+ const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(Object.assign({}, style, styles.container), { enableVar, parentFontSize, parentWidth, parentHeight });
134
134
  const navigation = useNavigation();
135
135
  const prevSimultaneousHandlersRef = useRef(originSimultaneousHandlers || []);
136
136
  const prevWaitForHandlersRef = useRef(waitFor || []);
137
137
  const gestureSwitch = useRef(false);
138
138
  const { textStyle, innerStyle } = splitStyle(normalStyle);
139
- const textPassThrough = useTextPassThroughValue(textStyle, textProps);
139
+ const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
140
140
  const offsetX = useSharedValue(x);
141
141
  const offsetY = useSharedValue(y);
142
142
  const startPosition = useSharedValue({
@@ -564,7 +564,7 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
564
564
  });
565
565
  return handlers;
566
566
  };
567
- const layoutStyle = !hasLayoutRef.current && hasSelfPercent ? HIDDEN_STYLE : {};
567
+ const layoutStyle = !hasLayoutRef.current && hasSelfPercent ? hiddenStyle : {};
568
568
  // bind 相关 touch 事件直接由 gesture 触发,无须重复挂载
569
569
  // catch 相关 touch 事件需要重写并通过 useInnerProps 注入阻止冒泡逻辑
570
570
  const filterProps = omit(props, [
@@ -599,7 +599,7 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
599
599
  'changeThrottleTime',
600
600
  'bindchange'
601
601
  ]);
602
- return createElement(GestureDetector, { gesture: gesture }, createElement(Animated.View, innerProps, wrapChildren(props, {
602
+ return createElement(GestureDetector, { gesture: gesture }, createElement(Animated.View, innerProps, wrapChildren(props.children, {
603
603
  hasVarDec,
604
604
  varContext: varContextRef.current,
605
605
  textPassThrough
@@ -25,7 +25,7 @@ interface PickerViewProps {
25
25
  'indicator-style'?: Record<string, any>;
26
26
  'mask-style'?: Record<string, any>;
27
27
  'enable-var'?: boolean;
28
- 'external-var-context'?: Record<string, any>;
28
+ 'enable-text-pass-through'?: boolean;
29
29
  'enable-offset'?: boolean;
30
30
  }
31
31
  declare const _PickerView: React.ForwardRefExoticComponent<PickerViewProps & React.RefAttributes<HandlerRef<View, PickerViewProps>>>;
@@ -2,7 +2,7 @@ import { View } from 'react-native';
2
2
  import React, { createElement, forwardRef, useRef } from 'react';
3
3
  import useInnerProps, { getCustomEvent } from '../getInnerListeners';
4
4
  import useNodesRef from '../useNodesRef';
5
- import { useLayout, splitProps, splitStyle, wrapChildren, useTransformStyle, extendObject, useTextPassThroughValue } from '../utils';
5
+ import { useLayout, splitProps, splitStyle, wrapChildren, useTransformStyle, extendObject, useTextPassThrough } from '../utils';
6
6
  import { PickerViewStyleContext } from './pickerVIewContext';
7
7
  import Portal from '../mpx-portal';
8
8
  const styles = {
@@ -17,21 +17,21 @@ const styles = {
17
17
  };
18
18
  const DefaultPickerItemH = 36;
19
19
  const _PickerView = forwardRef((props, ref) => {
20
- const { children, value = [], bindchange, style, 'enable-wheel-animation': enableWheelAnimation = true, 'indicator-style': indicatorStyle = {}, 'mask-style': pickerMaskStyle = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext } = props;
20
+ const { children, value = [], bindchange, style, 'enable-wheel-animation': enableWheelAnimation = true, 'indicator-style': indicatorStyle = {}, 'mask-style': pickerMaskStyle = {}, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough } = props;
21
21
  const { height: indicatorH, ...pickerIndicatorStyle } = indicatorStyle;
22
22
  const nodeRef = useRef(null);
23
23
  const cloneRef = useRef(null);
24
24
  const activeValueRef = useRef(value);
25
25
  activeValueRef.current = value.slice();
26
26
  const snapActiveValueRef = useRef(null);
27
- const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(style, { enableVar, externalVarContext });
27
+ const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(style, { enableVar });
28
28
  useNodesRef(props, ref, nodeRef, {
29
29
  style: normalStyle
30
30
  });
31
31
  const { layoutRef, layoutProps, layoutStyle } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: nodeRef });
32
32
  const { textProps } = splitProps(props);
33
33
  const { textStyle } = splitStyle(normalStyle);
34
- const textPassThrough = useTextPassThroughValue(textStyle, textProps);
34
+ const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
35
35
  const onSelectChange = (columnIndex, selectedIndex) => {
36
36
  const activeValue = activeValueRef.current;
37
37
  activeValue[columnIndex] = selectedIndex;
@@ -83,9 +83,7 @@ const _PickerView = forwardRef((props, ref) => {
83
83
  enableWheelAnimation
84
84
  });
85
85
  const realElement = React.cloneElement(child, wrappedProps);
86
- return wrapChildren({
87
- children: realElement
88
- }, {
86
+ return wrapChildren(realElement, {
89
87
  hasVarDec,
90
88
  varContext: varContextRef.current,
91
89
  textPassThrough
@@ -10,7 +10,6 @@ interface ColumnProps {
10
10
  [key: string]: any;
11
11
  };
12
12
  'enable-var'?: boolean;
13
- 'external-var-context'?: Record<string, any>;
14
13
  wrapperStyle: {
15
14
  height: number;
16
15
  itemHeight: number;
@@ -11,8 +11,8 @@ import { PickerViewColumnAnimationContext } from '../mpx-picker-view/pickerVIewC
11
11
  import { calcHeightOffsets } from './pickerViewFaces';
12
12
  const visibleCount = 5;
13
13
  const _PickerViewColumn = forwardRef((props, ref) => {
14
- const { columnData, columnIndex, initialIndex, onSelectChange, style, wrapperStyle, pickerMaskStyle, pickerIndicatorStyle, enableWheelAnimation = true, 'enable-var': enableVar, 'external-var-context': externalVarContext } = props;
15
- const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext });
14
+ const { columnData, columnIndex, initialIndex, onSelectChange, style, wrapperStyle, pickerMaskStyle, pickerIndicatorStyle, enableWheelAnimation = true, 'enable-var': enableVar } = props;
15
+ const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar });
16
16
  const { textStyle = {} } = splitStyle(normalStyle);
17
17
  const { textProps = {} } = splitProps(props);
18
18
  const scrollViewRef = useAnimatedRef();
@@ -14,7 +14,6 @@ export interface ProgressProps {
14
14
  style?: ViewStyle & Record<string, any>;
15
15
  'enable-offset'?: boolean;
16
16
  'enable-var'?: boolean;
17
- 'external-var-context'?: Record<string, any>;
18
17
  'parent-font-size'?: number;
19
18
  'parent-width'?: number;
20
19
  'parent-height'?: number;
@@ -20,7 +20,7 @@ import useNodesRef from './useNodesRef';
20
20
  import { useLayout, useTransformStyle, extendObject, useRunOnJSCallback } from './utils';
21
21
  import Portal from './mpx-portal';
22
22
  const Progress = forwardRef((props, ref) => {
23
- const { percent = 0, 'stroke-width': strokeWidth = 6, color, activeColor = color || '#09BB07', backgroundColor = '#EBEBEB', active = false, 'active-mode': activeMode = 'backwards', duration = 30, style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
23
+ const { percent = 0, 'stroke-width': strokeWidth = 6, color, activeColor = color || '#09BB07', backgroundColor = '#EBEBEB', active = false, 'active-mode': activeMode = 'backwards', duration = 30, style = {}, 'enable-var': enableVar, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
24
24
  const nodeRef = useRef(null);
25
25
  const propsRef = useRef(props);
26
26
  propsRef.current = props;
@@ -29,7 +29,6 @@ const Progress = forwardRef((props, ref) => {
29
29
  const progressWidth = useSharedValue(0);
30
30
  const { normalStyle, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(style, {
31
31
  enableVar,
32
- externalVarContext,
33
32
  parentFontSize,
34
33
  parentWidth,
35
34
  parentHeight
@@ -9,7 +9,6 @@ export interface RadioGroupProps {
9
9
  style?: ViewStyle & Record<string, any>;
10
10
  'enable-offset'?: boolean;
11
11
  'enable-var'?: boolean;
12
- 'external-var-context'?: Record<string, any>;
13
12
  'parent-font-size'?: number;
14
13
  'parent-width'?: number;
15
14
  'parent-height'?: number;
@@ -10,7 +10,7 @@ import useNodesRef from './useNodesRef';
10
10
  import { useLayout, useTransformStyle, wrapChildren, extendObject } from './utils';
11
11
  import Portal from './mpx-portal';
12
12
  const radioGroup = forwardRef((props, ref) => {
13
- const { style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
13
+ const { style = {}, 'enable-var': enableVar, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
14
14
  const propsRef = useRef({});
15
15
  propsRef.current = props;
16
16
  const formContext = useContext(FormContext);
@@ -23,8 +23,7 @@ const radioGroup = forwardRef((props, ref) => {
23
23
  flexDirection: 'row',
24
24
  flexWrap: 'wrap'
25
25
  };
26
- const styleObj = extendObject({}, defaultStyle, style);
27
- const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
26
+ const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight, defaultStyle });
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 });
@@ -83,7 +82,7 @@ const radioGroup = forwardRef((props, ref) => {
83
82
  });
84
83
  const finalComponent = createElement(View, innerProps, createElement(RadioGroupContext.Provider, {
85
84
  value: contextValue
86
- }, wrapChildren(props, {
85
+ }, wrapChildren(props.children, {
87
86
  hasVarDec,
88
87
  varContext: varContextRef.current
89
88
  })));
@@ -15,7 +15,7 @@ export interface RadioProps {
15
15
  style?: ViewStyle & Record<string, any>;
16
16
  'enable-offset'?: boolean;
17
17
  'enable-var'?: boolean;
18
- 'external-var-context'?: Record<string, any>;
18
+ 'enable-text-pass-through'?: boolean;
19
19
  'parent-font-size'?: number;
20
20
  'parent-width'?: number;
21
21
  'parent-height'?: number;
@@ -10,7 +10,7 @@ import { warn } from '@mpxjs/utils';
10
10
  import { LabelContext, RadioGroupContext } from './context';
11
11
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
12
12
  import useNodesRef from './useNodesRef';
13
- import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useTextPassThroughValue } from './utils';
13
+ import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useTextPassThrough } from './utils';
14
14
  import Icon from './mpx-icon';
15
15
  import Portal from './mpx-portal';
16
16
  const styles = StyleSheet.create({
@@ -48,14 +48,13 @@ const styles = StyleSheet.create({
48
48
  });
49
49
  const Radio = forwardRef((radioProps, ref) => {
50
50
  const { textProps, innerProps: props = {} } = splitProps(radioProps);
51
- const { value = '', disabled = false, checked = false, color = '#09BB07', style = [], 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, bindtap } = props;
51
+ const { value = '', disabled = false, checked = false, color = '#09BB07', style = [], 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, bindtap } = props;
52
52
  const [isChecked, setIsChecked] = useState(!!checked);
53
53
  const groupContext = useContext(RadioGroupContext);
54
54
  let groupValue;
55
55
  let notifyChange;
56
56
  const labelContext = useContext(LabelContext);
57
- const defaultStyle = extendObject({}, styles.wrapper, isChecked ? styles.wrapperChecked : {}, disabled ? styles.wrapperDisabled : {});
58
- const styleObj = extendObject({}, styles.container, style);
57
+ const wrapperStyle = extendObject({}, styles.wrapper, isChecked ? styles.wrapperChecked : {}, disabled ? styles.wrapperDisabled : {});
59
58
  const onChange = (evt) => {
60
59
  if (disabled || isChecked)
61
60
  return;
@@ -74,15 +73,15 @@ const Radio = forwardRef((radioProps, ref) => {
74
73
  bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props));
75
74
  onChange(evt);
76
75
  };
77
- const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
76
+ const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight, defaultStyle: styles.container });
78
77
  const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle);
79
- const textPassThrough = useTextPassThroughValue(textStyle, textProps);
78
+ const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
80
79
  if (backgroundStyle) {
81
80
  warn('Radio does not support background image-related styles!');
82
81
  }
83
82
  const nodeRef = useRef(null);
84
83
  useNodesRef(props, ref, nodeRef, {
85
- style: extendObject({}, defaultStyle, normalStyle),
84
+ style: normalStyle,
86
85
  change: onChange
87
86
  });
88
87
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
@@ -126,12 +125,12 @@ const Radio = forwardRef((radioProps, ref) => {
126
125
  }
127
126
  }
128
127
  }, [checked]);
129
- const finalComponent = createElement(View, innerProps, createElement(View, { style: defaultStyle }, createElement(Icon, {
128
+ const finalComponent = createElement(View, innerProps, createElement(View, { style: wrapperStyle }, createElement(Icon, {
130
129
  type: 'success',
131
130
  size: 24,
132
131
  color: disabled ? '#E1E1E1' : color,
133
132
  style: extendObject({}, styles.icon, isChecked && styles.iconChecked, disabled && styles.iconDisabled)
134
- })), wrapChildren(props, {
133
+ })), wrapChildren(props.children, {
135
134
  hasVarDec,
136
135
  varContext: varContextRef.current,
137
136
  textPassThrough