@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
|
@@ -17,10 +17,8 @@ interface CanvasProps {
|
|
|
17
17
|
style?: Record<string, any>;
|
|
18
18
|
originWhitelist?: Array<string>;
|
|
19
19
|
'enable-var'?: boolean;
|
|
20
|
-
'parent-font-size'?: number;
|
|
21
20
|
'parent-width'?: number;
|
|
22
21
|
'parent-height'?: number;
|
|
23
|
-
'external-var-context'?: Record<string, any>;
|
|
24
22
|
bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
25
23
|
bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
26
24
|
bindtouchend?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
@@ -39,13 +39,11 @@ const stylesheet = StyleSheet.create({
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
const _Canvas = forwardRef((props = {}, ref) => {
|
|
42
|
-
const { style = {}, originWhitelist = ['*'], 'enable-var': enableVar, '
|
|
42
|
+
const { style = {}, originWhitelist = ['*'], 'enable-var': enableVar, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
43
43
|
const [isLoaded, setIsLoaded] = useState(false);
|
|
44
44
|
const nodeRef = useRef(null);
|
|
45
45
|
const { normalStyle, hasSelfPercent, hasPositionFixed, setWidth, setHeight } = useTransformStyle(extendObject({}, style, stylesheet.container), {
|
|
46
46
|
enableVar,
|
|
47
|
-
externalVarContext,
|
|
48
|
-
parentFontSize,
|
|
49
47
|
parentWidth,
|
|
50
48
|
parentHeight
|
|
51
49
|
});
|
|
@@ -30,7 +30,7 @@ export interface WebviewMessage {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
export interface CanvasInstance {
|
|
33
|
-
webview: WebView | null;
|
|
33
|
+
webview: WebView<any> | null;
|
|
34
34
|
bus: Bus | null;
|
|
35
35
|
context2D: CanvasRenderingContext2D;
|
|
36
36
|
getContext: (contextType: string) => CanvasRenderingContext2D | null;
|
|
@@ -9,8 +9,6 @@ export interface CheckboxGroupProps {
|
|
|
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
|
-
'parent-font-size'?: number;
|
|
14
12
|
'parent-width'?: number;
|
|
15
13
|
'parent-height'?: number;
|
|
16
14
|
children: ReactNode;
|
|
@@ -12,7 +12,7 @@ import Portal from './mpx-portal';
|
|
|
12
12
|
const CheckboxGroup = forwardRef((props, ref) => {
|
|
13
13
|
const propsRef = useRef({});
|
|
14
14
|
propsRef.current = props;
|
|
15
|
-
const { style = {}, 'enable-var': enableVar, '
|
|
15
|
+
const { style = {}, 'enable-var': enableVar, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
16
16
|
const formContext = useContext(FormContext);
|
|
17
17
|
let formValuesMap;
|
|
18
18
|
if (formContext) {
|
|
@@ -23,8 +23,7 @@ const CheckboxGroup = forwardRef((props, ref) => {
|
|
|
23
23
|
flexDirection: 'row',
|
|
24
24
|
flexWrap: 'wrap'
|
|
25
25
|
};
|
|
26
|
-
const
|
|
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, 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 CheckboxGroup = forwardRef((props, ref) => {
|
|
|
83
82
|
notifyChange
|
|
84
83
|
};
|
|
85
84
|
}, []);
|
|
86
|
-
const finalComponent = createElement(View, innerProps, createElement(CheckboxGroupContext.Provider, { value: contextValue }, wrapChildren(props, {
|
|
85
|
+
const finalComponent = createElement(View, innerProps, createElement(CheckboxGroupContext.Provider, { value: contextValue }, wrapChildren(props.children, {
|
|
87
86
|
hasVarDec,
|
|
88
87
|
varContext: varContextRef.current
|
|
89
88
|
})));
|
|
@@ -18,8 +18,7 @@ export interface CheckboxProps extends Selection {
|
|
|
18
18
|
groupValue?: Array<string>;
|
|
19
19
|
'enable-offset'?: boolean;
|
|
20
20
|
'enable-var'?: boolean;
|
|
21
|
-
'
|
|
22
|
-
'parent-font-size'?: number;
|
|
21
|
+
'enable-text-pass-through'?: boolean;
|
|
23
22
|
'parent-width'?: number;
|
|
24
23
|
'parent-height'?: number;
|
|
25
24
|
children?: ReactNode;
|
|
@@ -10,7 +10,7 @@ import { warn } from '@mpxjs/utils';
|
|
|
10
10
|
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
11
11
|
import useNodesRef from './useNodesRef';
|
|
12
12
|
import Icon from './mpx-icon';
|
|
13
|
-
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject,
|
|
13
|
+
import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useTextPassThrough } from './utils';
|
|
14
14
|
import { CheckboxGroupContext, LabelContext } from './context';
|
|
15
15
|
import Portal from './mpx-portal';
|
|
16
16
|
const styles = StyleSheet.create({
|
|
@@ -41,13 +41,12 @@ const styles = StyleSheet.create({
|
|
|
41
41
|
});
|
|
42
42
|
const Checkbox = forwardRef((checkboxProps, ref) => {
|
|
43
43
|
const { textProps, innerProps: props = {} } = splitProps(checkboxProps);
|
|
44
|
-
const { value = '', disabled = false, checked = false, color = '#09BB07', style = {}, 'enable-var': enableVar, '
|
|
44
|
+
const { value = '', disabled = false, checked = false, color = '#09BB07', style = {}, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-width': parentWidth, 'parent-height': parentHeight, bindtap, _onChange } = props;
|
|
45
45
|
const [isChecked, setIsChecked] = useState(!!checked);
|
|
46
46
|
const groupContext = useContext(CheckboxGroupContext);
|
|
47
47
|
let groupValue;
|
|
48
48
|
let notifyChange;
|
|
49
|
-
const
|
|
50
|
-
const styleObj = extendObject({}, styles.container, style);
|
|
49
|
+
const wrapperStyle = extendObject({}, styles.wrapper, disabled ? styles.wrapperDisabled : null);
|
|
51
50
|
const onChange = (evt) => {
|
|
52
51
|
if (disabled)
|
|
53
52
|
return;
|
|
@@ -64,15 +63,15 @@ const Checkbox = forwardRef((checkboxProps, ref) => {
|
|
|
64
63
|
bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props));
|
|
65
64
|
onChange(evt);
|
|
66
65
|
};
|
|
67
|
-
const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(
|
|
66
|
+
const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentWidth, parentHeight, defaultStyle: styles.container });
|
|
68
67
|
const nodeRef = useRef(null);
|
|
69
68
|
useNodesRef(props, ref, nodeRef, {
|
|
70
|
-
style:
|
|
69
|
+
style: normalStyle,
|
|
71
70
|
change: onChange
|
|
72
71
|
});
|
|
73
72
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
|
|
74
73
|
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle);
|
|
75
|
-
const textPassThrough =
|
|
74
|
+
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
|
|
76
75
|
if (backgroundStyle) {
|
|
77
76
|
warn('Checkbox does not support background image-related styles!');
|
|
78
77
|
}
|
|
@@ -118,12 +117,12 @@ const Checkbox = forwardRef((checkboxProps, ref) => {
|
|
|
118
117
|
}
|
|
119
118
|
}
|
|
120
119
|
}, [checked]);
|
|
121
|
-
const finalComponent = createElement(View, innerProps, createElement(View, { style:
|
|
120
|
+
const finalComponent = createElement(View, innerProps, createElement(View, { style: wrapperStyle }, createElement(Icon, {
|
|
122
121
|
type: 'success_no_circle',
|
|
123
122
|
size: 18,
|
|
124
123
|
color: disabled ? '#ADADAD' : color,
|
|
125
124
|
style: isChecked ? styles.iconChecked : styles.icon
|
|
126
|
-
})), wrapChildren(props, {
|
|
125
|
+
})), wrapChildren(props.children, {
|
|
127
126
|
hasVarDec,
|
|
128
127
|
varContext: varContextRef.current,
|
|
129
128
|
textPassThrough
|
|
@@ -12,8 +12,7 @@ interface FormProps {
|
|
|
12
12
|
children?: ReactNode;
|
|
13
13
|
'enable-offset'?: boolean;
|
|
14
14
|
'enable-var'?: boolean;
|
|
15
|
-
'
|
|
16
|
-
'parent-font-size'?: number;
|
|
15
|
+
'enable-text-pass-through'?: boolean;
|
|
17
16
|
'parent-width'?: number;
|
|
18
17
|
'parent-height'?: number;
|
|
19
18
|
bindsubmit?: (evt: {
|
|
@@ -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,
|
|
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, '
|
|
16
|
-
const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar,
|
|
15
|
+
const { style, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
16
|
+
const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentWidth, parentHeight });
|
|
17
17
|
const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
|
|
18
|
-
const textPassThrough =
|
|
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,8 +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
|
-
'parent-font-size'?: number;
|
|
14
12
|
'parent-width'?: number;
|
|
15
13
|
'parent-height'?: number;
|
|
16
14
|
}
|
|
@@ -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, '
|
|
33
|
+
const { type, size = 23, color, style = {}, 'enable-var': enableVar, '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,
|
|
37
|
+
const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, 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,8 +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
|
-
'parent-font-size'?: number;
|
|
13
11
|
'parent-width'?: number;
|
|
14
12
|
'parent-height'?: number;
|
|
15
13
|
'enable-fast-image'?: boolean;
|
|
@@ -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 {
|
|
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
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
'top left',
|
|
30
|
-
'top right',
|
|
31
|
-
'bottom left',
|
|
32
|
-
'bottom right'
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
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, '
|
|
96
|
-
const
|
|
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, '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
|
-
|
|
103
|
-
|
|
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 =
|
|
121
|
+
const isCropMode = hasOwn(cropModeMap, mode);
|
|
109
122
|
const isLayoutMode = isWidthFixMode || isHeightFixMode || isCropMode;
|
|
110
|
-
const resizeMode =
|
|
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,
|
|
143
|
+
const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, transformRadiusPercent: isAndroid && !isSvg && !isLayoutMode, 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 :
|
|
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({
|
|
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:
|
|
381
|
+
source: imageSource,
|
|
362
382
|
resizeMode: resizeMode,
|
|
363
383
|
onLoad: bindload && onImageLoad,
|
|
364
384
|
onError: binderror && onImageError,
|
|
365
|
-
style:
|
|
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() {
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { Text } from 'react-native';
|
|
2
2
|
import { createElement, useContext } from 'react';
|
|
3
|
-
import { extendObject, getDefaultAllowFontScaling } from './utils';
|
|
3
|
+
import { extendObject, getDefaultAllowFontScaling, resolveTextLineHeightPercentStyle } from './utils';
|
|
4
4
|
import { TextPassThroughContext } from './context';
|
|
5
5
|
const InlineText = (props) => {
|
|
6
6
|
const inheritedText = useContext(TextPassThroughContext);
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const mergedStyle = inheritedText?.textStyle
|
|
8
|
+
? extendObject({}, inheritedText.textStyle)
|
|
9
|
+
: undefined;
|
|
10
|
+
// inline-text 只包裹裸文本,消费继承文本样式中的相对 lineHeight,不处理本地样式。
|
|
11
|
+
if (inheritedText?.textStyle) {
|
|
12
|
+
resolveTextLineHeightPercentStyle(mergedStyle, inheritedText.textStyle);
|
|
13
|
+
}
|
|
14
|
+
const mergedProps = inheritedText?.pendingTextProps
|
|
15
|
+
? extendObject({}, inheritedText.pendingTextProps, props)
|
|
16
|
+
: props;
|
|
9
17
|
const { allowFontScaling, children } = mergedProps;
|
|
10
18
|
return createElement(Text, extendObject({}, mergedProps, {
|
|
11
|
-
allowFontScaling: allowFontScaling ?? getDefaultAllowFontScaling()
|
|
19
|
+
allowFontScaling: allowFontScaling ?? getDefaultAllowFontScaling(),
|
|
20
|
+
style: mergedStyle
|
|
12
21
|
}), children);
|
|
13
22
|
};
|
|
14
23
|
InlineText.displayName = 'MpxInlineText';
|
|
@@ -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, '
|
|
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-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,
|
|
87
|
+
const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, parentWidth, parentHeight });
|
|
88
88
|
const nodeRef = useRef(null);
|
|
89
89
|
useNodesRef(props, ref, nodeRef, {
|
|
90
90
|
style: normalStyle
|
|
@@ -153,7 +153,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
153
153
|
// auto-focus/focus 不会触发而是在 useEffect 中初始化
|
|
154
154
|
setKeyboardAvoidContext();
|
|
155
155
|
};
|
|
156
|
-
const
|
|
156
|
+
const markEventOrigin = (evt) => {
|
|
157
157
|
evt.nativeEvent.origin = 'input';
|
|
158
158
|
};
|
|
159
159
|
const onFocus = (evt) => {
|
|
@@ -286,7 +286,14 @@ const Input = forwardRef((props, ref) => {
|
|
|
286
286
|
// React Native 的 TextInput 在 textAlign center + placeholder 时光标会跑到右边
|
|
287
287
|
// 这个问题只在 Android 上出现
|
|
288
288
|
// 参考:https://github.com/facebook/react-native/issues/28794 (Android only)
|
|
289
|
-
const
|
|
289
|
+
const conditionalTextInputProps = {};
|
|
290
|
+
if (isAndroid && !multiline && props.placeholder && normalStyle.textAlign === 'center') {
|
|
291
|
+
conditionalTextInputProps.multiline = true;
|
|
292
|
+
conditionalTextInputProps.numberOfLines = 1;
|
|
293
|
+
}
|
|
294
|
+
if (!multiline || confirmType !== 'return') {
|
|
295
|
+
conditionalTextInputProps.enterKeyHint = confirmType;
|
|
296
|
+
}
|
|
290
297
|
const innerProps = useInnerProps(extendObject({}, props, layoutProps, {
|
|
291
298
|
ref: nodeRef,
|
|
292
299
|
style: extendObject({}, normalStyle, layoutStyle),
|
|
@@ -301,20 +308,21 @@ const Input = forwardRef((props, ref) => {
|
|
|
301
308
|
autoFocus: isAutoFocus,
|
|
302
309
|
selection: selectionStart > -1 || typeof cursor === 'number' ? selection : undefined,
|
|
303
310
|
selectionColor: cursorColor,
|
|
304
|
-
|
|
311
|
+
submitBehavior: multiline ? (confirmType === 'return' ? 'newline' : 'blurAndSubmit') : (confirmHold ? 'submit' : 'blurAndSubmit'),
|
|
305
312
|
underlineColorAndroid: 'rgba(0,0,0,0)',
|
|
306
313
|
textAlignVertical: textAlignVertical,
|
|
307
314
|
placeholderTextColor: placeholderStyle?.color,
|
|
308
|
-
multiline
|
|
315
|
+
multiline,
|
|
309
316
|
onTouchStart,
|
|
310
|
-
onTouchEnd,
|
|
317
|
+
onTouchEnd: markEventOrigin,
|
|
318
|
+
onTouchMove: markEventOrigin,
|
|
311
319
|
onFocus,
|
|
312
320
|
onBlur,
|
|
313
321
|
onChange,
|
|
314
322
|
onSelectionChange,
|
|
315
323
|
onContentSizeChange,
|
|
316
324
|
onSubmitEditing: bindconfirm && onSubmitEditing
|
|
317
|
-
},
|
|
325
|
+
}, conditionalTextInputProps), [
|
|
318
326
|
'name',
|
|
319
327
|
'type',
|
|
320
328
|
'maxlength',
|
|
@@ -9,8 +9,7 @@ export interface LabelProps {
|
|
|
9
9
|
style?: ViewStyle & Record<string, any>;
|
|
10
10
|
'enable-offset'?: boolean;
|
|
11
11
|
'enable-var'?: boolean;
|
|
12
|
-
'
|
|
13
|
-
'parent-font-size'?: number;
|
|
12
|
+
'enable-text-pass-through'?: boolean;
|
|
14
13
|
'parent-width'?: number;
|
|
15
14
|
'parent-height'?: number;
|
|
16
15
|
children: ReactNode;
|
|
@@ -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,
|
|
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, '
|
|
15
|
+
const { style = {}, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
16
16
|
propsRef.current = props;
|
|
17
17
|
const defaultStyle = {
|
|
18
18
|
flexDirection: 'row'
|
|
19
19
|
};
|
|
20
|
-
const
|
|
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, 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 =
|
|
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
|
|
@@ -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, '
|
|
13
|
-
const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, hasPositionFixed, setWidth, setHeight } = useTransformStyle(style, { enableVar,
|
|
12
|
+
const { style = {}, 'enable-var': enableVar, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
13
|
+
const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, hasPositionFixed, setWidth, setHeight } = useTransformStyle(style, { enableVar, 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,8 +55,7 @@ interface MovableViewProps {
|
|
|
55
55
|
'simultaneous-handlers'?: Array<GestureHandler>;
|
|
56
56
|
inertia?: boolean;
|
|
57
57
|
'enable-var'?: boolean;
|
|
58
|
-
'
|
|
59
|
-
'parent-font-size'?: number;
|
|
58
|
+
'enable-text-pass-through'?: boolean;
|
|
60
59
|
'parent-width'?: number;
|
|
61
60
|
'parent-height'?: number;
|
|
62
61
|
'disable-event-passthrough'?: boolean;
|