@mpxjs/webpack-plugin 2.10.17 → 2.10.18
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/config.js +60 -0
- package/lib/file-loader.js +4 -1
- package/lib/global.d.ts +231 -0
- package/lib/index.js +58 -73
- package/lib/init.js +3 -0
- package/lib/json-compiler/index.js +13 -4
- package/lib/loader.js +4 -0
- package/lib/platform/json/wx/index.js +6 -0
- package/lib/platform/style/wx/index.js +102 -72
- package/lib/platform/template/wx/component-config/ad.js +5 -0
- package/lib/platform/template/wx/component-config/button.js +10 -3
- package/lib/platform/template/wx/component-config/camera.js +13 -3
- package/lib/platform/template/wx/component-config/canvas.js +8 -1
- package/lib/platform/template/wx/component-config/cover-image.js +7 -2
- package/lib/platform/template/wx/component-config/cover-view.js +3 -1
- package/lib/platform/template/wx/component-config/form.js +27 -2
- package/lib/platform/template/wx/component-config/image.js +5 -0
- package/lib/platform/template/wx/component-config/input.js +10 -0
- package/lib/platform/template/wx/component-config/label.js +10 -2
- package/lib/platform/template/wx/component-config/map.js +11 -0
- package/lib/platform/template/wx/component-config/movable-area.js +4 -1
- package/lib/platform/template/wx/component-config/movable-view.js +17 -2
- package/lib/platform/template/wx/component-config/navigator.js +26 -0
- package/lib/platform/template/wx/component-config/picker-view.js +12 -0
- package/lib/platform/template/wx/component-config/picker.js +3 -1
- package/lib/platform/template/wx/component-config/progress.js +11 -1
- package/lib/platform/template/wx/component-config/rich-text.js +5 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +12 -1
- package/lib/platform/template/wx/component-config/slider.js +8 -0
- package/lib/platform/template/wx/component-config/swiper-item.js +5 -2
- package/lib/platform/template/wx/component-config/swiper.js +10 -0
- package/lib/platform/template/wx/component-config/text.js +5 -0
- package/lib/platform/template/wx/component-config/textarea.js +19 -2
- package/lib/platform/template/wx/component-config/unsupported.js +9 -0
- package/lib/platform/template/wx/component-config/video.js +10 -0
- package/lib/platform/template/wx/index.js +21 -1
- package/lib/react/LoadAsyncChunkModule.js +1 -1
- package/lib/react/processStyles.js +21 -9
- package/lib/react/script-helper.js +2 -2
- package/lib/react/style-helper.js +76 -13
- package/lib/resolver/AddModePlugin.js +17 -7
- package/lib/runtime/components/react/animationHooks/index.ts +75 -0
- package/lib/runtime/components/react/animationHooks/useAnimationAPIHooks.ts +197 -0
- package/lib/runtime/components/react/animationHooks/useTransitionHooks.ts +301 -0
- package/lib/runtime/components/react/animationHooks/utils.ts +197 -0
- package/lib/runtime/components/react/context.ts +12 -3
- package/lib/runtime/components/react/dist/animationHooks/index.d.ts +15 -0
- package/lib/runtime/components/react/dist/animationHooks/index.js +67 -0
- package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.d.ts +3 -0
- package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.js +181 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.d.ts +3 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.js +279 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.d.ts +109 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.js +151 -0
- package/lib/runtime/components/react/dist/context.d.ts +10 -3
- package/lib/runtime/components/react/dist/context.js +1 -2
- package/lib/runtime/components/react/dist/event.config.d.ts +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.jsx +3 -1
- package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-image.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-input.d.ts +2 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +66 -50
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +35 -6
- package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -1
- 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/pickerViewColumnItem.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +84 -78
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +20 -20
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +10 -1
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +95 -61
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -0
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-view.d.ts +3 -3
- package/lib/runtime/components/react/dist/mpx-view.jsx +22 -8
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/parser.d.ts +0 -1
- package/lib/runtime/components/react/dist/useNodesRef.d.ts +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts +10 -9
- package/lib/runtime/components/react/dist/utils.jsx +47 -24
- package/lib/runtime/components/react/mpx-async-suspense.tsx +3 -1
- package/lib/runtime/components/react/mpx-image.tsx +2 -2
- package/lib/runtime/components/react/mpx-input.tsx +77 -54
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +35 -6
- package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +2 -2
- package/lib/runtime/components/react/mpx-scroll-view.tsx +110 -114
- package/lib/runtime/components/react/mpx-sticky-header.tsx +24 -24
- package/lib/runtime/components/react/mpx-swiper.tsx +115 -60
- package/lib/runtime/components/react/mpx-textarea.tsx +1 -0
- package/lib/runtime/components/react/mpx-view.tsx +27 -12
- package/lib/runtime/components/react/tsconfig.json +26 -0
- package/lib/runtime/components/react/types/global.d.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +51 -27
- package/lib/runtime/optionProcessor.js +5 -0
- package/lib/runtime/optionProcessorReact.js +7 -0
- package/lib/runtime/stringify.wxs +2 -2
- package/lib/script-setup-compiler/index.js +1 -2
- package/lib/style-compiler/strip-conditional.js +243 -0
- package/lib/template-compiler/compiler.js +2 -5
- package/lib/utils/string.js +25 -1
- package/lib/wxss/loader.js +4 -1
- package/lib/wxss/utils.js +7 -2
- package/package.json +7 -14
- package/lib/runtime/components/react/dist/context.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/event.config.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-button.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-form.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-input.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-label.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-video.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/parser.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +0 -33
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/useAnimationHooks.js +0 -289
- package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/useAnimationHooks.ts +0 -320
- package/lib/style-compiler/strip-conditional-loader.js +0 -289
|
@@ -14,9 +14,12 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
14
14
|
// 比如机型 iPhone 11 Pro,可能会导致显隐动画冲突
|
|
15
15
|
// 因此增加状态标记 + cancelAnimation 来优化
|
|
16
16
|
const isShow = useRef(false);
|
|
17
|
+
const keybaordHandleTimerRef = useRef(null);
|
|
17
18
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
18
|
-
// translate/position top
|
|
19
|
-
|
|
19
|
+
// translate/position top+ overflow hidden 在 android 上时因为键盘顶起让页面高度变小,同时元素位置上移
|
|
20
|
+
// 此时最底部的区域是超出了页面高度的,hidden生效就被隐藏掉,因此需要 android 配置聚焦时禁用高度缩小
|
|
21
|
+
// margin-top 因为在 react-native 上和 flex 1 同时存在时,负值只会让容器高度整体变高,不会让元素上移
|
|
22
|
+
transform: [{ translateY: -offset.value }],
|
|
20
23
|
flexBasis: basic.value
|
|
21
24
|
}));
|
|
22
25
|
const resetKeyboard = () => {
|
|
@@ -26,11 +29,20 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
26
29
|
isShow.current = false;
|
|
27
30
|
if (keyboardAvoid?.current) {
|
|
28
31
|
const inputRef = keyboardAvoid.current.ref?.current;
|
|
29
|
-
if (inputRef && inputRef.isFocused()) {
|
|
32
|
+
if (inputRef && inputRef.isFocused() && !keyboardAvoid.current.readyToShow) {
|
|
30
33
|
// 修复 Android 点击键盘收起按钮时当前 input 没触发失焦的问题
|
|
34
|
+
// keyboardAvoid.current.readyToShow = true 表示聚焦到了新的输入框,不需要手动触发失焦
|
|
31
35
|
inputRef.blur();
|
|
32
36
|
}
|
|
33
|
-
keyboardAvoid.current
|
|
37
|
+
if (!keyboardAvoid.current.onKeyboardShow) {
|
|
38
|
+
// 修复部分 Android 机型可能时序问题:当从 input 已聚焦状态,聚焦到另一个 input 时,可能时序:
|
|
39
|
+
// - 新的 Input `onTouchStart` -> 新的 Input `onFocus` -> 旧输入框键盘 `keyboardDidHide` -> 新输入框键盘 `keyboardDidShow`
|
|
40
|
+
// - 此时 keyboardAvoid.current 如果清空 null,会导致新输入框键盘 `keyboardDidShow` 回调 keybaordAvoding 执行失败。
|
|
41
|
+
// 修复方案:
|
|
42
|
+
// 如果出现时序问题,那么新的 Input `onFocus` 会更早执行,那么 `keyboardAvoid.current.onKeyboardShow` 存在,
|
|
43
|
+
// 那么不应该重置为 null,反之,说明时正常情况,应当重置为 null。
|
|
44
|
+
keyboardAvoid.current = null;
|
|
45
|
+
}
|
|
34
46
|
}
|
|
35
47
|
cancelAnimation(offset);
|
|
36
48
|
offset.value = withTiming(0, { duration, easing });
|
|
@@ -38,13 +50,20 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
38
50
|
};
|
|
39
51
|
const onTouchEnd = ({ nativeEvent }) => {
|
|
40
52
|
if (nativeEvent.origin !== 'input') {
|
|
53
|
+
if (keyboardAvoid?.current?.holdKeyboard) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
41
56
|
Keyboard.isVisible() && Keyboard.dismiss();
|
|
42
57
|
}
|
|
43
58
|
};
|
|
44
59
|
useEffect(() => {
|
|
45
60
|
let subscriptions = [];
|
|
46
61
|
function keybaordAvoding(evt) {
|
|
47
|
-
if (
|
|
62
|
+
if (keyboardAvoid?.current?.readyToShow) {
|
|
63
|
+
// 重置标记位
|
|
64
|
+
keyboardAvoid.current.readyToShow = false;
|
|
65
|
+
}
|
|
66
|
+
if (!keyboardAvoid?.current) {
|
|
48
67
|
return;
|
|
49
68
|
}
|
|
50
69
|
isShow.current = true;
|
|
@@ -84,13 +103,23 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
84
103
|
}
|
|
85
104
|
}
|
|
86
105
|
if (isIOS) {
|
|
87
|
-
subscriptions = [
|
|
106
|
+
subscriptions = [
|
|
107
|
+
Keyboard.addListener('keyboardWillShow', (evt) => {
|
|
108
|
+
if (keybaordHandleTimerRef.current) {
|
|
109
|
+
clearTimeout(keybaordHandleTimerRef.current);
|
|
110
|
+
}
|
|
111
|
+
// iphone 在input聚焦时长按滑动后会导致 show 事件先于 focus 事件发生,因此等一下,等 focus 先触发拿到 input,避免键盘出现但input没顶上去
|
|
112
|
+
keybaordHandleTimerRef.current = setTimeout(() => keybaordAvoding(evt), 32);
|
|
113
|
+
}),
|
|
114
|
+
Keyboard.addListener('keyboardWillHide', resetKeyboard)
|
|
115
|
+
];
|
|
88
116
|
}
|
|
89
117
|
else {
|
|
90
118
|
subscriptions = [Keyboard.addListener('keyboardDidShow', keybaordAvoding), Keyboard.addListener('keyboardDidHide', resetKeyboard)];
|
|
91
119
|
}
|
|
92
120
|
return () => {
|
|
93
121
|
subscriptions.forEach(subscription => subscription.remove());
|
|
122
|
+
keybaordHandleTimerRef.current && clearTimeout(keybaordHandleTimerRef.current);
|
|
94
123
|
};
|
|
95
124
|
}, [keyboardAvoid]);
|
|
96
125
|
return (<View style={style} onTouchEnd={onTouchEnd} onTouchMove={onTouchEnd}>
|
|
@@ -18,4 +18,3 @@ interface MovableAreaProps {
|
|
|
18
18
|
}
|
|
19
19
|
declare const _MovableArea: import("react").ForwardRefExoticComponent<MovableAreaProps & import("react").RefAttributes<HandlerRef<View, MovableAreaProps>>>;
|
|
20
20
|
export default _MovableArea;
|
|
21
|
-
//# sourceMappingURL=mpx-movable-area.d.ts.map
|
|
@@ -63,4 +63,3 @@ interface MovableViewProps {
|
|
|
63
63
|
}
|
|
64
64
|
declare const _MovableView: import("react").ForwardRefExoticComponent<MovableViewProps & import("react").RefAttributes<HandlerRef<View, MovableViewProps>>>;
|
|
65
65
|
export default _MovableView;
|
|
66
|
-
//# sourceMappingURL=mpx-movable-view.d.ts.map
|
|
@@ -4,4 +4,3 @@ import { DateProps } from './type';
|
|
|
4
4
|
import { HandlerRef } from '../useNodesRef';
|
|
5
5
|
declare const PickerDate: React.ForwardRefExoticComponent<Omit<DateProps, "ref"> & React.RefAttributes<HandlerRef<View, DateProps>>>;
|
|
6
6
|
export default PickerDate;
|
|
7
|
-
//# sourceMappingURL=date.d.ts.map
|
|
@@ -5,4 +5,3 @@ export declare const years: string[];
|
|
|
5
5
|
export declare const months: string[];
|
|
6
6
|
export declare const daysInMonthLength: (year: number, month: number) => 30 | 28 | 29 | 31;
|
|
7
7
|
export declare const daysInMonth: (year: number, month: number) => string[];
|
|
8
|
-
//# sourceMappingURL=dateData.d.ts.map
|
|
@@ -4,4 +4,3 @@ import { HandlerRef } from '../useNodesRef';
|
|
|
4
4
|
import { PickerProps } from './type';
|
|
5
5
|
declare const Picker: React.ForwardRefExoticComponent<(Omit<import("./type").DateProps, "ref"> | Omit<import("./type").SelectorProps, "ref"> | Omit<import("./type").MultiSelectorProps, "ref"> | Omit<import("./type").TimeProps, "ref"> | Omit<import("./type").RegionProps, "ref">) & React.RefAttributes<HandlerRef<View, PickerProps>>>;
|
|
6
6
|
export default Picker;
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -4,4 +4,3 @@ import { MultiSelectorProps } from './type';
|
|
|
4
4
|
import { HandlerRef } from '../useNodesRef';
|
|
5
5
|
declare const PickerMultiSelector: React.ForwardRefExoticComponent<Omit<MultiSelectorProps, "ref"> & React.RefAttributes<HandlerRef<View, MultiSelectorProps>>>;
|
|
6
6
|
export default PickerMultiSelector;
|
|
7
|
-
//# sourceMappingURL=multiSelector.d.ts.map
|
|
@@ -4,4 +4,3 @@ import { RegionProps } from './type';
|
|
|
4
4
|
import { HandlerRef } from '../useNodesRef';
|
|
5
5
|
declare const PickerRegion: React.ForwardRefExoticComponent<Omit<RegionProps, "ref"> & React.RefAttributes<HandlerRef<View, RegionProps>>>;
|
|
6
6
|
export default PickerRegion;
|
|
7
|
-
//# sourceMappingURL=region.d.ts.map
|
|
@@ -4,4 +4,3 @@ import { SelectorProps } from './type';
|
|
|
4
4
|
import { HandlerRef } from '../useNodesRef';
|
|
5
5
|
declare const PickerSelector: React.ForwardRefExoticComponent<Omit<SelectorProps, "ref"> & React.RefAttributes<HandlerRef<View, SelectorProps>>>;
|
|
6
6
|
export default PickerSelector;
|
|
7
|
-
//# sourceMappingURL=selector.d.ts.map
|
|
@@ -4,4 +4,3 @@ import { TimeProps } from './type';
|
|
|
4
4
|
import { HandlerRef } from '../useNodesRef';
|
|
5
5
|
declare const PickerTime: React.ForwardRefExoticComponent<Omit<TimeProps, "ref"> & React.RefAttributes<HandlerRef<View, TimeProps>>>;
|
|
6
6
|
export default PickerTime;
|
|
7
|
-
//# sourceMappingURL=time.d.ts.map
|
|
@@ -6,4 +6,3 @@ export declare const usePickerViewColumnAnimationContext: () => ContextValue;
|
|
|
6
6
|
export declare const PickerViewStyleContext: import("react").Context<Record<string, any> | undefined>;
|
|
7
7
|
export declare const usePickerViewStyleContext: () => Record<string, any> | undefined;
|
|
8
8
|
export {};
|
|
9
|
-
//# sourceMappingURL=pickerVIewContext.d.ts.map
|
|
@@ -14,4 +14,3 @@ export declare const degToRad: (deg: number) => number;
|
|
|
14
14
|
export declare const calcPickerHeight: (faces: Faces[], itemHeight: number) => number;
|
|
15
15
|
export declare const calcHeightOffsets: (itemHeight: number) => number[];
|
|
16
16
|
export declare const createFaces: (itemHeight: number, visibleCount: number) => Faces[];
|
|
17
|
-
//# sourceMappingURL=pickerViewFaces.d.ts.map
|
|
@@ -7,7 +7,7 @@ const _PortalManager = forwardRef((props, ref) => {
|
|
|
7
7
|
setState((prevState) => ({
|
|
8
8
|
portals: [...prevState.portals, { key, children }]
|
|
9
9
|
}));
|
|
10
|
-
}, [
|
|
10
|
+
}, []);
|
|
11
11
|
const update = useCallback((key, children) => {
|
|
12
12
|
setState((prevState) => ({
|
|
13
13
|
portals: prevState.portals.map((item) => {
|
|
@@ -17,7 +17,7 @@ const _PortalManager = forwardRef((props, ref) => {
|
|
|
17
17
|
return item;
|
|
18
18
|
})
|
|
19
19
|
}));
|
|
20
|
-
}, [
|
|
20
|
+
}, []);
|
|
21
21
|
const unmount = useCallback((key) => {
|
|
22
22
|
setState((prevState) => ({
|
|
23
23
|
portals: prevState.portals.filter((item) => item.key !== key)
|
|
@@ -18,4 +18,3 @@ export interface RadioGroupProps {
|
|
|
18
18
|
}
|
|
19
19
|
declare const radioGroup: import("react").ForwardRefExoticComponent<RadioGroupProps & import("react").RefAttributes<HandlerRef<View, RadioGroupProps>>>;
|
|
20
20
|
export default radioGroup;
|
|
21
|
-
//# sourceMappingURL=mpx-radio-group.d.ts.map
|
|
@@ -52,4 +52,3 @@ declare const _ScrollView: import("react").ForwardRefExoticComponent<ScrollViewP
|
|
|
52
52
|
children?: ReactNode;
|
|
53
53
|
} & import("react-native-gesture-handler").NativeViewGestureHandlerProps & import("react").RefAttributes<import("react").ComponentType<any>>> & import("react-native").ScrollView & View, ScrollViewProps>>>;
|
|
54
54
|
export default _ScrollView;
|
|
55
|
-
//# sourceMappingURL=mpx-scroll-view.d.ts.map
|
|
@@ -42,17 +42,23 @@ import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, ext
|
|
|
42
42
|
import { IntersectionObserverContext, ScrollViewContext } from './context';
|
|
43
43
|
import Portal from './mpx-portal';
|
|
44
44
|
const AnimatedScrollView = RNAnimated.createAnimatedComponent(ScrollView);
|
|
45
|
+
const REFRESH_COLOR = {
|
|
46
|
+
black: ['#000'],
|
|
47
|
+
white: ['#fff']
|
|
48
|
+
};
|
|
45
49
|
const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
46
50
|
const { textProps, innerProps: props = {} } = splitProps(scrollViewProps);
|
|
47
|
-
const { enhanced = false, bounces = true, style = {}, binddragstart, binddragging, binddragend,
|
|
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, 'external-var-context': externalVarContext, '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;
|
|
48
52
|
const scrollOffset = useRef(new RNAnimated.Value(0)).current;
|
|
49
53
|
const simultaneousHandlers = flatGesture(originSimultaneousHandlers);
|
|
50
54
|
const waitForHandlers = flatGesture(waitFor);
|
|
55
|
+
const { refresherContent, otherContent } = getRefresherContent(props.children);
|
|
56
|
+
const hasRefresher = refresherContent && refresherEnabled;
|
|
51
57
|
const [refreshing, setRefreshing] = useState(false);
|
|
52
58
|
const [enableScroll, setEnableScroll] = useState(true);
|
|
53
|
-
const enableScrollValue = useSharedValue(true);
|
|
54
59
|
const [scrollBounces, setScrollBounces] = useState(false);
|
|
55
|
-
const
|
|
60
|
+
const enableScrollValue = useSharedValue(true);
|
|
61
|
+
const bouncesValue = useSharedValue(false);
|
|
56
62
|
const translateY = useSharedValue(0);
|
|
57
63
|
const isAtTop = useSharedValue(true);
|
|
58
64
|
const refresherHeight = useSharedValue(0);
|
|
@@ -68,13 +74,7 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
68
74
|
const initialTimeout = useRef(null);
|
|
69
75
|
const intersectionObservers = useContext(IntersectionObserverContext);
|
|
70
76
|
const firstScrollIntoViewChange = useRef(true);
|
|
71
|
-
const refreshColor = {
|
|
72
|
-
black: ['#000'],
|
|
73
|
-
white: ['#fff']
|
|
74
|
-
};
|
|
75
77
|
const isContentSizeChange = useRef(false);
|
|
76
|
-
const { refresherContent, otherContent } = getRefresherContent(props.children);
|
|
77
|
-
const hasRefresher = refresherContent && refresherEnabled;
|
|
78
78
|
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, hasPositionFixed, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
|
|
79
79
|
const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
|
|
80
80
|
const scrollViewRef = useRef(null);
|
|
@@ -455,67 +455,71 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
455
455
|
runOnJS(runOnJSCallback)('setScrollBounces', newValue);
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
// 处理下拉刷新的手势
|
|
459
|
-
const panGesture =
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
458
|
+
// 处理下拉刷新的手势 - 使用 useMemo 避免每次渲染都创建
|
|
459
|
+
const panGesture = useMemo(() => {
|
|
460
|
+
if (!hasRefresher)
|
|
461
|
+
return Gesture.Pan(); // 返回空手势
|
|
462
|
+
return Gesture.Pan()
|
|
463
|
+
.onUpdate((event) => {
|
|
464
|
+
'worklet';
|
|
465
|
+
if (enhanced && !!bounces) {
|
|
466
|
+
if (event.translationY > 0 && bouncesValue.value) {
|
|
467
|
+
updateBouncesState(false);
|
|
468
|
+
}
|
|
469
|
+
else if ((event.translationY < 0) && !bouncesValue.value) {
|
|
470
|
+
updateBouncesState(true);
|
|
471
|
+
}
|
|
465
472
|
}
|
|
466
|
-
|
|
467
|
-
|
|
473
|
+
if (translateY.value <= 0 && event.translationY < 0) {
|
|
474
|
+
// 滑动到顶再向上开启滚动
|
|
475
|
+
updateScrollState(true);
|
|
468
476
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
477
|
+
else if (event.translationY > 0 && isAtTop.value) {
|
|
478
|
+
// 滚动到顶再向下禁止滚动
|
|
479
|
+
updateScrollState(false);
|
|
480
|
+
}
|
|
481
|
+
// 禁止滚动后切换为滑动
|
|
482
|
+
if (!enableScrollValue.value && isAtTop.value) {
|
|
483
|
+
if (refreshing) {
|
|
484
|
+
// 从完全展开状态(refresherHeight.value)开始计算偏移
|
|
485
|
+
translateY.value = Math.max(0, Math.min(refresherHeight.value, refresherHeight.value + event.translationY));
|
|
486
|
+
}
|
|
487
|
+
else if (event.translationY > 0) {
|
|
488
|
+
// 非刷新状态下的下拉逻辑保持不变
|
|
489
|
+
translateY.value = Math.min(event.translationY * 0.6, refresherHeight.value);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
})
|
|
493
|
+
.onEnd((event) => {
|
|
494
|
+
'worklet';
|
|
495
|
+
if (enableScrollValue.value)
|
|
496
|
+
return;
|
|
480
497
|
if (refreshing) {
|
|
481
|
-
//
|
|
482
|
-
|
|
498
|
+
// 刷新状态下,根据滑动距离决定是否隐藏
|
|
499
|
+
// 如果向下滑动没超过 refresherThreshold,就完全隐藏,如果向上滑动完全隐藏
|
|
500
|
+
if ((event.translationY > 0 && translateY.value < refresherThreshold) || event.translationY < 0) {
|
|
501
|
+
translateY.value = withTiming(0);
|
|
502
|
+
updateScrollState(true);
|
|
503
|
+
runOnJS(runOnJSCallback)('setRefreshing', false);
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
translateY.value = withTiming(refresherHeight.value);
|
|
507
|
+
}
|
|
483
508
|
}
|
|
484
|
-
else if (event.translationY
|
|
485
|
-
//
|
|
486
|
-
translateY.value =
|
|
509
|
+
else if (event.translationY >= refresherHeight.value) {
|
|
510
|
+
// 触发刷新
|
|
511
|
+
translateY.value = withTiming(refresherHeight.value);
|
|
512
|
+
runOnJS(runOnJSCallback)('onRefresh');
|
|
487
513
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
.onEnd((event) => {
|
|
491
|
-
'worklet';
|
|
492
|
-
if (enableScrollValue.value)
|
|
493
|
-
return;
|
|
494
|
-
if (refreshing) {
|
|
495
|
-
// 刷新状态下,根据滑动距离决定是否隐藏
|
|
496
|
-
// 如果向下滑动没超过 refresherThreshold,就完全隐藏,如果向上滑动完全隐藏
|
|
497
|
-
if ((event.translationY > 0 && translateY.value < refresherThreshold) || event.translationY < 0) {
|
|
514
|
+
else {
|
|
515
|
+
// 回弹
|
|
498
516
|
translateY.value = withTiming(0);
|
|
499
517
|
updateScrollState(true);
|
|
500
518
|
runOnJS(runOnJSCallback)('setRefreshing', false);
|
|
501
519
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
else if (event.translationY >= refresherHeight.value) {
|
|
507
|
-
// 触发刷新
|
|
508
|
-
translateY.value = withTiming(refresherHeight.value);
|
|
509
|
-
runOnJS(runOnJSCallback)('onRefresh');
|
|
510
|
-
}
|
|
511
|
-
else {
|
|
512
|
-
// 回弹
|
|
513
|
-
translateY.value = withTiming(0);
|
|
514
|
-
updateScrollState(true);
|
|
515
|
-
runOnJS(runOnJSCallback)('setRefreshing', false);
|
|
516
|
-
}
|
|
517
|
-
})
|
|
518
|
-
.simultaneousWithExternalGesture(scrollViewRef);
|
|
520
|
+
})
|
|
521
|
+
.simultaneousWithExternalGesture(scrollViewRef);
|
|
522
|
+
}, [hasRefresher, enhanced, bounces, refreshing, refresherThreshold]);
|
|
519
523
|
const scrollAdditionalProps = extendObject({
|
|
520
524
|
style: extendObject(hasOwn(innerStyle, 'flex') || hasOwn(innerStyle, 'flexGrow')
|
|
521
525
|
? {}
|
|
@@ -575,29 +579,31 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
575
579
|
'bindrefresherrefresh'
|
|
576
580
|
], { layoutRef });
|
|
577
581
|
const ScrollViewComponent = enableSticky ? AnimatedScrollView : ScrollView;
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
582
|
+
const createScrollViewContent = () => {
|
|
583
|
+
const wrappedChildren = wrapChildren(hasRefresher ? extendObject({}, props, { children: otherContent }) : props, {
|
|
584
|
+
hasVarDec,
|
|
585
|
+
varContext: varContextRef.current,
|
|
586
|
+
textStyle,
|
|
587
|
+
textProps
|
|
588
|
+
});
|
|
589
|
+
return createElement(ScrollViewContext.Provider, { value: contextValue }, wrappedChildren);
|
|
590
|
+
};
|
|
591
|
+
const withRefresherScrollView = () => {
|
|
592
|
+
return createElement(GestureDetector, { gesture: panGesture }, createElement(ScrollViewComponent, innerProps, createElement(Animated.View, { style: [refresherAnimatedStyle, refresherLayoutStyle], onLayout: onRefresherLayout }, refresherContent), createElement(Animated.View, { style: contentAnimatedStyle }, createScrollViewContent())));
|
|
593
|
+
};
|
|
594
|
+
const commonScrollView = () => {
|
|
595
|
+
const refreshControl = refresherEnabled
|
|
586
596
|
? createElement(RefreshControl, extendObject({
|
|
587
597
|
progressBackgroundColor: refresherBackground,
|
|
588
598
|
refreshing: refreshing,
|
|
589
599
|
onRefresh: onRefresh
|
|
590
600
|
}, refresherDefaultStyle && refresherDefaultStyle !== 'none'
|
|
591
|
-
? { colors:
|
|
601
|
+
? { colors: REFRESH_COLOR[refresherDefaultStyle] }
|
|
592
602
|
: {}))
|
|
593
|
-
: undefined
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
textStyle,
|
|
598
|
-
textProps
|
|
599
|
-
})));
|
|
600
|
-
let scrollViewComponent = hasRefresher ? withRefresherScrollView : commonScrollView;
|
|
603
|
+
: undefined;
|
|
604
|
+
return createElement(ScrollViewComponent, extendObject({}, innerProps, { refreshControl }), createScrollViewContent());
|
|
605
|
+
};
|
|
606
|
+
let scrollViewComponent = hasRefresher ? withRefresherScrollView() : commonScrollView();
|
|
601
607
|
if (hasPositionFixed) {
|
|
602
608
|
scrollViewComponent = createElement(Portal, null, scrollViewComponent);
|
|
603
609
|
}
|
|
@@ -15,4 +15,3 @@ interface StickyHeaderProps {
|
|
|
15
15
|
}
|
|
16
16
|
declare const _StickyHeader: import("react").ForwardRefExoticComponent<StickyHeaderProps & import("react").RefAttributes<HandlerRef<View, StickyHeaderProps>>>;
|
|
17
17
|
export default _StickyHeader;
|
|
18
|
-
//# sourceMappingURL=mpx-sticky-header.d.ts.map
|