@mpxjs/webpack-plugin 2.10.18-beta.6 → 2.10.18-beta.8
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 +3 -8
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -0
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +15 -3
- package/lib/runtime/components/react/mpx-input.tsx +2 -9
- package/lib/runtime/components/react/mpx-swiper.tsx +18 -3
- package/package.json +1 -1
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
import { forwardRef, useRef, useState, useContext, useEffect, createElement } from 'react';
|
|
41
41
|
import { TextInput } from 'react-native';
|
|
42
42
|
import { warn } from '@mpxjs/utils';
|
|
43
|
-
import { useUpdateEffect, useTransformStyle, useLayout, extendObject
|
|
43
|
+
import { useUpdateEffect, useTransformStyle, useLayout, extendObject } from './utils';
|
|
44
44
|
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
45
45
|
import useNodesRef from './useNodesRef';
|
|
46
46
|
import { FormContext, KeyboardAvoidContext } from './context';
|
|
@@ -285,11 +285,6 @@ const Input = forwardRef((props, ref) => {
|
|
|
285
285
|
? nodeRef.current?.focus()
|
|
286
286
|
: nodeRef.current?.blur();
|
|
287
287
|
}, [isAutoFocus]);
|
|
288
|
-
// 使用 multiline 来修复光标位置问题
|
|
289
|
-
// React Native 的 TextInput 在 textAlign center + placeholder 时光标会跑到右边
|
|
290
|
-
// 这个问题只在 Android 上出现
|
|
291
|
-
// 参考:https://github.com/facebook/react-native/issues/28794 (Android only)
|
|
292
|
-
const needMultilineFix = isAndroid && !multiline;
|
|
293
288
|
const innerProps = useInnerProps(extendObject({}, props, layoutProps, {
|
|
294
289
|
ref: nodeRef,
|
|
295
290
|
style: extendObject({}, normalStyle, layoutStyle),
|
|
@@ -308,7 +303,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
308
303
|
underlineColorAndroid: 'rgba(0,0,0,0)',
|
|
309
304
|
textAlignVertical: textAlignVertical,
|
|
310
305
|
placeholderTextColor: placeholderStyle?.color,
|
|
311
|
-
multiline: multiline
|
|
306
|
+
multiline: !!multiline,
|
|
312
307
|
onTouchStart,
|
|
313
308
|
onTouchEnd,
|
|
314
309
|
onFocus,
|
|
@@ -317,7 +312,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
317
312
|
onSelectionChange,
|
|
318
313
|
onContentSizeChange,
|
|
319
314
|
onSubmitEditing: bindconfirm && onSubmitEditing
|
|
320
|
-
},
|
|
315
|
+
}, !!multiline && confirmType === 'return' ? {} : { enterKeyHint: confirmType }), [
|
|
321
316
|
'type',
|
|
322
317
|
'password',
|
|
323
318
|
'placeholder-style',
|
|
@@ -58,6 +58,7 @@ interface SwiperProps {
|
|
|
58
58
|
disableGesture?: boolean;
|
|
59
59
|
'display-multiple-items'?: number;
|
|
60
60
|
bindchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
61
|
+
bindchangestart?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
61
62
|
}
|
|
62
63
|
declare const SwiperWrapper: React.ForwardRefExoticComponent<SwiperProps & React.RefAttributes<HandlerRef<View, SwiperProps>>>;
|
|
63
64
|
export default SwiperWrapper;
|
|
@@ -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, 'external-var-context': externalVarContext, 'simultaneous-handlers': originSimultaneousHandlers = [], 'wait-for': waitFor = [], style = {}, autoplay = false, circular = false, disableGesture = false, current: propCurrent = 0, bindchange } = props;
|
|
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, 'external-var-context': externalVarContext, 'simultaneous-handlers': originSimultaneousHandlers = [], 'wait-for': waitFor = [], style = {}, autoplay = false, circular = false, disableGesture = false, current: propCurrent = 0, bindchange, bindchangestart } = props;
|
|
65
65
|
const dotCommonStyle = {
|
|
66
66
|
width: dotWidth,
|
|
67
67
|
height: dotHeight,
|
|
@@ -300,6 +300,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
300
300
|
nextIndex += 1;
|
|
301
301
|
// targetOffset = -nextIndex * step.value - preMarginShared.value
|
|
302
302
|
targetOffset = -nextIndex * step.value;
|
|
303
|
+
runOnJSCallback('handleSwiperChangeStart', nextIndex);
|
|
303
304
|
offset.value = withTiming(targetOffset, {
|
|
304
305
|
duration: easeDuration,
|
|
305
306
|
easing: easeMap[easeingFunc]
|
|
@@ -314,6 +315,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
314
315
|
nextIndex = 0;
|
|
315
316
|
targetOffset = -(childrenLength.value + patchElmNumShared.value) * step.value + preMarginShared.value;
|
|
316
317
|
// 执行动画到下一帧
|
|
318
|
+
runOnJSCallback('handleSwiperChangeStart', nextIndex);
|
|
317
319
|
offset.value = withTiming(targetOffset, {
|
|
318
320
|
duration: easeDuration
|
|
319
321
|
}, () => {
|
|
@@ -328,6 +330,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
328
330
|
nextIndex = currentIndex.value + 1;
|
|
329
331
|
targetOffset = -(nextIndex + patchElmNumShared.value) * step.value + preMarginShared.value;
|
|
330
332
|
// 执行动画到下一帧
|
|
333
|
+
runOnJSCallback('handleSwiperChangeStart', nextIndex);
|
|
331
334
|
offset.value = withTiming(targetOffset, {
|
|
332
335
|
duration: easeDuration,
|
|
333
336
|
easing: easeMap[easeingFunc]
|
|
@@ -362,11 +365,16 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
362
365
|
const eventData = getCustomEvent('change', {}, { detail: { current, source: 'touch' }, layoutRef: layoutRef });
|
|
363
366
|
bindchange && bindchange(eventData);
|
|
364
367
|
}
|
|
368
|
+
function handleSwiperChangeStart(current) {
|
|
369
|
+
const eventData = getCustomEvent('changestart', {}, { detail: { current }, layoutRef: layoutRef });
|
|
370
|
+
bindchangestart && bindchangestart(eventData);
|
|
371
|
+
}
|
|
365
372
|
const runOnJSCallbackRef = useRef({
|
|
366
373
|
loop,
|
|
367
374
|
pauseLoop,
|
|
368
375
|
resumeLoop,
|
|
369
|
-
handleSwiperChange
|
|
376
|
+
handleSwiperChange,
|
|
377
|
+
handleSwiperChangeStart
|
|
370
378
|
});
|
|
371
379
|
const runOnJSCallback = useRunOnJSCallback(runOnJSCallbackRef);
|
|
372
380
|
function getOffset(index, stepValue) {
|
|
@@ -387,6 +395,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
387
395
|
if (targetOffset !== offset.value) {
|
|
388
396
|
// 内部基于props.current!==currentIndex.value决定是否使用动画及更新currentIndex.value
|
|
389
397
|
if (propCurrent !== undefined && propCurrent !== currentIndex.value) {
|
|
398
|
+
runOnJSCallback('handleSwiperChangeStart', propCurrent);
|
|
390
399
|
offset.value = withTiming(targetOffset, {
|
|
391
400
|
duration: easeDuration,
|
|
392
401
|
easing: easeMap[easeingFunc]
|
|
@@ -686,7 +695,10 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
686
695
|
const offsetHalf = computeHalf();
|
|
687
696
|
if (childrenLength.value > 1 && offsetHalf) {
|
|
688
697
|
const { selectedIndex } = getTargetPosition({ transdir: moveDistance });
|
|
689
|
-
currentIndex.value
|
|
698
|
+
if (selectedIndex !== currentIndex.value) {
|
|
699
|
+
currentIndex.value = selectedIndex;
|
|
700
|
+
runOnJS(runOnJSCallback)('handleSwiperChangeStart', selectedIndex);
|
|
701
|
+
}
|
|
690
702
|
}
|
|
691
703
|
// 2. 非循环: 处理用户一直拖拽到临界点的场景,如果放到onFinalize无法阻止offset.value更新为越界的值
|
|
692
704
|
if (!circularShared.value) {
|
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
NativeTouchEvent
|
|
55
55
|
} from 'react-native'
|
|
56
56
|
import { warn } from '@mpxjs/utils'
|
|
57
|
-
import { useUpdateEffect, useTransformStyle, useLayout, extendObject,
|
|
57
|
+
import { useUpdateEffect, useTransformStyle, useLayout, extendObject, isIOS } from './utils'
|
|
58
58
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
59
59
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
60
60
|
import { FormContext, FormFieldValue, KeyboardAvoidContext } from './context'
|
|
@@ -472,12 +472,6 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
472
472
|
: (nodeRef.current as TextInput)?.blur()
|
|
473
473
|
}, [isAutoFocus])
|
|
474
474
|
|
|
475
|
-
// 使用 multiline 来修复光标位置问题
|
|
476
|
-
// React Native 的 TextInput 在 textAlign center + placeholder 时光标会跑到右边
|
|
477
|
-
// 这个问题只在 Android 上出现
|
|
478
|
-
// 参考:https://github.com/facebook/react-native/issues/28794 (Android only)
|
|
479
|
-
const needMultilineFix = isAndroid && !multiline
|
|
480
|
-
|
|
481
475
|
const innerProps = useInnerProps(
|
|
482
476
|
extendObject(
|
|
483
477
|
{},
|
|
@@ -501,7 +495,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
501
495
|
underlineColorAndroid: 'rgba(0,0,0,0)',
|
|
502
496
|
textAlignVertical: textAlignVertical,
|
|
503
497
|
placeholderTextColor: placeholderStyle?.color,
|
|
504
|
-
multiline: multiline
|
|
498
|
+
multiline: !!multiline,
|
|
505
499
|
onTouchStart,
|
|
506
500
|
onTouchEnd,
|
|
507
501
|
onFocus,
|
|
@@ -511,7 +505,6 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
511
505
|
onContentSizeChange,
|
|
512
506
|
onSubmitEditing: bindconfirm && onSubmitEditing
|
|
513
507
|
},
|
|
514
|
-
needMultilineFix ? { numberOfLines: 1 } : {},
|
|
515
508
|
!!multiline && confirmType === 'return' ? {} : { enterKeyHint: confirmType }
|
|
516
509
|
),
|
|
517
510
|
[
|
|
@@ -79,6 +79,7 @@ interface SwiperProps {
|
|
|
79
79
|
disableGesture?: boolean
|
|
80
80
|
'display-multiple-items'?: number
|
|
81
81
|
bindchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void
|
|
82
|
+
bindchangestart?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
/**
|
|
@@ -159,7 +160,8 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
159
160
|
circular = false,
|
|
160
161
|
disableGesture = false,
|
|
161
162
|
current: propCurrent = 0,
|
|
162
|
-
bindchange
|
|
163
|
+
bindchange,
|
|
164
|
+
bindchangestart
|
|
163
165
|
} = props
|
|
164
166
|
|
|
165
167
|
const dotCommonStyle = {
|
|
@@ -425,6 +427,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
425
427
|
nextIndex += 1
|
|
426
428
|
// targetOffset = -nextIndex * step.value - preMarginShared.value
|
|
427
429
|
targetOffset = -nextIndex * step.value
|
|
430
|
+
runOnJSCallback('handleSwiperChangeStart', nextIndex)
|
|
428
431
|
offset.value = withTiming(targetOffset, {
|
|
429
432
|
duration: easeDuration,
|
|
430
433
|
easing: easeMap[easeingFunc]
|
|
@@ -438,6 +441,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
438
441
|
nextIndex = 0
|
|
439
442
|
targetOffset = -(childrenLength.value + patchElmNumShared.value) * step.value + preMarginShared.value
|
|
440
443
|
// 执行动画到下一帧
|
|
444
|
+
runOnJSCallback('handleSwiperChangeStart', nextIndex)
|
|
441
445
|
offset.value = withTiming(targetOffset, {
|
|
442
446
|
duration: easeDuration
|
|
443
447
|
}, () => {
|
|
@@ -451,6 +455,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
451
455
|
nextIndex = currentIndex.value + 1
|
|
452
456
|
targetOffset = -(nextIndex + patchElmNumShared.value) * step.value + preMarginShared.value
|
|
453
457
|
// 执行动画到下一帧
|
|
458
|
+
runOnJSCallback('handleSwiperChangeStart', nextIndex)
|
|
454
459
|
offset.value = withTiming(targetOffset, {
|
|
455
460
|
duration: easeDuration,
|
|
456
461
|
easing: easeMap[easeingFunc]
|
|
@@ -489,11 +494,17 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
489
494
|
bindchange && bindchange(eventData)
|
|
490
495
|
}
|
|
491
496
|
|
|
497
|
+
function handleSwiperChangeStart (current: number) {
|
|
498
|
+
const eventData = getCustomEvent('changestart', {}, { detail: { current }, layoutRef: layoutRef })
|
|
499
|
+
bindchangestart && bindchangestart(eventData)
|
|
500
|
+
}
|
|
501
|
+
|
|
492
502
|
const runOnJSCallbackRef = useRef({
|
|
493
503
|
loop,
|
|
494
504
|
pauseLoop,
|
|
495
505
|
resumeLoop,
|
|
496
|
-
handleSwiperChange
|
|
506
|
+
handleSwiperChange,
|
|
507
|
+
handleSwiperChangeStart
|
|
497
508
|
})
|
|
498
509
|
const runOnJSCallback = useRunOnJSCallback(runOnJSCallbackRef)
|
|
499
510
|
|
|
@@ -514,6 +525,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
514
525
|
if (targetOffset !== offset.value) {
|
|
515
526
|
// 内部基于props.current!==currentIndex.value决定是否使用动画及更新currentIndex.value
|
|
516
527
|
if (propCurrent !== undefined && propCurrent !== currentIndex.value) {
|
|
528
|
+
runOnJSCallback('handleSwiperChangeStart', propCurrent)
|
|
517
529
|
offset.value = withTiming(targetOffset, {
|
|
518
530
|
duration: easeDuration,
|
|
519
531
|
easing: easeMap[easeingFunc]
|
|
@@ -805,7 +817,10 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
805
817
|
const offsetHalf = computeHalf()
|
|
806
818
|
if (childrenLength.value > 1 && offsetHalf) {
|
|
807
819
|
const { selectedIndex } = getTargetPosition({ transdir: moveDistance } as EventEndType)
|
|
808
|
-
currentIndex.value
|
|
820
|
+
if (selectedIndex !== currentIndex.value) {
|
|
821
|
+
currentIndex.value = selectedIndex
|
|
822
|
+
runOnJS(runOnJSCallback)('handleSwiperChangeStart', selectedIndex)
|
|
823
|
+
}
|
|
809
824
|
}
|
|
810
825
|
// 2. 非循环: 处理用户一直拖拽到临界点的场景,如果放到onFinalize无法阻止offset.value更新为越界的值
|
|
811
826
|
if (!circularShared.value) {
|