@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.
- package/lib/loader.js +2 -0
- package/lib/platform/style/wx/index.js +395 -104
- package/lib/react/index.js +3 -1
- package/lib/react/processTemplate.js +3 -1
- package/lib/react/style-helper.js +6 -6
- 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 -1
- package/lib/runtime/components/react/dist/mpx-button.jsx +16 -9
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +1 -2
- 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 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +8 -9
- package/lib/runtime/components/react/dist/mpx-form.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-form.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-image.jsx +59 -43
- package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-label.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-label.jsx +5 -6
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +3 -3
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +6 -6
- 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 +5 -7
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-progress.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-radio.jsx +8 -9
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +36 -31
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +4 -2
- package/lib/runtime/components/react/dist/mpx-simple-view.jsx +24 -17
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +4 -7
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-switch.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-text.jsx +44 -40
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-video.jsx +4 -4
- package/lib/runtime/components/react/dist/mpx-view.d.ts +2 -1
- package/lib/runtime/components/react/dist/mpx-view.jsx +229 -128
- 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 +73 -69
- package/lib/runtime/components/react/dist/utils.jsx +1295 -442
- 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 -16
- package/lib/runtime/components/react/mpx-camera.tsx +0 -3
- package/lib/runtime/components/react/mpx-canvas/index.tsx +1 -3
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -1
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +2 -6
- package/lib/runtime/components/react/mpx-checkbox.tsx +9 -11
- package/lib/runtime/components/react/mpx-form.tsx +6 -6
- package/lib/runtime/components/react/mpx-icon/index.tsx +1 -3
- package/lib/runtime/components/react/mpx-image.tsx +65 -54
- package/lib/runtime/components/react/mpx-input.tsx +1 -3
- package/lib/runtime/components/react/mpx-label.tsx +6 -8
- package/lib/runtime/components/react/mpx-movable-area.tsx +3 -4
- package/lib/runtime/components/react/mpx-movable-view.tsx +7 -7
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +6 -8
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +2 -4
- package/lib/runtime/components/react/mpx-progress.tsx +0 -3
- package/lib/runtime/components/react/mpx-radio-group.tsx +2 -6
- package/lib/runtime/components/react/mpx-radio.tsx +9 -11
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +0 -3
- package/lib/runtime/components/react/mpx-scroll-view.tsx +7 -7
- package/lib/runtime/components/react/mpx-simple-text.tsx +36 -38
- package/lib/runtime/components/react/mpx-simple-view.tsx +29 -17
- package/lib/runtime/components/react/mpx-slider.tsx +15 -10
- package/lib/runtime/components/react/mpx-sticky-header.tsx +6 -6
- package/lib/runtime/components/react/mpx-sticky-section.tsx +7 -7
- package/lib/runtime/components/react/mpx-swiper-item.tsx +6 -6
- package/lib/runtime/components/react/mpx-swiper.tsx +5 -8
- package/lib/runtime/components/react/mpx-switch.tsx +0 -3
- package/lib/runtime/components/react/mpx-text.tsx +46 -49
- package/lib/runtime/components/react/mpx-video.tsx +3 -5
- package/lib/runtime/components/react/mpx-view.tsx +250 -141
- package/lib/runtime/components/react/mpx-web-view.tsx +8 -3
- 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 +1347 -539
- package/lib/runtime/i18n.wxs +15 -9
- package/lib/style-compiler/strip-conditional.js +19 -4
- package/lib/template-compiler/compiler.js +5 -1
- package/lib/utils/source-location.js +9 -13
- package/lib/web/index.js +3 -1
- package/lib/web/processTemplate.js +3 -1
- package/package.json +5 -4
- package/LICENSE +0 -433
|
@@ -15,7 +15,6 @@ interface _RichTextProps extends ViewProps {
|
|
|
15
15
|
style?: ViewStyle;
|
|
16
16
|
nodes: string | Array<Node>;
|
|
17
17
|
'enable-var'?: boolean;
|
|
18
|
-
'external-var-context'?: Record<string, any>;
|
|
19
18
|
'parent-font-size'?: number;
|
|
20
19
|
'parent-width'?: number;
|
|
21
20
|
'parent-height'?: number;
|
|
@@ -28,7 +28,7 @@ function jsonToHtmlStr(elements) {
|
|
|
28
28
|
return htmlStr;
|
|
29
29
|
}
|
|
30
30
|
const _RichText = forwardRef((props, ref) => {
|
|
31
|
-
const { style = {}, nodes, 'enable-var': enableVar, '
|
|
31
|
+
const { style = {}, nodes, 'enable-var': enableVar, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
32
32
|
const nodeRef = useRef(null);
|
|
33
33
|
const [webViewHeight, setWebViewHeight] = useState(0);
|
|
34
34
|
const { normalStyle, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(Object.assign({
|
|
@@ -36,7 +36,6 @@ const _RichText = forwardRef((props, ref) => {
|
|
|
36
36
|
height: webViewHeight
|
|
37
37
|
}, style), {
|
|
38
38
|
enableVar,
|
|
39
|
-
externalVarContext,
|
|
40
39
|
parentFontSize,
|
|
41
40
|
parentWidth,
|
|
42
41
|
parentHeight
|
|
@@ -26,7 +26,7 @@ interface ScrollViewProps {
|
|
|
26
26
|
'scroll-into-view'?: string;
|
|
27
27
|
'enable-trigger-intersection-observer'?: boolean;
|
|
28
28
|
'enable-var'?: boolean;
|
|
29
|
-
'
|
|
29
|
+
'enable-text-pass-through'?: boolean;
|
|
30
30
|
'parent-font-size'?: number;
|
|
31
31
|
'parent-width'?: number;
|
|
32
32
|
'parent-height'?: number;
|
|
@@ -38,7 +38,7 @@ import Animated, { useSharedValue, withTiming, useAnimatedStyle, runOnJS } from
|
|
|
38
38
|
import { warn, hasOwn } from '@mpxjs/utils';
|
|
39
39
|
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
40
40
|
import useNodesRef from './useNodesRef';
|
|
41
|
-
import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, extendObject, flatGesture,
|
|
41
|
+
import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, extendObject, flatGesture, hiddenStyle, useRunOnJSCallback, useTextPassThrough } from './utils';
|
|
42
42
|
import { IntersectionObserverContext, ScrollViewContext } from './context';
|
|
43
43
|
import Portal from './mpx-portal';
|
|
44
44
|
const AnimatedScrollView = RNAnimated.createAnimatedComponent(ScrollView);
|
|
@@ -48,7 +48,7 @@ const REFRESH_COLOR = {
|
|
|
48
48
|
};
|
|
49
49
|
const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
50
50
|
const { textProps, innerProps: props = {} } = splitProps(scrollViewProps);
|
|
51
|
-
const { enhanced = false, bounces = true, style = {}, binddragstart, binddragging, binddragend, bindtouchmove, 'scroll-x': scrollX = false, 'scroll-y': scrollY = false, 'enable-back-to-top': enableBackToTop = false, 'enable-trigger-intersection-observer': enableTriggerIntersectionObserver = false, 'paging-enabled': pagingEnabled = false, 'upper-threshold': upperThreshold = 50, 'lower-threshold': lowerThreshold = 50, 'scroll-with-animation': scrollWithAnimation = false, 'refresher-enabled': refresherEnabled, 'refresher-default-style': refresherDefaultStyle, 'refresher-background': refresherBackground, 'refresher-threshold': refresherThreshold = 45, 'show-scrollbar': showScrollbar = true, 'scroll-into-view': scrollIntoView = '', 'scroll-top': scrollTop = 0, 'scroll-left': scrollLeft = 0, 'refresher-triggered': refresherTriggered, 'enable-var': enableVar, '
|
|
51
|
+
const { enhanced = false, bounces = true, style = {}, binddragstart, binddragging, binddragend, bindtouchmove, 'scroll-x': scrollX = false, 'scroll-y': scrollY = false, 'enable-back-to-top': enableBackToTop = false, 'enable-trigger-intersection-observer': enableTriggerIntersectionObserver = false, 'paging-enabled': pagingEnabled = false, 'upper-threshold': upperThreshold = 50, 'lower-threshold': lowerThreshold = 50, 'scroll-with-animation': scrollWithAnimation = false, 'refresher-enabled': refresherEnabled, 'refresher-default-style': refresherDefaultStyle, 'refresher-background': refresherBackground, 'refresher-threshold': refresherThreshold = 45, 'show-scrollbar': showScrollbar = true, 'scroll-into-view': scrollIntoView = '', 'scroll-top': scrollTop = 0, 'scroll-left': scrollLeft = 0, 'refresher-triggered': refresherTriggered, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'simultaneous-handlers': originSimultaneousHandlers, 'wait-for': waitFor, 'enable-sticky': enableSticky, 'scroll-event-throttle': scrollEventThrottle = 0, 'scroll-into-view-offset': scrollIntoViewOffset = 0, __selectRef } = props;
|
|
52
52
|
const scrollOffset = useRef(new RNAnimated.Value(0)).current;
|
|
53
53
|
const simultaneousHandlers = flatGesture(originSimultaneousHandlers);
|
|
54
54
|
const waitForHandlers = flatGesture(waitFor);
|
|
@@ -75,9 +75,9 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
75
75
|
const intersectionObservers = useContext(IntersectionObserverContext);
|
|
76
76
|
const firstScrollIntoViewChange = useRef(true);
|
|
77
77
|
const isContentSizeChange = useRef(false);
|
|
78
|
-
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, hasPositionFixed, setWidth, setHeight } = useTransformStyle(style, { enableVar,
|
|
78
|
+
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, hasPositionFixed, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight });
|
|
79
79
|
const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
|
|
80
|
-
const textPassThrough =
|
|
80
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
|
|
81
81
|
const scrollViewRef = useRef(null);
|
|
82
82
|
const propsRef = useRef(props);
|
|
83
83
|
const refresherStateRef = useRef({
|
|
@@ -120,7 +120,7 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
120
120
|
}, []);
|
|
121
121
|
const hasRefresherLayoutRef = useRef(false);
|
|
122
122
|
// layout 完成前先隐藏,避免安卓闪烁问题
|
|
123
|
-
const refresherLayoutStyle = useMemo(() => { return !hasRefresherLayoutRef.current ?
|
|
123
|
+
const refresherLayoutStyle = useMemo(() => { return !hasRefresherLayoutRef.current ? hiddenStyle : {}; }, [hasRefresherLayoutRef.current]);
|
|
124
124
|
const lastOffset = useRef(0);
|
|
125
125
|
if (scrollX && scrollY) {
|
|
126
126
|
warn('scroll-x and scroll-y cannot be set to true at the same time, Mpx will use the value of scroll-y as the criterion');
|
|
@@ -667,7 +667,7 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
667
667
|
], { layoutRef });
|
|
668
668
|
const ScrollViewComponent = enableSticky ? AnimatedScrollView : ScrollView;
|
|
669
669
|
const createScrollViewContent = () => {
|
|
670
|
-
const wrappedChildren = wrapChildren(hasRefresher ?
|
|
670
|
+
const wrappedChildren = wrapChildren(hasRefresher ? otherContent : props.children, {
|
|
671
671
|
hasVarDec,
|
|
672
672
|
varContext: varContextRef.current,
|
|
673
673
|
textPassThrough
|
|
@@ -1,58 +1,63 @@
|
|
|
1
1
|
import { Text } from 'react-native';
|
|
2
|
-
import { createElement
|
|
2
|
+
import { createElement } from 'react';
|
|
3
3
|
import useInnerProps from './getInnerListeners';
|
|
4
|
-
import { extendObject, getDefaultAllowFontScaling,
|
|
5
|
-
import { TextPassThroughContext } from './context';
|
|
4
|
+
import { extendObject, getDefaultAllowFontScaling, useTextPassThroughText, wrapChildren, isStringChildren, transformBoxSizing, splitStyle, isBoxSizingAffectingStyle } from './utils';
|
|
6
5
|
import * as perf from '@mpxjs/perf';
|
|
7
6
|
const SimpleText = (props) => {
|
|
8
|
-
let
|
|
7
|
+
let idTotal = -1;
|
|
9
8
|
if (__mpx_perf_framework__)
|
|
10
|
-
|
|
9
|
+
idTotal = perf.scopeStart('simple-text:render:total');
|
|
11
10
|
// ───── style 阶段 ─────
|
|
12
|
-
let
|
|
11
|
+
let idStyle = -1;
|
|
13
12
|
if (__mpx_perf_framework__)
|
|
14
|
-
|
|
15
|
-
const inheritedText = useContext(TextPassThroughContext);
|
|
16
|
-
const mergedStyle = extendObject({}, inheritedText?.textStyle, props.style);
|
|
13
|
+
idStyle = perf.scopeStart('simple-text:render:style');
|
|
17
14
|
let hasBoxSizingAffectingStyle = false;
|
|
18
|
-
const { textStyle
|
|
15
|
+
const { textStyle } = splitStyle(props.style || {}, (key) => {
|
|
19
16
|
if (!hasBoxSizingAffectingStyle && isBoxSizingAffectingStyle(key)) {
|
|
20
17
|
hasBoxSizingAffectingStyle = true;
|
|
21
18
|
}
|
|
22
19
|
});
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
// textStyle 仅在子节点非纯字符串时才需要透传给子级;按需计算 isStringChildren
|
|
21
|
+
const childTextStyle = textStyle && !isStringChildren(props.children)
|
|
22
|
+
? textStyle
|
|
23
|
+
: undefined;
|
|
24
|
+
const { inheritedText, textPassThrough } = useTextPassThroughText(childTextStyle);
|
|
25
|
+
const mergedProps = inheritedText?.pendingTextProps
|
|
26
|
+
? extendObject({}, inheritedText.pendingTextProps, props)
|
|
27
|
+
: props;
|
|
28
|
+
let mergedStyle = inheritedText?.textStyle
|
|
29
|
+
? extendObject({}, inheritedText.textStyle, props.style)
|
|
30
|
+
: props.style;
|
|
31
|
+
if (hasBoxSizingAffectingStyle) {
|
|
32
|
+
// 仅在需要 mutate 时 clone,避免污染上游 props.style
|
|
33
|
+
if (mergedStyle === props.style)
|
|
34
|
+
mergedStyle = extendObject({}, props.style);
|
|
35
|
+
transformBoxSizing(mergedStyle);
|
|
36
|
+
}
|
|
32
37
|
if (__mpx_perf_framework__)
|
|
33
|
-
|
|
38
|
+
perf.scopeEnd(idStyle);
|
|
34
39
|
// ───── innerProps 阶段 ─────
|
|
35
|
-
let
|
|
40
|
+
let idInnerProps = -1;
|
|
36
41
|
if (__mpx_perf_framework__)
|
|
37
|
-
|
|
42
|
+
idInnerProps = perf.scopeStart('simple-text:render:innerProps');
|
|
38
43
|
const innerProps = useInnerProps(extendObject({}, mergedProps, {
|
|
39
|
-
allowFontScaling: allowFontScaling ?? getDefaultAllowFontScaling(),
|
|
40
|
-
style:
|
|
44
|
+
allowFontScaling: mergedProps.allowFontScaling ?? getDefaultAllowFontScaling(),
|
|
45
|
+
style: mergedStyle
|
|
41
46
|
}));
|
|
42
47
|
if (__mpx_perf_framework__)
|
|
43
|
-
|
|
48
|
+
perf.scopeEnd(idInnerProps);
|
|
44
49
|
// ───── createElement 阶段 ─────
|
|
45
|
-
let
|
|
50
|
+
let idCreate = -1;
|
|
46
51
|
if (__mpx_perf_framework__)
|
|
47
|
-
|
|
48
|
-
const result = createElement(Text, innerProps, wrapChildren(
|
|
52
|
+
idCreate = perf.scopeStart('simple-text:render:createElement');
|
|
53
|
+
const result = createElement(Text, innerProps, wrapChildren(mergedProps.children, {
|
|
49
54
|
hasVarDec: false,
|
|
50
|
-
textPassThrough
|
|
55
|
+
textPassThrough
|
|
51
56
|
}));
|
|
52
57
|
if (__mpx_perf_framework__)
|
|
53
|
-
|
|
58
|
+
perf.scopeEnd(idCreate);
|
|
54
59
|
if (__mpx_perf_framework__)
|
|
55
|
-
|
|
60
|
+
perf.scopeEnd(idTotal);
|
|
56
61
|
return result;
|
|
57
62
|
};
|
|
58
63
|
SimpleText.displayName = 'MpxSimpleText';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ViewProps } from 'react-native';
|
|
2
|
+
interface SimpleViewProps extends ViewProps {
|
|
3
|
+
'enable-text-pass-through'?: boolean;
|
|
4
|
+
}
|
|
3
5
|
declare const SimpleView: {
|
|
4
|
-
(simpleViewProps:
|
|
6
|
+
(simpleViewProps: SimpleViewProps): JSX.Element;
|
|
5
7
|
displayName: string;
|
|
6
8
|
};
|
|
7
9
|
export default SimpleView;
|
|
@@ -1,47 +1,54 @@
|
|
|
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) => {
|
|
7
|
-
let
|
|
7
|
+
let idTotal = -1;
|
|
8
8
|
if (__mpx_perf_framework__)
|
|
9
|
-
|
|
9
|
+
idTotal = perf.scopeStart('simple-view:render:total');
|
|
10
10
|
// ───── style 阶段 ─────
|
|
11
|
-
let
|
|
11
|
+
let idStyle = -1;
|
|
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
|
-
|
|
23
|
-
|
|
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
|
+
}
|
|
29
|
+
if (__mpx_perf_framework__)
|
|
30
|
+
perf.scopeEnd(idStyle);
|
|
24
31
|
// ───── innerProps 阶段 ─────
|
|
25
|
-
let
|
|
32
|
+
let idInnerProps = -1;
|
|
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);
|
|
33
40
|
// ───── createElement 阶段 ─────
|
|
34
|
-
let
|
|
41
|
+
let idCreate = -1;
|
|
35
42
|
if (__mpx_perf_framework__)
|
|
36
|
-
|
|
37
|
-
const result = createElement(View, innerProps, wrapChildren(props, {
|
|
43
|
+
idCreate = perf.scopeStart('simple-view:render:createElement');
|
|
44
|
+
const result = createElement(View, innerProps, wrapChildren(props.children, {
|
|
38
45
|
hasVarDec: false,
|
|
39
46
|
textPassThrough
|
|
40
47
|
}));
|
|
41
48
|
if (__mpx_perf_framework__)
|
|
42
|
-
|
|
49
|
+
perf.scopeEnd(idCreate);
|
|
43
50
|
if (__mpx_perf_framework__)
|
|
44
|
-
|
|
51
|
+
perf.scopeEnd(idTotal);
|
|
45
52
|
return result;
|
|
46
53
|
};
|
|
47
54
|
SimpleView.displayName = 'MpxSimpleView';
|
|
@@ -21,7 +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
24
|
'parent-font-size'?: number;
|
|
26
25
|
'parent-width'?: number;
|
|
27
26
|
'parent-height'?: number;
|
|
@@ -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-font-size': parentFontSize, '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,7 +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
54
|
parentFontSize,
|
|
56
55
|
parentWidth,
|
|
57
56
|
parentHeight
|
|
@@ -239,12 +238,13 @@ const Slider = forwardRef((props, ref) => {
|
|
|
239
238
|
// 样式定义
|
|
240
239
|
const blockSizeNum = Math.max(12, Math.min(28, blockSize));
|
|
241
240
|
const trackHeight = 4;
|
|
241
|
+
// 用户传 padding shorthand 时跳过 paddingLeft/Right default,
|
|
242
|
+
// 避免 number 形式 padding:0 被 longhand default 反向覆盖
|
|
242
243
|
const containerStyle = extendObject({}, {
|
|
243
244
|
flexDirection: 'row',
|
|
244
245
|
alignItems: 'center',
|
|
245
|
-
minHeight: Math.max(blockSizeNum + 8, 40)
|
|
246
|
-
|
|
247
|
-
}, normalStyle, layoutStyle);
|
|
246
|
+
minHeight: Math.max(blockSizeNum + 8, 40)
|
|
247
|
+
}, hasOwn(style, 'padding') ? null : { paddingHorizontal: 14 }, hasOwn(style, 'margin') ? null : { marginHorizontal: 18, marginVertical: 10 }, normalStyle, layoutStyle);
|
|
248
248
|
const trackStyle = {
|
|
249
249
|
flex: 1,
|
|
250
250
|
height: trackHeight,
|
|
@@ -7,7 +7,7 @@ interface StickyHeaderProps {
|
|
|
7
7
|
padding?: [number, number, number, number];
|
|
8
8
|
'offset-top'?: number;
|
|
9
9
|
'enable-var'?: boolean;
|
|
10
|
-
'
|
|
10
|
+
'enable-text-pass-through'?: boolean;
|
|
11
11
|
'parent-font-size'?: number;
|
|
12
12
|
'parent-width'?: number;
|
|
13
13
|
'parent-height'?: number;
|
|
@@ -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-font-size': parentFontSize, '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, parentFontSize, 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,7 +6,7 @@ interface StickySectionProps {
|
|
|
6
6
|
style?: ViewStyle;
|
|
7
7
|
'offset-top'?: number;
|
|
8
8
|
'enable-var'?: boolean;
|
|
9
|
-
'
|
|
9
|
+
'enable-text-pass-through'?: boolean;
|
|
10
10
|
'parent-font-size'?: number;
|
|
11
11
|
'parent-width'?: number;
|
|
12
12
|
'parent-height'?: number;
|
|
@@ -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-font-size': parentFontSize, '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, parentFontSize, 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,7 +5,7 @@ interface SwiperItemProps {
|
|
|
5
5
|
'item-id'?: string;
|
|
6
6
|
'enable-offset'?: boolean;
|
|
7
7
|
'enable-var': boolean;
|
|
8
|
-
'
|
|
8
|
+
'enable-text-pass-through'?: boolean;
|
|
9
9
|
'parent-font-size'?: number;
|
|
10
10
|
'parent-width'?: number;
|
|
11
11
|
'parent-height'?: number;
|
|
@@ -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,10 @@ interface SwiperProps {
|
|
|
49
49
|
'next-margin'?: string;
|
|
50
50
|
'enable-offset'?: boolean;
|
|
51
51
|
'enable-var': boolean;
|
|
52
|
+
'enable-text-pass-through'?: boolean;
|
|
52
53
|
'parent-font-size'?: number;
|
|
53
54
|
'parent-width'?: number;
|
|
54
55
|
'parent-height'?: number;
|
|
55
|
-
'external-var-context'?: Record<string, any>;
|
|
56
56
|
'wait-for'?: Array<GestureHandler>;
|
|
57
57
|
'simultaneous-handlers'?: Array<GestureHandler>;
|
|
58
58
|
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, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, '
|
|
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-font-size': parentFontSize, '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,13 @@ 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
88
|
parentFontSize,
|
|
90
89
|
parentWidth,
|
|
91
90
|
parentHeight
|
|
92
91
|
});
|
|
93
92
|
const { textStyle } = splitStyle(normalStyle);
|
|
94
93
|
const { textProps } = splitProps(props);
|
|
95
|
-
const textPassThrough =
|
|
94
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
|
|
96
95
|
const preMargin = props['previous-margin'] ? global.__formatValue(props['previous-margin']) : 0;
|
|
97
96
|
const nextMargin = props['next-margin'] ? global.__formatValue(props['next-margin']) : 0;
|
|
98
97
|
const preMarginShared = useSharedValue(preMargin);
|
|
@@ -817,9 +816,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
817
816
|
const animateComponent = createElement(Animated.View, {
|
|
818
817
|
key: 'swiperContainer',
|
|
819
818
|
style: [{ flexDirection: dir === 'x' ? 'row' : 'column', width: '100%', height: '100%' }, animatedStyles]
|
|
820
|
-
}, wrapChildren({
|
|
821
|
-
children: arrPages
|
|
822
|
-
}, {
|
|
819
|
+
}, wrapChildren(arrPages, {
|
|
823
820
|
hasVarDec,
|
|
824
821
|
varContext: varContextRef.current,
|
|
825
822
|
textPassThrough
|
|
@@ -18,7 +18,6 @@ interface _SwitchProps extends SwitchProps {
|
|
|
18
18
|
'parent-font-size'?: number;
|
|
19
19
|
'parent-width'?: number;
|
|
20
20
|
'parent-height'?: number;
|
|
21
|
-
'external-var-context'?: Record<string, any>;
|
|
22
21
|
bindchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
23
22
|
catchchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
24
23
|
}
|
|
@@ -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-font-size': parentFontSize, '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,7 +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
27
|
parentFontSize,
|
|
29
28
|
parentWidth,
|
|
30
29
|
parentHeight
|