@mpxjs/webpack-plugin 2.10.3-beta.1 → 2.10.3-beta.5
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/runtime/components/react/dist/mpx-input.jsx +10 -7
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +4 -1
- package/lib/runtime/components/react/mpx-input.tsx +9 -6
- package/lib/runtime/components/react/mpx-swiper.tsx +4 -2
- package/lib/runtime/components/react/mpx-web-view.tsx +4 -1
- package/package.json +1 -1
|
@@ -82,7 +82,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
82
82
|
const lineCount = useRef(0);
|
|
83
83
|
const [inputValue, setInputValue] = useState(defaultValue);
|
|
84
84
|
const [contentHeight, setContentHeight] = useState(0);
|
|
85
|
-
const [selection, setSelection] = useState({ start: -1, end:
|
|
85
|
+
const [selection, setSelection] = useState({ start: -1, end: tmpValue.current.length });
|
|
86
86
|
const styleObj = extendObject({ padding: 0, backgroundColor: '#fff' }, style, multiline && autoHeight
|
|
87
87
|
? { height: 'auto', minHeight: Math.max(style?.minHeight || 35, contentHeight) }
|
|
88
88
|
: {});
|
|
@@ -94,15 +94,17 @@ const Input = forwardRef((props, ref) => {
|
|
|
94
94
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
|
|
95
95
|
useEffect(() => {
|
|
96
96
|
if (inputValue !== value) {
|
|
97
|
-
|
|
97
|
+
const parsed = parseValue(value);
|
|
98
|
+
tmpValue.current = parsed;
|
|
99
|
+
setInputValue(parsed);
|
|
98
100
|
}
|
|
99
101
|
}, [value]);
|
|
100
102
|
useEffect(() => {
|
|
101
|
-
if (
|
|
102
|
-
setSelection({ start:
|
|
103
|
+
if (selectionStart > -1) {
|
|
104
|
+
setSelection({ start: selectionStart, end: selectionEnd === -1 ? tmpValue.current.length : selectionEnd });
|
|
103
105
|
}
|
|
104
|
-
else if (
|
|
105
|
-
setSelection({ start:
|
|
106
|
+
else if (typeof cursor === 'number') {
|
|
107
|
+
setSelection({ start: cursor, end: cursor });
|
|
106
108
|
}
|
|
107
109
|
}, [cursor, selectionStart, selectionEnd]);
|
|
108
110
|
// have not selection on the Android platformg
|
|
@@ -211,6 +213,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
211
213
|
}
|
|
212
214
|
};
|
|
213
215
|
const resetValue = () => {
|
|
216
|
+
tmpValue.current = '';
|
|
214
217
|
setInputValue('');
|
|
215
218
|
};
|
|
216
219
|
const getValue = () => {
|
|
@@ -255,7 +258,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
255
258
|
maxLength: maxlength === -1 ? undefined : maxlength,
|
|
256
259
|
editable: !disabled,
|
|
257
260
|
autoFocus: !!autoFocus || !!focus,
|
|
258
|
-
selection: selection,
|
|
261
|
+
selection: selectionStart > -1 || typeof cursor === 'number' ? selection : undefined,
|
|
259
262
|
selectionColor: cursorColor,
|
|
260
263
|
blurOnSubmit: !multiline && !confirmHold,
|
|
261
264
|
underlineColorAndroid: 'rgba(0,0,0,0)',
|
|
@@ -70,7 +70,7 @@ const easeMap = {
|
|
|
70
70
|
easeInOutCubic: Easing.inOut(Easing.cubic)
|
|
71
71
|
};
|
|
72
72
|
const SwiperWrapper = forwardRef((props, ref) => {
|
|
73
|
-
const { 'indicator-dots': showsPagination, 'indicator-color': dotColor = 'rgba(0, 0, 0, .3)', 'indicator-active-color': activeDotColor = '#000000', 'enable-var': enableVar = false, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'external-var-context': externalVarContext, style = {}, autoplay = false, circular = false } = props;
|
|
73
|
+
const { 'indicator-dots': showsPagination, 'indicator-color': dotColor = 'rgba(0, 0, 0, .3)', 'indicator-active-color': activeDotColor = '#000000', 'enable-var': enableVar = false, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'external-var-context': externalVarContext, style = {}, autoplay = false, circular = false, disableGesture = false } = props;
|
|
74
74
|
const easeingFunc = props['easing-function'] || 'default';
|
|
75
75
|
const easeDuration = props.duration || 500;
|
|
76
76
|
const horizontal = props.vertical !== undefined ? !props.vertical : true;
|
|
@@ -658,7 +658,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
658
658
|
{showsPagination && renderPagination()}
|
|
659
659
|
</View>);
|
|
660
660
|
}
|
|
661
|
-
if (children.length === 1) {
|
|
661
|
+
if (children.length === 1 || disableGesture) {
|
|
662
662
|
return renderSwiper();
|
|
663
663
|
}
|
|
664
664
|
else {
|
|
@@ -75,7 +75,10 @@ const _WebView = forwardRef((props, ref) => {
|
|
|
75
75
|
};
|
|
76
76
|
const navigation = useNavigation();
|
|
77
77
|
useEffect(() => {
|
|
78
|
-
|
|
78
|
+
let beforeRemoveSubscription;
|
|
79
|
+
if (__mpx_mode__ !== 'ios') {
|
|
80
|
+
beforeRemoveSubscription = navigation?.addListener?.('beforeRemove', beforeRemoveHandle);
|
|
81
|
+
}
|
|
79
82
|
return () => {
|
|
80
83
|
if (isFunction(beforeRemoveSubscription)) {
|
|
81
84
|
beforeRemoveSubscription();
|
|
@@ -195,7 +195,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
195
195
|
|
|
196
196
|
const [inputValue, setInputValue] = useState(defaultValue)
|
|
197
197
|
const [contentHeight, setContentHeight] = useState(0)
|
|
198
|
-
const [selection, setSelection] = useState({ start: -1, end:
|
|
198
|
+
const [selection, setSelection] = useState({ start: -1, end: tmpValue.current.length })
|
|
199
199
|
|
|
200
200
|
const styleObj = extendObject(
|
|
201
201
|
{ padding: 0, backgroundColor: '#fff' },
|
|
@@ -221,15 +221,17 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
221
221
|
|
|
222
222
|
useEffect(() => {
|
|
223
223
|
if (inputValue !== value) {
|
|
224
|
-
|
|
224
|
+
const parsed = parseValue(value)
|
|
225
|
+
tmpValue.current = parsed
|
|
226
|
+
setInputValue(parsed)
|
|
225
227
|
}
|
|
226
228
|
}, [value])
|
|
227
229
|
|
|
228
230
|
useEffect(() => {
|
|
229
|
-
if (
|
|
231
|
+
if (selectionStart > -1) {
|
|
232
|
+
setSelection({ start: selectionStart, end: selectionEnd === -1 ? tmpValue.current.length : selectionEnd })
|
|
233
|
+
} else if (typeof cursor === 'number') {
|
|
230
234
|
setSelection({ start: cursor, end: cursor })
|
|
231
|
-
} else if (selectionStart >= 0 && selectionEnd >= 0 && selectionStart !== selectionEnd) {
|
|
232
|
-
setSelection({ start: selectionStart, end: selectionEnd })
|
|
233
235
|
}
|
|
234
236
|
}, [cursor, selectionStart, selectionEnd])
|
|
235
237
|
|
|
@@ -388,6 +390,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
388
390
|
}
|
|
389
391
|
|
|
390
392
|
const resetValue = () => {
|
|
393
|
+
tmpValue.current = ''
|
|
391
394
|
setInputValue('')
|
|
392
395
|
}
|
|
393
396
|
|
|
@@ -440,7 +443,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
440
443
|
maxLength: maxlength === -1 ? undefined : maxlength,
|
|
441
444
|
editable: !disabled,
|
|
442
445
|
autoFocus: !!autoFocus || !!focus,
|
|
443
|
-
selection: selection,
|
|
446
|
+
selection: selectionStart > -1 || typeof cursor === 'number' ? selection : undefined,
|
|
444
447
|
selectionColor: cursorColor,
|
|
445
448
|
blurOnSubmit: !multiline && !confirmHold,
|
|
446
449
|
underlineColorAndroid: 'rgba(0,0,0,0)',
|
|
@@ -55,6 +55,7 @@ interface SwiperProps {
|
|
|
55
55
|
'parent-width'?: number;
|
|
56
56
|
'parent-height'?: number;
|
|
57
57
|
'external-var-context'?: Record<string, any>;
|
|
58
|
+
disableGesture?: boolean;
|
|
58
59
|
bindchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -136,7 +137,8 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
136
137
|
'external-var-context': externalVarContext,
|
|
137
138
|
style = {},
|
|
138
139
|
autoplay = false,
|
|
139
|
-
circular = false
|
|
140
|
+
circular = false,
|
|
141
|
+
disableGesture = false
|
|
140
142
|
} = props
|
|
141
143
|
const easeingFunc = props['easing-function'] || 'default'
|
|
142
144
|
const easeDuration = props.duration || 500
|
|
@@ -730,7 +732,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
730
732
|
</View>)
|
|
731
733
|
}
|
|
732
734
|
|
|
733
|
-
if (children.length === 1) {
|
|
735
|
+
if (children.length === 1 || disableGesture) {
|
|
734
736
|
return renderSwiper()
|
|
735
737
|
} else {
|
|
736
738
|
return (<GestureDetector gesture={gestureHandler}>
|
|
@@ -123,7 +123,10 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
|
|
|
123
123
|
const navigation = useNavigation()
|
|
124
124
|
|
|
125
125
|
useEffect(() => {
|
|
126
|
-
|
|
126
|
+
let beforeRemoveSubscription:any
|
|
127
|
+
if (__mpx_mode__ !== 'ios') {
|
|
128
|
+
beforeRemoveSubscription = navigation?.addListener?.('beforeRemove', beforeRemoveHandle)
|
|
129
|
+
}
|
|
127
130
|
return () => {
|
|
128
131
|
if (isFunction(beforeRemoveSubscription)) {
|
|
129
132
|
beforeRemoveSubscription()
|