@mpxjs/webpack-plugin 2.10.24 → 2.11.0
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.
- package/lib/index.js +4 -1
- package/lib/platform/style/wx/index.js +417 -120
- package/lib/platform/template/wx/component-config/picker.js +0 -6
- package/lib/react/style-helper.js +6 -6
- package/lib/resolver/AddEnvPlugin.js +1 -1
- package/lib/resolver/AddModePlugin.js +1 -1
- package/lib/resolver/ExtendComponentsPlugin.js +68 -0
- package/lib/runtime/components/extends/section-list.mpx +14 -0
- package/lib/runtime/components/react/animationHooks/index.ts +7 -3
- package/lib/runtime/components/react/dist/animationHooks/index.d.ts +0 -2
- package/lib/runtime/components/react/dist/animationHooks/index.js +6 -1
- package/lib/runtime/components/react/dist/event.config.d.ts +2 -6
- package/lib/runtime/components/react/dist/event.config.js +28 -24
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +1 -1
- package/lib/runtime/components/react/dist/getInnerListeners.js +74 -56
- package/lib/runtime/components/react/dist/mpx-button.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-button.jsx +16 -9
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-camera.jsx +36 -5
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +1 -3
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +8 -9
- package/lib/runtime/components/react/dist/mpx-form.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-form.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-image.jsx +59 -43
- package/lib/runtime/components/react/dist/mpx-inline-text.jsx +13 -4
- package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-input.jsx +16 -8
- package/lib/runtime/components/react/dist/mpx-label.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-label.jsx +5 -6
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +3 -3
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-nav.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +72 -23
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +4 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +10 -14
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.js +0 -5
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +34 -14
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +4 -5
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +3 -5
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +5 -4
- package/lib/runtime/components/react/dist/mpx-popup/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-progress.jsx +1 -3
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-radio.jsx +8 -9
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +1 -3
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-section-list.d.ts +51 -0
- package/lib/runtime/components/react/dist/mpx-section-list.jsx +376 -0
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +37 -19
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +4 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.jsx +11 -4
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-slider.jsx +6 -7
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -2
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +4 -8
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-switch.jsx +1 -3
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-text.jsx +43 -25
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-video.jsx +4 -5
- package/lib/runtime/components/react/dist/mpx-view.d.ts +2 -2
- package/lib/runtime/components/react/dist/mpx-view.jsx +214 -114
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +2 -1
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +5 -1
- package/lib/runtime/components/react/dist/namedColorSet.d.ts +2 -0
- package/lib/runtime/components/react/dist/namedColorSet.js +149 -0
- package/lib/runtime/components/react/dist/utils.d.ts +71 -70
- package/lib/runtime/components/react/dist/utils.jsx +1295 -456
- package/lib/runtime/components/react/event.config.ts +32 -25
- package/lib/runtime/components/react/getInnerListeners.ts +84 -60
- package/lib/runtime/components/react/mpx-button.tsx +18 -18
- package/lib/runtime/components/react/mpx-camera.tsx +40 -8
- package/lib/runtime/components/react/mpx-canvas/index.tsx +5 -7
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -1
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +2 -8
- package/lib/runtime/components/react/mpx-checkbox.tsx +9 -13
- package/lib/runtime/components/react/mpx-form.tsx +6 -8
- package/lib/runtime/components/react/mpx-icon/index.tsx +1 -5
- package/lib/runtime/components/react/mpx-image.tsx +66 -58
- package/lib/runtime/components/react/mpx-inline-text.tsx +13 -4
- package/lib/runtime/components/react/mpx-input.tsx +19 -12
- package/lib/runtime/components/react/mpx-label.tsx +6 -10
- package/lib/runtime/components/react/mpx-movable-area.tsx +3 -5
- package/lib/runtime/components/react/mpx-movable-view.tsx +7 -9
- package/lib/runtime/components/react/mpx-nav.tsx +1 -1
- package/lib/runtime/components/react/mpx-picker/index.tsx +100 -29
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +3 -3
- package/lib/runtime/components/react/mpx-picker/selector.tsx +1 -1
- package/lib/runtime/components/react/mpx-picker/type.ts +4 -0
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +17 -24
- package/lib/runtime/components/react/mpx-picker-view/pickerVIewContext.ts +0 -9
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +44 -23
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +1 -9
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +0 -9
- package/lib/runtime/components/react/mpx-popup/index.tsx +7 -3
- package/lib/runtime/components/react/mpx-popup/popupBase.tsx +3 -2
- package/lib/runtime/components/react/mpx-progress.tsx +0 -6
- package/lib/runtime/components/react/mpx-radio-group.tsx +2 -8
- package/lib/runtime/components/react/mpx-radio.tsx +9 -13
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +0 -6
- package/lib/runtime/components/react/mpx-scroll-view.tsx +7 -9
- package/lib/runtime/components/react/mpx-section-list.tsx +557 -0
- package/lib/runtime/components/react/mpx-simple-text.tsx +36 -25
- package/lib/runtime/components/react/mpx-simple-view.tsx +17 -5
- package/lib/runtime/components/react/mpx-slider.tsx +15 -13
- package/lib/runtime/components/react/mpx-sticky-header.tsx +6 -8
- package/lib/runtime/components/react/mpx-sticky-section.tsx +7 -9
- package/lib/runtime/components/react/mpx-swiper-item.tsx +6 -7
- package/lib/runtime/components/react/mpx-swiper.tsx +5 -11
- package/lib/runtime/components/react/mpx-switch.tsx +0 -6
- package/lib/runtime/components/react/mpx-text.tsx +45 -36
- package/lib/runtime/components/react/mpx-video.tsx +3 -8
- package/lib/runtime/components/react/mpx-view.tsx +235 -129
- package/lib/runtime/components/react/mpx-web-view.tsx +12 -6
- package/lib/runtime/components/react/namedColorSet.ts +150 -0
- package/lib/runtime/components/react/types/getInnerListeners.d.ts +21 -1
- package/lib/runtime/components/react/types/global.d.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +1352 -550
- package/lib/runtime/i18n.wxs +15 -9
- package/lib/style-compiler/strip-conditional.js +19 -4
- package/lib/template-compiler/compiler.js +6 -0
- package/package.json +6 -6
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Text } from 'react-native';
|
|
2
|
-
import { createElement, useContext } from 'react';
|
|
2
|
+
import { createElement, useContext, useRef } from 'react';
|
|
3
3
|
import useInnerProps from './getInnerListeners';
|
|
4
|
-
import { extendObject, getDefaultAllowFontScaling,
|
|
5
|
-
import { TextPassThroughContext } from './context';
|
|
4
|
+
import { extendObject, getDefaultAllowFontScaling, wrapChildren, isStringChildren, transformBoxSizing, splitStyle, isBoxSizingAffectingStyle, resolveTextFontSizePercentStyle, resolveTextLineHeightPercentStyle } from './utils';
|
|
6
5
|
import * as perf from '@mpxjs/perf';
|
|
6
|
+
import { diffAndCloneA } from '@mpxjs/utils';
|
|
7
|
+
import { TextPassThroughContext } from './context';
|
|
7
8
|
const SimpleText = (props) => {
|
|
8
9
|
let idTotal = -1;
|
|
9
10
|
if (__mpx_perf_framework__)
|
|
@@ -12,23 +13,40 @@ const SimpleText = (props) => {
|
|
|
12
13
|
let idStyle = -1;
|
|
13
14
|
if (__mpx_perf_framework__)
|
|
14
15
|
idStyle = perf.scopeStart('simple-text:render:style');
|
|
15
|
-
const inheritedText = useContext(TextPassThroughContext);
|
|
16
|
-
const mergedStyle = extendObject({}, inheritedText?.textStyle, props.style);
|
|
17
16
|
let hasBoxSizingAffectingStyle = false;
|
|
18
|
-
const { textStyle
|
|
17
|
+
const { textStyle } = splitStyle(props.style, (key) => {
|
|
19
18
|
if (!hasBoxSizingAffectingStyle && isBoxSizingAffectingStyle(key)) {
|
|
20
19
|
hasBoxSizingAffectingStyle = true;
|
|
21
20
|
}
|
|
22
21
|
});
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
const inheritedText = useContext(TextPassThroughContext);
|
|
23
|
+
const resolvedTextStyle = resolveTextFontSizePercentStyle(textStyle, inheritedText?.textStyle);
|
|
24
|
+
// textStyle 仅在子节点非纯字符串时才需要透传给子级;按需计算 isStringChildren
|
|
25
|
+
const childTextStyle = resolvedTextStyle && !isStringChildren(props.children)
|
|
26
|
+
? resolvedTextStyle
|
|
27
|
+
: undefined;
|
|
28
|
+
const textPassThroughRef = useRef(null);
|
|
29
|
+
let textPassThrough = null;
|
|
30
|
+
if (childTextStyle) {
|
|
31
|
+
const nextTextPassThrough = {
|
|
32
|
+
textStyle: extendObject({}, inheritedText?.textStyle, childTextStyle)
|
|
33
|
+
};
|
|
34
|
+
if (diffAndCloneA(textPassThroughRef.current, nextTextPassThrough).diff) {
|
|
35
|
+
textPassThroughRef.current = nextTextPassThrough;
|
|
36
|
+
}
|
|
37
|
+
textPassThrough = textPassThroughRef.current;
|
|
38
|
+
}
|
|
39
|
+
const mergedProps = inheritedText?.pendingTextProps
|
|
40
|
+
? extendObject({}, inheritedText.pendingTextProps, props)
|
|
41
|
+
: props;
|
|
42
|
+
const mergedStyle = inheritedText?.textStyle || props.style
|
|
43
|
+
? extendObject({}, inheritedText?.textStyle, props.style, resolvedTextStyle)
|
|
44
|
+
: undefined;
|
|
45
|
+
if (mergedStyle) {
|
|
46
|
+
resolveTextLineHeightPercentStyle(mergedStyle, inheritedText?.textStyle);
|
|
47
|
+
if (hasBoxSizingAffectingStyle)
|
|
48
|
+
transformBoxSizing(mergedStyle);
|
|
49
|
+
}
|
|
32
50
|
if (__mpx_perf_framework__)
|
|
33
51
|
perf.scopeEnd(idStyle);
|
|
34
52
|
// ───── innerProps 阶段 ─────
|
|
@@ -36,8 +54,8 @@ const SimpleText = (props) => {
|
|
|
36
54
|
if (__mpx_perf_framework__)
|
|
37
55
|
idInnerProps = perf.scopeStart('simple-text:render:innerProps');
|
|
38
56
|
const innerProps = useInnerProps(extendObject({}, mergedProps, {
|
|
39
|
-
allowFontScaling: allowFontScaling ?? getDefaultAllowFontScaling(),
|
|
40
|
-
style:
|
|
57
|
+
allowFontScaling: mergedProps.allowFontScaling ?? getDefaultAllowFontScaling(),
|
|
58
|
+
style: mergedStyle
|
|
41
59
|
}));
|
|
42
60
|
if (__mpx_perf_framework__)
|
|
43
61
|
perf.scopeEnd(idInnerProps);
|
|
@@ -45,9 +63,9 @@ const SimpleText = (props) => {
|
|
|
45
63
|
let idCreate = -1;
|
|
46
64
|
if (__mpx_perf_framework__)
|
|
47
65
|
idCreate = perf.scopeStart('simple-text:render:createElement');
|
|
48
|
-
const result = createElement(Text, innerProps, wrapChildren(
|
|
66
|
+
const result = createElement(Text, innerProps, wrapChildren(mergedProps.children, {
|
|
49
67
|
hasVarDec: false,
|
|
50
|
-
textPassThrough
|
|
68
|
+
textPassThrough
|
|
51
69
|
}));
|
|
52
70
|
if (__mpx_perf_framework__)
|
|
53
71
|
perf.scopeEnd(idCreate);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ViewProps } from 'react-native';
|
|
3
|
+
interface SimpleViewProps extends ViewProps {
|
|
4
|
+
'enable-text-pass-through'?: boolean;
|
|
5
|
+
}
|
|
3
6
|
declare const SimpleView: {
|
|
4
|
-
(simpleViewProps:
|
|
7
|
+
(simpleViewProps: SimpleViewProps): JSX.Element;
|
|
5
8
|
displayName: string;
|
|
6
9
|
};
|
|
7
10
|
export default SimpleView;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { View } from 'react-native';
|
|
2
2
|
import { createElement } from 'react';
|
|
3
|
-
import { splitProps, splitStyle, wrapChildren, extendObject,
|
|
3
|
+
import { splitProps, splitStyle, wrapChildren, extendObject, useTextPassThrough, transformBoxSizing, isBoxSizingAffectingStyle } from './utils';
|
|
4
4
|
import useInnerProps from './getInnerListeners';
|
|
5
5
|
import * as perf from '@mpxjs/perf';
|
|
6
6
|
const SimpleView = (simpleViewProps) => {
|
|
@@ -12,13 +12,20 @@ const SimpleView = (simpleViewProps) => {
|
|
|
12
12
|
if (__mpx_perf_framework__)
|
|
13
13
|
idStyle = perf.scopeStart('simple-view:render:style');
|
|
14
14
|
const { textProps, innerProps: props = {} } = splitProps(simpleViewProps);
|
|
15
|
+
const enableTextPassThrough = props['enable-text-pass-through'];
|
|
15
16
|
let hasBoxSizingAffectingStyle = false;
|
|
16
17
|
const { textStyle, innerStyle = {} } = splitStyle(props.style || {}, (key) => {
|
|
17
18
|
if (!hasBoxSizingAffectingStyle && isBoxSizingAffectingStyle(key)) {
|
|
18
19
|
hasBoxSizingAffectingStyle = true;
|
|
19
20
|
}
|
|
20
21
|
});
|
|
21
|
-
const textPassThrough =
|
|
22
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
|
|
23
|
+
let styleObj = innerStyle;
|
|
24
|
+
if (hasBoxSizingAffectingStyle) {
|
|
25
|
+
// 复制一次再 mutate,避免污染 splitStyle 复用的原 props.style
|
|
26
|
+
styleObj = extendObject({}, innerStyle);
|
|
27
|
+
transformBoxSizing(styleObj);
|
|
28
|
+
}
|
|
22
29
|
if (__mpx_perf_framework__)
|
|
23
30
|
perf.scopeEnd(idStyle);
|
|
24
31
|
// ───── innerProps 阶段 ─────
|
|
@@ -26,7 +33,7 @@ const SimpleView = (simpleViewProps) => {
|
|
|
26
33
|
if (__mpx_perf_framework__)
|
|
27
34
|
idInnerProps = perf.scopeStart('simple-view:render:innerProps');
|
|
28
35
|
const innerProps = useInnerProps(extendObject({}, props, {
|
|
29
|
-
style:
|
|
36
|
+
style: styleObj
|
|
30
37
|
}));
|
|
31
38
|
if (__mpx_perf_framework__)
|
|
32
39
|
perf.scopeEnd(idInnerProps);
|
|
@@ -34,7 +41,7 @@ const SimpleView = (simpleViewProps) => {
|
|
|
34
41
|
let idCreate = -1;
|
|
35
42
|
if (__mpx_perf_framework__)
|
|
36
43
|
idCreate = perf.scopeStart('simple-view:render:createElement');
|
|
37
|
-
const result = createElement(View, innerProps, wrapChildren(props, {
|
|
44
|
+
const result = createElement(View, innerProps, wrapChildren(props.children, {
|
|
38
45
|
hasVarDec: false,
|
|
39
46
|
textPassThrough
|
|
40
47
|
}));
|
|
@@ -21,8 +21,6 @@ export interface SliderProps {
|
|
|
21
21
|
style?: ViewStyle & Record<string, any>;
|
|
22
22
|
'enable-offset'?: boolean;
|
|
23
23
|
'enable-var'?: boolean;
|
|
24
|
-
'external-var-context'?: Record<string, any>;
|
|
25
|
-
'parent-font-size'?: number;
|
|
26
24
|
'parent-width'?: number;
|
|
27
25
|
'parent-height'?: number;
|
|
28
26
|
}
|
|
@@ -18,14 +18,14 @@ import { useRef, forwardRef, useEffect, useState, createElement, useContext, use
|
|
|
18
18
|
import { View } from 'react-native';
|
|
19
19
|
import { GestureDetector, Gesture } from 'react-native-gesture-handler';
|
|
20
20
|
import Animated, { useSharedValue, useAnimatedStyle, runOnJS } from 'react-native-reanimated';
|
|
21
|
-
import { warn } from '@mpxjs/utils';
|
|
21
|
+
import { warn, hasOwn } from '@mpxjs/utils';
|
|
22
22
|
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
23
23
|
import useNodesRef from './useNodesRef';
|
|
24
24
|
import { useLayout, useTransformStyle, extendObject, useRunOnJSCallback } from './utils';
|
|
25
25
|
import Portal from './mpx-portal';
|
|
26
26
|
import { FormContext } from './context';
|
|
27
27
|
const Slider = forwardRef((props, ref) => {
|
|
28
|
-
const { min: rawMin = 0, max: rawMax = 100, step: rawStep = 1, disabled = false, value: rawValue, color, 'selected-color': selectedColor, activeColor = selectedColor || color || '#1aad19', backgroundColor = color || '#e9e9e9', 'block-size': rawBlockSize = 28, 'block-color': blockColor = '#ffffff', name, style = {}, 'enable-var': enableVar, '
|
|
28
|
+
const { min: rawMin = 0, max: rawMax = 100, step: rawStep = 1, disabled = false, value: rawValue, color, 'selected-color': selectedColor, activeColor = selectedColor || color || '#1aad19', backgroundColor = color || '#e9e9e9', 'block-size': rawBlockSize = 28, 'block-color': blockColor = '#ffffff', name, style = {}, 'enable-var': enableVar, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
29
29
|
// 确保数值类型正确
|
|
30
30
|
const min = typeof rawMin === 'string' ? parseFloat(rawMin) : rawMin;
|
|
31
31
|
const max = typeof rawMax === 'string' ? parseFloat(rawMax) : rawMax;
|
|
@@ -51,8 +51,6 @@ const Slider = forwardRef((props, ref) => {
|
|
|
51
51
|
}
|
|
52
52
|
const { normalStyle, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(style, {
|
|
53
53
|
enableVar,
|
|
54
|
-
externalVarContext,
|
|
55
|
-
parentFontSize,
|
|
56
54
|
parentWidth,
|
|
57
55
|
parentHeight
|
|
58
56
|
});
|
|
@@ -239,12 +237,13 @@ const Slider = forwardRef((props, ref) => {
|
|
|
239
237
|
// 样式定义
|
|
240
238
|
const blockSizeNum = Math.max(12, Math.min(28, blockSize));
|
|
241
239
|
const trackHeight = 4;
|
|
240
|
+
// 用户传 padding shorthand 时跳过 paddingLeft/Right default,
|
|
241
|
+
// 避免 number 形式 padding:0 被 longhand default 反向覆盖
|
|
242
242
|
const containerStyle = extendObject({}, {
|
|
243
243
|
flexDirection: 'row',
|
|
244
244
|
alignItems: 'center',
|
|
245
|
-
minHeight: Math.max(blockSizeNum + 8, 40)
|
|
246
|
-
|
|
247
|
-
}, normalStyle, layoutStyle);
|
|
245
|
+
minHeight: Math.max(blockSizeNum + 8, 40)
|
|
246
|
+
}, hasOwn(style, 'padding') ? null : { paddingHorizontal: 14 }, hasOwn(style, 'margin') ? null : { marginHorizontal: 18, marginVertical: 10 }, normalStyle, layoutStyle);
|
|
248
247
|
const trackStyle = {
|
|
249
248
|
flex: 1,
|
|
250
249
|
height: trackHeight,
|
|
@@ -7,8 +7,7 @@ interface StickyHeaderProps {
|
|
|
7
7
|
padding?: [number, number, number, number];
|
|
8
8
|
'offset-top'?: number;
|
|
9
9
|
'enable-var'?: boolean;
|
|
10
|
-
'
|
|
11
|
-
'parent-font-size'?: number;
|
|
10
|
+
'enable-text-pass-through'?: boolean;
|
|
12
11
|
'parent-width'?: number;
|
|
13
12
|
'parent-height'?: number;
|
|
14
13
|
bindstickontopchange?: (e: NativeSyntheticEvent<unknown>) => void;
|
|
@@ -2,22 +2,22 @@ import { useEffect, useRef, useContext, forwardRef, useMemo, createElement, useI
|
|
|
2
2
|
import { Animated, StyleSheet, useAnimatedValue } from 'react-native';
|
|
3
3
|
import { ScrollViewContext, StickyContext } from './context';
|
|
4
4
|
import useNodesRef from './useNodesRef';
|
|
5
|
-
import { splitProps, splitStyle, useTransformStyle, wrapChildren, useLayout, extendObject,
|
|
5
|
+
import { splitProps, splitStyle, useTransformStyle, wrapChildren, useLayout, extendObject, useTextPassThrough } from './utils';
|
|
6
6
|
import { error } from '@mpxjs/utils';
|
|
7
7
|
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
8
8
|
const _StickyHeader = forwardRef((stickyHeaderProps = {}, ref) => {
|
|
9
9
|
const { textProps, innerProps: props = {} } = splitProps(stickyHeaderProps);
|
|
10
|
-
const { style, bindstickontopchange, padding = [0, 0, 0, 0], 'offset-top': offsetTop = 0, 'enable-var': enableVar, '
|
|
10
|
+
const { style, bindstickontopchange, padding = [0, 0, 0, 0], 'offset-top': offsetTop = 0, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
11
11
|
const { scrollOffset, gestureRef: scrollViewRef } = useContext(ScrollViewContext);
|
|
12
12
|
const stickyContext = useContext(StickyContext);
|
|
13
13
|
const { registerStickyHeader, unregisterStickyHeader } = stickyContext;
|
|
14
14
|
const headerRef = useRef(null);
|
|
15
15
|
const isStickOnTopRef = useRef(false);
|
|
16
16
|
const id = useId();
|
|
17
|
-
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar,
|
|
17
|
+
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentWidth, parentHeight });
|
|
18
18
|
const { layoutRef, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: headerRef, onLayout });
|
|
19
19
|
const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
|
|
20
|
-
const textPassThrough =
|
|
20
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
|
|
21
21
|
const headerTopAnimated = useAnimatedValue(0);
|
|
22
22
|
// harmony animatedValue 不支持通过 _value 访问
|
|
23
23
|
const headerTopRef = useRef(0);
|
|
@@ -103,7 +103,7 @@ const _StickyHeader = forwardRef((stickyHeaderProps = {}, ref) => {
|
|
|
103
103
|
'offset-top',
|
|
104
104
|
'bindstickontopchange'
|
|
105
105
|
], { layoutRef });
|
|
106
|
-
return (createElement(Animated.View, innerProps, wrapChildren(props, {
|
|
106
|
+
return (createElement(Animated.View, innerProps, wrapChildren(props.children, {
|
|
107
107
|
hasVarDec,
|
|
108
108
|
varContext: varContextRef.current,
|
|
109
109
|
textPassThrough
|
|
@@ -6,8 +6,7 @@ interface StickySectionProps {
|
|
|
6
6
|
style?: ViewStyle;
|
|
7
7
|
'offset-top'?: number;
|
|
8
8
|
'enable-var'?: boolean;
|
|
9
|
-
'
|
|
10
|
-
'parent-font-size'?: number;
|
|
9
|
+
'enable-text-pass-through'?: boolean;
|
|
11
10
|
'parent-width'?: number;
|
|
12
11
|
'parent-height'?: number;
|
|
13
12
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { useRef, forwardRef, createElement, useCallback, useMemo } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import useNodesRef from './useNodesRef';
|
|
4
|
-
import { splitProps, splitStyle, useTransformStyle, wrapChildren, useLayout, extendObject,
|
|
4
|
+
import { splitProps, splitStyle, useTransformStyle, wrapChildren, useLayout, extendObject, useTextPassThrough } from './utils';
|
|
5
5
|
import { StickyContext } from './context';
|
|
6
6
|
import useInnerProps from './getInnerListeners';
|
|
7
7
|
const _StickySection = forwardRef((stickySectionProps = {}, ref) => {
|
|
8
8
|
const { textProps, innerProps: props = {} } = splitProps(stickySectionProps);
|
|
9
|
-
const { style, 'enable-var': enableVar, '
|
|
9
|
+
const { style, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
10
10
|
const sectionRef = useRef(null);
|
|
11
|
-
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar,
|
|
11
|
+
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentWidth, parentHeight });
|
|
12
12
|
const { layoutRef, layoutProps, layoutStyle } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: sectionRef, onLayout });
|
|
13
13
|
const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
|
|
14
|
-
const textPassThrough =
|
|
14
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
|
|
15
15
|
const stickyHeaders = useRef(new Map());
|
|
16
16
|
const registerStickyHeader = useCallback((item) => {
|
|
17
17
|
stickyHeaders.current.set(item.id, item);
|
|
@@ -32,12 +32,12 @@ const _StickySection = forwardRef((stickySectionProps = {}, ref) => {
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
const innerProps = useInnerProps(extendObject({}, props, {
|
|
35
|
-
style: extendObject(innerStyle, layoutStyle),
|
|
35
|
+
style: extendObject({}, innerStyle, layoutStyle),
|
|
36
36
|
ref: sectionRef
|
|
37
37
|
}, layoutProps), [
|
|
38
38
|
'offset-top'
|
|
39
39
|
], { layoutRef });
|
|
40
|
-
return (createElement(View, innerProps, createElement(StickyContext.Provider, { value: contextValue }, wrapChildren(props, {
|
|
40
|
+
return (createElement(View, innerProps, createElement(StickyContext.Provider, { value: contextValue }, wrapChildren(props.children, {
|
|
41
41
|
hasVarDec,
|
|
42
42
|
varContext: varContextRef.current,
|
|
43
43
|
textPassThrough
|
|
@@ -5,8 +5,7 @@ interface SwiperItemProps {
|
|
|
5
5
|
'item-id'?: string;
|
|
6
6
|
'enable-offset'?: boolean;
|
|
7
7
|
'enable-var': boolean;
|
|
8
|
-
'
|
|
9
|
-
'parent-font-size'?: number;
|
|
8
|
+
'enable-text-pass-through'?: boolean;
|
|
10
9
|
'parent-width'?: number;
|
|
11
10
|
'parent-height'?: number;
|
|
12
11
|
children?: ReactNode;
|
|
@@ -2,10 +2,10 @@ import Animated, { useAnimatedStyle, interpolate } from 'react-native-reanimated
|
|
|
2
2
|
import { forwardRef, useRef, useContext, createElement } from 'react';
|
|
3
3
|
import useInnerProps from './getInnerListeners';
|
|
4
4
|
import useNodesRef from './useNodesRef'; // 引入辅助函数
|
|
5
|
-
import { useTransformStyle, splitStyle, splitProps, wrapChildren, useLayout, extendObject, isHarmony,
|
|
5
|
+
import { useTransformStyle, splitStyle, splitProps, wrapChildren, useLayout, extendObject, isHarmony, useTextPassThrough } from './utils';
|
|
6
6
|
import { SwiperContext } from './context';
|
|
7
7
|
const _SwiperItem = forwardRef((props, ref) => {
|
|
8
|
-
const { 'enable-var': enableVar, '
|
|
8
|
+
const { 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, style, customStyle, itemIndex } = props;
|
|
9
9
|
const contextValue = useContext(SwiperContext);
|
|
10
10
|
const offset = contextValue.offset || 0;
|
|
11
11
|
const step = contextValue.step || 0;
|
|
@@ -13,9 +13,9 @@ const _SwiperItem = forwardRef((props, ref) => {
|
|
|
13
13
|
const dir = contextValue.dir || 'x';
|
|
14
14
|
const { textProps } = splitProps(props);
|
|
15
15
|
const nodeRef = useRef(null);
|
|
16
|
-
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar
|
|
16
|
+
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar });
|
|
17
17
|
const { textStyle, innerStyle } = splitStyle(normalStyle);
|
|
18
|
-
const textPassThrough =
|
|
18
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
|
|
19
19
|
useNodesRef(props, ref, nodeRef, {
|
|
20
20
|
style: normalStyle
|
|
21
21
|
});
|
|
@@ -53,7 +53,7 @@ const _SwiperItem = forwardRef((props, ref) => {
|
|
|
53
53
|
style: [innerStyle, layoutStyle, itemAnimatedStyle, customStyle],
|
|
54
54
|
'data-itemId': props['item-id']
|
|
55
55
|
});
|
|
56
|
-
return createElement(Animated.View, mergeProps, wrapChildren(props, {
|
|
56
|
+
return createElement(Animated.View, mergeProps, wrapChildren(props.children, {
|
|
57
57
|
hasVarDec,
|
|
58
58
|
varContext: varContextRef.current,
|
|
59
59
|
textPassThrough
|
|
@@ -49,10 +49,9 @@ interface SwiperProps {
|
|
|
49
49
|
'next-margin'?: string;
|
|
50
50
|
'enable-offset'?: boolean;
|
|
51
51
|
'enable-var': boolean;
|
|
52
|
-
'
|
|
52
|
+
'enable-text-pass-through'?: boolean;
|
|
53
53
|
'parent-width'?: number;
|
|
54
54
|
'parent-height'?: number;
|
|
55
|
-
'external-var-context'?: Record<string, any>;
|
|
56
55
|
'wait-for'?: Array<GestureHandler>;
|
|
57
56
|
'simultaneous-handlers'?: Array<GestureHandler>;
|
|
58
57
|
disableGesture?: boolean;
|
|
@@ -4,7 +4,7 @@ import Animated, { useAnimatedStyle, useSharedValue, withTiming, Easing, runOnJS
|
|
|
4
4
|
import React, { forwardRef, useRef, useEffect, useMemo, createElement } from 'react';
|
|
5
5
|
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
6
6
|
import useNodesRef from './useNodesRef'; // 引入辅助函数
|
|
7
|
-
import { useTransformStyle, splitStyle, splitProps, useLayout, wrapChildren, extendObject, flatGesture, useRunOnJSCallback,
|
|
7
|
+
import { useTransformStyle, splitStyle, splitProps, useLayout, wrapChildren, extendObject, flatGesture, useRunOnJSCallback, useTextPassThrough } from './utils';
|
|
8
8
|
import { SwiperContext } from './context';
|
|
9
9
|
import Portal from './mpx-portal';
|
|
10
10
|
/**
|
|
@@ -61,7 +61,7 @@ const easeMap = {
|
|
|
61
61
|
easeInOutCubic: Easing.inOut(Easing.cubic)
|
|
62
62
|
};
|
|
63
63
|
const SwiperWrapper = forwardRef((props, ref) => {
|
|
64
|
-
const { 'indicator-dots': showPagination, 'indicator-color': dotColor = 'rgba(0, 0, 0, .3)', 'indicator-width': dotWidth = 8, 'indicator-height': dotHeight = 8, 'indicator-radius': dotRadius = 4, 'indicator-spacing': dotSpacing = 4, 'indicator-margin': paginationMargin = 10, 'indicator-active-color': activeDotColor = '#000000', 'enable-var': enableVar = false, '
|
|
64
|
+
const { 'indicator-dots': showPagination, 'indicator-color': dotColor = 'rgba(0, 0, 0, .3)', 'indicator-width': dotWidth = 8, 'indicator-height': dotHeight = 8, 'indicator-radius': dotRadius = 4, 'indicator-spacing': dotSpacing = 4, 'indicator-margin': paginationMargin = 10, 'indicator-active-color': activeDotColor = '#000000', 'enable-var': enableVar = false, 'enable-text-pass-through': enableTextPassThrough, 'parent-width': parentWidth, 'parent-height': parentHeight, 'simultaneous-handlers': originSimultaneousHandlers = [], 'wait-for': waitFor = [], style = {}, autoplay = false, circular = false, disableGesture = false, current: propCurrent = 0, bindchange } = props;
|
|
65
65
|
const dotCommonStyle = {
|
|
66
66
|
width: dotWidth,
|
|
67
67
|
height: dotHeight,
|
|
@@ -85,14 +85,12 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
85
85
|
// 计算transfrom之类的
|
|
86
86
|
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, hasPositionFixed, setWidth, setHeight } = useTransformStyle(style, {
|
|
87
87
|
enableVar,
|
|
88
|
-
externalVarContext,
|
|
89
|
-
parentFontSize,
|
|
90
88
|
parentWidth,
|
|
91
89
|
parentHeight
|
|
92
90
|
});
|
|
93
91
|
const { textStyle } = splitStyle(normalStyle);
|
|
94
92
|
const { textProps } = splitProps(props);
|
|
95
|
-
const textPassThrough =
|
|
93
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
|
|
96
94
|
const preMargin = props['previous-margin'] ? global.__formatValue(props['previous-margin']) : 0;
|
|
97
95
|
const nextMargin = props['next-margin'] ? global.__formatValue(props['next-margin']) : 0;
|
|
98
96
|
const preMarginShared = useSharedValue(preMargin);
|
|
@@ -817,9 +815,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
817
815
|
const animateComponent = createElement(Animated.View, {
|
|
818
816
|
key: 'swiperContainer',
|
|
819
817
|
style: [{ flexDirection: dir === 'x' ? 'row' : 'column', width: '100%', height: '100%' }, animatedStyles]
|
|
820
|
-
}, wrapChildren({
|
|
821
|
-
children: arrPages
|
|
822
|
-
}, {
|
|
818
|
+
}, wrapChildren(arrPages, {
|
|
823
819
|
hasVarDec,
|
|
824
820
|
varContext: varContextRef.current,
|
|
825
821
|
textPassThrough
|
|
@@ -15,10 +15,8 @@ interface _SwitchProps extends SwitchProps {
|
|
|
15
15
|
disabled: boolean;
|
|
16
16
|
color: string;
|
|
17
17
|
'enable-var'?: boolean;
|
|
18
|
-
'parent-font-size'?: number;
|
|
19
18
|
'parent-width'?: number;
|
|
20
19
|
'parent-height'?: number;
|
|
21
|
-
'external-var-context'?: Record<string, any>;
|
|
22
20
|
bindchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
23
21
|
catchchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
24
22
|
}
|
|
@@ -14,7 +14,7 @@ import Portal from './mpx-portal';
|
|
|
14
14
|
import { FormContext } from './context';
|
|
15
15
|
import { useTransformStyle, useLayout, extendObject } from './utils';
|
|
16
16
|
const _Switch = forwardRef((props, ref) => {
|
|
17
|
-
const { style = {}, checked = false, type = 'switch', disabled = false, color = '#04BE02', 'enable-var': enableVar, '
|
|
17
|
+
const { style = {}, checked = false, type = 'switch', disabled = false, color = '#04BE02', 'enable-var': enableVar, 'parent-width': parentWidth, 'parent-height': parentHeight, bindchange, catchchange } = props;
|
|
18
18
|
const [isChecked, setIsChecked] = useState(checked);
|
|
19
19
|
const changeHandler = bindchange || catchchange;
|
|
20
20
|
let formValuesMap;
|
|
@@ -24,8 +24,6 @@ const _Switch = forwardRef((props, ref) => {
|
|
|
24
24
|
}
|
|
25
25
|
const { normalStyle, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(style, {
|
|
26
26
|
enableVar,
|
|
27
|
-
externalVarContext,
|
|
28
|
-
parentFontSize,
|
|
29
27
|
parentWidth,
|
|
30
28
|
parentHeight
|
|
31
29
|
});
|
|
@@ -12,8 +12,6 @@ interface _TextProps extends TextProps {
|
|
|
12
12
|
selectable?: boolean;
|
|
13
13
|
'user-select'?: boolean;
|
|
14
14
|
'enable-var'?: boolean;
|
|
15
|
-
'external-var-context'?: Record<string, any>;
|
|
16
|
-
'parent-font-size'?: number;
|
|
17
15
|
'parent-width'?: number;
|
|
18
16
|
'parent-height'?: number;
|
|
19
17
|
decode?: boolean;
|
|
@@ -8,9 +8,10 @@ import { useRef, forwardRef, createElement, Children, useContext } from 'react';
|
|
|
8
8
|
import Portal from './mpx-portal';
|
|
9
9
|
import useInnerProps from './getInnerListeners';
|
|
10
10
|
import useNodesRef from './useNodesRef'; // 引入辅助函数
|
|
11
|
-
import { useTransformStyle, wrapChildren, extendObject, getDefaultAllowFontScaling,
|
|
12
|
-
import { TextPassThroughContext } from './context';
|
|
11
|
+
import { useTransformStyle, wrapChildren, extendObject, getDefaultAllowFontScaling, isStringChildren, splitStyle, resolveTextFontSizePercentStyle, resolveTextLineHeightPercentStyle } from './utils';
|
|
13
12
|
import * as perf from '@mpxjs/perf';
|
|
13
|
+
import { diffAndCloneA } from '@mpxjs/utils';
|
|
14
|
+
import { TextPassThroughContext } from './context';
|
|
14
15
|
const decodeMap = {
|
|
15
16
|
'<': '<',
|
|
16
17
|
'>': '>',
|
|
@@ -28,12 +29,17 @@ function decode(value) {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
function getDecodedChildren(children) {
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
if (typeof children === 'string') {
|
|
33
|
+
return { children: decode(children), isStringOnly: true };
|
|
34
|
+
}
|
|
35
|
+
let isStringOnly = true;
|
|
36
|
+
const decoded = Children.map(children, (child) => {
|
|
37
|
+
if (typeof child === 'string')
|
|
33
38
|
return decode(child);
|
|
34
|
-
|
|
39
|
+
isStringOnly = false;
|
|
35
40
|
return child;
|
|
36
41
|
});
|
|
42
|
+
return { children: decoded, isStringOnly };
|
|
37
43
|
}
|
|
38
44
|
const _Text = forwardRef((props, ref) => {
|
|
39
45
|
let idTotal = -1;
|
|
@@ -43,9 +49,7 @@ const _Text = forwardRef((props, ref) => {
|
|
|
43
49
|
let idProps = -1;
|
|
44
50
|
if (__mpx_perf_framework__)
|
|
45
51
|
idProps = perf.scopeStart('text:render:props');
|
|
46
|
-
const
|
|
47
|
-
const mergedProps = extendObject({}, inheritedText?.pendingTextProps, props);
|
|
48
|
-
const { style: currentStyle = {}, allowFontScaling, selectable, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'user-select': userSelect, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, decode } = mergedProps;
|
|
52
|
+
const { style: currentStyle = {}, allowFontScaling, selectable, 'enable-var': enableVar, 'user-select': userSelect, 'parent-width': parentWidth, 'parent-height': parentHeight, decode } = props;
|
|
49
53
|
if (__mpx_perf_framework__)
|
|
50
54
|
perf.scopeEnd(idProps);
|
|
51
55
|
// ───── style 阶段 ─────
|
|
@@ -54,27 +58,43 @@ const _Text = forwardRef((props, ref) => {
|
|
|
54
58
|
idStyle = perf.scopeStart('text:render:style');
|
|
55
59
|
const { normalStyle, hasVarDec, varContextRef, hasPositionFixed } = useTransformStyle(currentStyle, {
|
|
56
60
|
enableVar,
|
|
57
|
-
externalVarContext,
|
|
58
|
-
parentFontSize,
|
|
59
61
|
parentWidth,
|
|
60
62
|
parentHeight
|
|
61
63
|
});
|
|
62
|
-
|
|
64
|
+
let children;
|
|
65
|
+
let isStringOnly;
|
|
66
|
+
if (decode) {
|
|
67
|
+
({ children, isStringOnly } = getDecodedChildren(props.children));
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
children = props.children;
|
|
71
|
+
isStringOnly = isStringChildren(children);
|
|
72
|
+
}
|
|
73
|
+
const inheritedText = useContext(TextPassThroughContext);
|
|
74
|
+
const resolvedNormalStyle = resolveTextFontSizePercentStyle(normalStyle, inheritedText?.textStyle);
|
|
75
|
+
const childTextStyle = !isStringOnly ? splitStyle(resolvedNormalStyle).textStyle : undefined;
|
|
76
|
+
const textPassThroughRef = useRef(null);
|
|
77
|
+
let textPassThrough = null;
|
|
78
|
+
if (childTextStyle) {
|
|
79
|
+
const nextTextPassThrough = {
|
|
80
|
+
textStyle: extendObject({}, inheritedText?.textStyle, childTextStyle)
|
|
81
|
+
};
|
|
82
|
+
if (diffAndCloneA(textPassThroughRef.current, nextTextPassThrough).diff) {
|
|
83
|
+
textPassThroughRef.current = nextTextPassThrough;
|
|
84
|
+
}
|
|
85
|
+
textPassThrough = textPassThroughRef.current;
|
|
86
|
+
}
|
|
87
|
+
const mergedProps = inheritedText?.pendingTextProps
|
|
88
|
+
? extendObject({}, inheritedText.pendingTextProps, props)
|
|
89
|
+
: props;
|
|
90
|
+
const finalStyle = inheritedText?.textStyle
|
|
91
|
+
? extendObject({}, inheritedText.textStyle, resolvedNormalStyle)
|
|
92
|
+
: resolvedNormalStyle;
|
|
93
|
+
resolveTextLineHeightPercentStyle(finalStyle, inheritedText?.textStyle);
|
|
63
94
|
const nodeRef = useRef(null);
|
|
64
95
|
useNodesRef(mergedProps, ref, nodeRef, {
|
|
65
96
|
style: finalStyle
|
|
66
97
|
});
|
|
67
|
-
const children = decode ? getDecodedChildren(mergedProps.children) : mergedProps.children;
|
|
68
|
-
const isStringOnly = isStringChildren(children);
|
|
69
|
-
let childTextStyle;
|
|
70
|
-
if (!isStringOnly) {
|
|
71
|
-
const { textStyle = {} } = splitStyle(finalStyle);
|
|
72
|
-
childTextStyle = Object.keys(textStyle).length ? textStyle : undefined;
|
|
73
|
-
}
|
|
74
|
-
const textPassThrough = useTextPassThroughValue(childTextStyle, undefined, {
|
|
75
|
-
inheritTextProps: false,
|
|
76
|
-
disabled: isStringOnly
|
|
77
|
-
});
|
|
78
98
|
if (__mpx_perf_framework__)
|
|
79
99
|
perf.scopeEnd(idStyle);
|
|
80
100
|
// ───── innerProps 阶段 ─────
|
|
@@ -96,9 +116,7 @@ const _Text = forwardRef((props, ref) => {
|
|
|
96
116
|
let idCreate = -1;
|
|
97
117
|
if (__mpx_perf_framework__)
|
|
98
118
|
idCreate = perf.scopeStart('text:render:createElement');
|
|
99
|
-
let finalComponent = createElement(Text, innerProps, wrapChildren(
|
|
100
|
-
children
|
|
101
|
-
}), {
|
|
119
|
+
let finalComponent = createElement(Text, innerProps, wrapChildren(children, {
|
|
102
120
|
hasVarDec,
|
|
103
121
|
varContext: varContextRef.current,
|
|
104
122
|
textPassThrough
|
|
@@ -83,8 +83,6 @@ interface VideoProps {
|
|
|
83
83
|
'preferred-peak-bit-rate'?: number;
|
|
84
84
|
'enable-auto-rotation'?: number;
|
|
85
85
|
'enable-var'?: boolean;
|
|
86
|
-
'external-var-context'?: Record<string, any>;
|
|
87
|
-
'parent-font-size'?: number;
|
|
88
86
|
'parent-width'?: number;
|
|
89
87
|
'parent-height'?: number;
|
|
90
88
|
bindplay?: (event: Record<string, any>) => void;
|
|
@@ -80,18 +80,17 @@ const styles = StyleSheet.create({
|
|
|
80
80
|
});
|
|
81
81
|
const MpxVideo = forwardRef((videoProps, ref) => {
|
|
82
82
|
const { innerProps: props = {} } = splitProps(videoProps);
|
|
83
|
-
const { src, autoplay = false, loop = false, muted = false, controls = true, poster = '', bindplay, bindpause, bindended, bindtimeupdate, bindfullscreenchange, bindwaiting, binderror, bindloadedmetadata, bindcontrolstoggle, bindseekcomplete, style, 'initial-time': initialTime = 0, 'object-fit': objectFit = 'contain', 'is-drm': isDrm = false, 'provision-url': provisionUrl, 'certificate-url': certificateUrl, 'license-url': licenseUrl, 'preferred-peak-bit-rate': preferredPeakBitRate = 0, 'enable-auto-rotation': enableAutoRotation = false, 'enable-var': enableVar, '
|
|
83
|
+
const { src, autoplay = false, loop = false, muted = false, controls = true, poster = '', bindplay, bindpause, bindended, bindtimeupdate, bindfullscreenchange, bindwaiting, binderror, bindloadedmetadata, bindcontrolstoggle, bindseekcomplete, style, 'initial-time': initialTime = 0, 'object-fit': objectFit = 'contain', 'is-drm': isDrm = false, 'provision-url': provisionUrl, 'certificate-url': certificateUrl, 'license-url': licenseUrl, 'preferred-peak-bit-rate': preferredPeakBitRate = 0, 'enable-auto-rotation': enableAutoRotation = false, 'enable-var': enableVar, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
84
84
|
const videoRef = useRef(null);
|
|
85
85
|
const viewRef = useRef(null);
|
|
86
86
|
const videoInfoRef = useRef({});
|
|
87
87
|
const propsRef = useRef({});
|
|
88
88
|
propsRef.current = props;
|
|
89
|
-
const { normalStyle, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(
|
|
89
|
+
const { normalStyle, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(style, {
|
|
90
90
|
enableVar,
|
|
91
|
-
externalVarContext,
|
|
92
|
-
parentFontSize,
|
|
93
91
|
parentWidth,
|
|
94
|
-
parentHeight
|
|
92
|
+
parentHeight,
|
|
93
|
+
defaultStyle: styles.container
|
|
95
94
|
});
|
|
96
95
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({
|
|
97
96
|
props,
|
|
@@ -18,10 +18,9 @@ export interface _ViewProps extends ViewProps {
|
|
|
18
18
|
'hover-start-time'?: number;
|
|
19
19
|
'hover-stay-time'?: number;
|
|
20
20
|
'enable-background'?: boolean;
|
|
21
|
+
'enable-text-pass-through'?: boolean;
|
|
21
22
|
'enable-var'?: boolean;
|
|
22
23
|
'enable-fast-image'?: boolean;
|
|
23
|
-
'external-var-context'?: Record<string, any>;
|
|
24
|
-
'parent-font-size'?: number;
|
|
25
24
|
'parent-width'?: number;
|
|
26
25
|
'parent-height'?: number;
|
|
27
26
|
'enable-animation'?: boolean | AnimationType;
|
|
@@ -31,5 +30,6 @@ export interface _ViewProps extends ViewProps {
|
|
|
31
30
|
bindtransitionend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
32
31
|
catchtransitionend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
33
32
|
}
|
|
33
|
+
export declare const __parseBgImageForTest: (text?: string) => any;
|
|
34
34
|
declare const _View: import("react").ForwardRefExoticComponent<_ViewProps & import("react").RefAttributes<HandlerRef<View, _ViewProps>>>;
|
|
35
35
|
export default _View;
|