@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
|
@@ -8,9 +8,8 @@ import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
|
8
8
|
const _StickyHeader = forwardRef((stickyHeaderProps = {}, ref) => {
|
|
9
9
|
const { textProps, innerProps: props = {} } = splitProps(stickyHeaderProps);
|
|
10
10
|
const { style, bindstickontopchange, padding = [0, 0, 0, 0], 'offset-top': offsetTop = 0, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
11
|
-
const
|
|
11
|
+
const { scrollOffset, gestureRef: scrollViewRef } = useContext(ScrollViewContext);
|
|
12
12
|
const stickyContext = useContext(StickyContext);
|
|
13
|
-
const { scrollOffset } = scrollViewContext;
|
|
14
13
|
const { registerStickyHeader, unregisterStickyHeader } = stickyContext;
|
|
15
14
|
const headerRef = useRef(null);
|
|
16
15
|
const isStickOnTopRef = useRef(false);
|
|
@@ -29,7 +28,6 @@ const _StickyHeader = forwardRef((stickyHeaderProps = {}, ref) => {
|
|
|
29
28
|
}, []);
|
|
30
29
|
function updatePosition() {
|
|
31
30
|
if (headerRef.current) {
|
|
32
|
-
const scrollViewRef = scrollViewContext.gestureRef;
|
|
33
31
|
if (scrollViewRef && scrollViewRef.current) {
|
|
34
32
|
headerRef.current.measureLayout(scrollViewRef.current, (left, top) => {
|
|
35
33
|
Animated.timing(headerTopAnimated, {
|
|
@@ -52,7 +50,7 @@ const _StickyHeader = forwardRef((stickyHeaderProps = {}, ref) => {
|
|
|
52
50
|
style: normalStyle
|
|
53
51
|
});
|
|
54
52
|
useEffect(() => {
|
|
55
|
-
if (!bindstickontopchange)
|
|
53
|
+
if (!bindstickontopchange || !scrollOffset)
|
|
56
54
|
return;
|
|
57
55
|
const listener = scrollOffset.addListener((state) => {
|
|
58
56
|
const currentScrollValue = state.value;
|
|
@@ -70,24 +68,26 @@ const _StickyHeader = forwardRef((stickyHeaderProps = {}, ref) => {
|
|
|
70
68
|
return () => {
|
|
71
69
|
scrollOffset.removeListener(listener);
|
|
72
70
|
};
|
|
73
|
-
}, []);
|
|
71
|
+
}, [bindstickontopchange, scrollOffset]);
|
|
74
72
|
const animatedStyle = useMemo(() => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
outputRange: [0, 1],
|
|
78
|
-
extrapolateLeft: 'clamp',
|
|
79
|
-
extrapolateRight: 'extend'
|
|
80
|
-
});
|
|
81
|
-
const finalTranslateY = offsetTop === 0
|
|
82
|
-
? translateY
|
|
83
|
-
: Animated.add(translateY, Animated.subtract(scrollOffset, headerTopAnimated).interpolate({
|
|
73
|
+
if (scrollOffset) {
|
|
74
|
+
const translateY = Animated.subtract(scrollOffset, headerTopAnimated).interpolate({
|
|
84
75
|
inputRange: [0, 1],
|
|
85
|
-
outputRange: [0,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
76
|
+
outputRange: [0, 1],
|
|
77
|
+
extrapolateLeft: 'clamp',
|
|
78
|
+
extrapolateRight: 'extend'
|
|
79
|
+
});
|
|
80
|
+
const finalTranslateY = offsetTop === 0
|
|
81
|
+
? translateY
|
|
82
|
+
: Animated.add(translateY, Animated.subtract(scrollOffset, headerTopAnimated).interpolate({
|
|
83
|
+
inputRange: [0, 1],
|
|
84
|
+
outputRange: [0, offsetTop],
|
|
85
|
+
extrapolate: 'clamp'
|
|
86
|
+
}));
|
|
87
|
+
return {
|
|
88
|
+
transform: [{ translateY: finalTranslateY }]
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
91
|
}, [scrollOffset, headerTopAnimated, offsetTop]);
|
|
92
92
|
const innerProps = useInnerProps(extendObject({}, props, {
|
|
93
93
|
ref: headerRef,
|
|
@@ -13,4 +13,3 @@ interface StickySectionProps {
|
|
|
13
13
|
}
|
|
14
14
|
declare const _StickySection: import("react").ForwardRefExoticComponent<StickySectionProps & import("react").RefAttributes<HandlerRef<View, StickySectionProps>>>;
|
|
15
15
|
export default _StickySection;
|
|
16
|
-
//# sourceMappingURL=mpx-sticky-section.d.ts.map
|
|
@@ -5,6 +5,11 @@ import { GestureHandler } from './utils';
|
|
|
5
5
|
/**
|
|
6
6
|
* ✔ indicator-dots
|
|
7
7
|
* ✔ indicator-color
|
|
8
|
+
* ✔ indicator-width
|
|
9
|
+
* ✔ indicator-height
|
|
10
|
+
* ✔ indicator-radius
|
|
11
|
+
* ✔ indicator-spacing
|
|
12
|
+
* ✔ indicator-margin
|
|
8
13
|
* ✔ indicator-active-color
|
|
9
14
|
* ✔ autoplay
|
|
10
15
|
* ✔ current
|
|
@@ -29,6 +34,11 @@ interface SwiperProps {
|
|
|
29
34
|
scale?: boolean;
|
|
30
35
|
'indicator-dots'?: boolean;
|
|
31
36
|
'indicator-color'?: string;
|
|
37
|
+
'indicator-width'?: number;
|
|
38
|
+
'indicator-height'?: number;
|
|
39
|
+
'indicator-spacing'?: number;
|
|
40
|
+
'indicator-radius'?: number;
|
|
41
|
+
'indicator-margin'?: number;
|
|
32
42
|
'indicator-active-color'?: string;
|
|
33
43
|
vertical?: boolean;
|
|
34
44
|
style: {
|
|
@@ -50,4 +60,3 @@ interface SwiperProps {
|
|
|
50
60
|
}
|
|
51
61
|
declare const SwiperWrapper: React.ForwardRefExoticComponent<SwiperProps & React.RefAttributes<HandlerRef<View, SwiperProps>>>;
|
|
52
62
|
export default SwiperWrapper;
|
|
53
|
-
//# sourceMappingURL=mpx-swiper.d.ts.map
|
|
@@ -13,23 +13,23 @@ import Portal from './mpx-portal';
|
|
|
13
13
|
const styles = {
|
|
14
14
|
pagination_x: {
|
|
15
15
|
position: 'absolute',
|
|
16
|
-
bottom:
|
|
16
|
+
bottom: 0,
|
|
17
17
|
left: 0,
|
|
18
18
|
right: 0,
|
|
19
19
|
flexDirection: 'row',
|
|
20
20
|
flex: 1,
|
|
21
21
|
justifyContent: 'center',
|
|
22
|
-
alignItems: '
|
|
22
|
+
alignItems: 'flex-end'
|
|
23
23
|
},
|
|
24
24
|
pagination_y: {
|
|
25
25
|
position: 'absolute',
|
|
26
|
-
right:
|
|
26
|
+
right: 0,
|
|
27
27
|
top: 0,
|
|
28
28
|
bottom: 0,
|
|
29
29
|
flexDirection: 'column',
|
|
30
30
|
flex: 1,
|
|
31
31
|
justifyContent: 'center',
|
|
32
|
-
alignItems: '
|
|
32
|
+
alignItems: 'flex-end'
|
|
33
33
|
},
|
|
34
34
|
pagerWrapperx: {
|
|
35
35
|
position: 'absolute',
|
|
@@ -49,16 +49,6 @@ const styles = {
|
|
|
49
49
|
justifyContent: 'flex-start'
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
const dotCommonStyle = {
|
|
53
|
-
width: 8,
|
|
54
|
-
height: 8,
|
|
55
|
-
borderRadius: 4,
|
|
56
|
-
marginLeft: 3,
|
|
57
|
-
marginRight: 3,
|
|
58
|
-
marginTop: 3,
|
|
59
|
-
marginBottom: 3,
|
|
60
|
-
zIndex: 98
|
|
61
|
-
};
|
|
62
52
|
const activeDotStyle = {
|
|
63
53
|
zIndex: 99
|
|
64
54
|
};
|
|
@@ -71,7 +61,17 @@ const easeMap = {
|
|
|
71
61
|
easeInOutCubic: Easing.inOut(Easing.cubic)
|
|
72
62
|
};
|
|
73
63
|
const SwiperWrapper = forwardRef((props, ref) => {
|
|
74
|
-
const { 'indicator-dots': showPagination, '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, '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 } = props;
|
|
65
|
+
const dotCommonStyle = {
|
|
66
|
+
width: dotWidth,
|
|
67
|
+
height: dotHeight,
|
|
68
|
+
borderRadius: dotRadius,
|
|
69
|
+
marginLeft: dotSpacing,
|
|
70
|
+
marginRight: dotSpacing,
|
|
71
|
+
marginTop: dotSpacing,
|
|
72
|
+
marginBottom: dotSpacing,
|
|
73
|
+
zIndex: 98
|
|
74
|
+
};
|
|
75
75
|
const easeingFunc = props['easing-function'] || 'default';
|
|
76
76
|
const easeDuration = props.duration || 500;
|
|
77
77
|
const horizontal = props.vertical !== undefined ? !props.vertical : true;
|
|
@@ -101,7 +101,8 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
101
101
|
const patchElmNum = circular ? (preMargin ? 2 : 1) : 0;
|
|
102
102
|
const patchElmNumShared = useSharedValue(patchElmNum);
|
|
103
103
|
const circularShared = useSharedValue(circular);
|
|
104
|
-
|
|
104
|
+
// 支持swiper-item 同时存在<swiper-item wx:for/>和<swiper-item>并列的情况
|
|
105
|
+
const children = React.Children.toArray(props.children);
|
|
105
106
|
// 对有变化的变量,在worklet中只能使用sharedValue变量,useRef不能更新
|
|
106
107
|
const childrenLength = useSharedValue(children.length);
|
|
107
108
|
const initWidth = typeof normalStyle?.width === 'number' ? normalStyle.width - preMargin - nextMargin : normalStyle.width;
|
|
@@ -124,8 +125,12 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
124
125
|
const preAbsolutePos = useSharedValue(0);
|
|
125
126
|
// 记录从onBegin 到 onTouchesUp 时移动的距离
|
|
126
127
|
const moveTranstion = useSharedValue(0);
|
|
128
|
+
// 记录用户手滑动的方向
|
|
129
|
+
const moveDir = useSharedValue(0);
|
|
127
130
|
const timerId = useRef(0);
|
|
128
131
|
const intervalTimer = props.interval || 500;
|
|
132
|
+
// 记录是否首次,首次不能触发bindchange回调
|
|
133
|
+
const isFirstRef = useRef(true);
|
|
129
134
|
const simultaneousHandlers = flatGesture(originSimultaneousHandlers);
|
|
130
135
|
const waitForHandlers = flatGesture(waitFor);
|
|
131
136
|
// 判断gesture手势是否需要协同处理、等待手势失败响应
|
|
@@ -152,6 +157,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
152
157
|
'style',
|
|
153
158
|
'indicator-dots',
|
|
154
159
|
'indicator-color',
|
|
160
|
+
'indicator-width',
|
|
155
161
|
'indicator-active-color',
|
|
156
162
|
'previous-margin',
|
|
157
163
|
'vertical',
|
|
@@ -193,7 +199,17 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
193
199
|
for (let i = 0; i < children.length; i++) {
|
|
194
200
|
dots.push(<View style={[dotCommonStyle, { backgroundColor: unActionColor }]} key={i}></View>);
|
|
195
201
|
}
|
|
196
|
-
|
|
202
|
+
let paginationStyle = styles['pagination_' + dir];
|
|
203
|
+
if (paginationMargin) {
|
|
204
|
+
paginationStyle = {
|
|
205
|
+
...paginationStyle,
|
|
206
|
+
marginBottom: paginationMargin,
|
|
207
|
+
marginLeft: paginationMargin,
|
|
208
|
+
marginRight: paginationMargin,
|
|
209
|
+
marginTop: paginationMargin
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
return (<View pointerEvents="none" style={paginationStyle} key="pagination">
|
|
197
213
|
<View style={[styles['pagerWrapper' + dir]]}>
|
|
198
214
|
<Animated.View style={[
|
|
199
215
|
dotCommonStyle,
|
|
@@ -325,11 +341,9 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
325
341
|
resumeLoop
|
|
326
342
|
};
|
|
327
343
|
}, []);
|
|
328
|
-
function handleSwiperChange(current
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
bindchange && bindchange(eventData);
|
|
332
|
-
}
|
|
344
|
+
function handleSwiperChange(current) {
|
|
345
|
+
const eventData = getCustomEvent('change', {}, { detail: { current, source: 'touch' }, layoutRef: layoutRef });
|
|
346
|
+
bindchange && bindchange(eventData);
|
|
333
347
|
}
|
|
334
348
|
const runOnJSCallbackRef = useRef({
|
|
335
349
|
loop,
|
|
@@ -379,9 +393,10 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
379
393
|
// 1. 用户在当前页切换选中项,动画;用户携带选中index打开到swiper页直接选中不走动画
|
|
380
394
|
useAnimatedReaction(() => currentIndex.value, (newIndex, preIndex) => {
|
|
381
395
|
// 这里必须传递函数名, 直接写()=> {}形式会报 访问了未sharedValue信息
|
|
382
|
-
if (newIndex !== preIndex && bindchange) {
|
|
396
|
+
if (newIndex !== preIndex && bindchange && !isFirstRef.current) {
|
|
383
397
|
runOnJS(runOnJSCallback)('handleSwiperChange', newIndex, propCurrent);
|
|
384
398
|
}
|
|
399
|
+
isFirstRef.current = false;
|
|
385
400
|
});
|
|
386
401
|
useEffect(() => {
|
|
387
402
|
let patchStep = 0;
|
|
@@ -434,6 +449,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
434
449
|
}
|
|
435
450
|
}, [circular, preMargin]);
|
|
436
451
|
const { gestureHandler } = useMemo(() => {
|
|
452
|
+
// 基于transdir + 当前offset计算索引
|
|
437
453
|
function getTargetPosition(eventData) {
|
|
438
454
|
'worklet';
|
|
439
455
|
// 移动的距离
|
|
@@ -546,10 +562,8 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
546
562
|
}
|
|
547
563
|
});
|
|
548
564
|
}
|
|
549
|
-
|
|
550
|
-
function computeHalf(eventData) {
|
|
565
|
+
function computeHalf() {
|
|
551
566
|
'worklet';
|
|
552
|
-
const { transdir } = eventData;
|
|
553
567
|
const currentOffset = Math.abs(offset.value);
|
|
554
568
|
let preOffset = (currentIndex.value + patchElmNumShared.value) * step.value;
|
|
555
569
|
if (circularShared.value) {
|
|
@@ -558,35 +572,14 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
558
572
|
// 正常事件中拿到的translation值(正向滑动<0,倒着滑>0)
|
|
559
573
|
const diffOffset = preOffset - currentOffset;
|
|
560
574
|
const half = Math.abs(diffOffset) > step.value / 2;
|
|
561
|
-
|
|
562
|
-
return {
|
|
563
|
-
diffOffset,
|
|
564
|
-
half,
|
|
565
|
-
isTriggerUpdateHalf
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
function handleLongPress(eventData) {
|
|
569
|
-
'worklet';
|
|
570
|
-
const { diffOffset, half, isTriggerUpdateHalf } = computeHalf(eventData);
|
|
571
|
-
if (+diffOffset === 0) {
|
|
572
|
-
runOnJS(runOnJSCallback)('resumeLoop');
|
|
573
|
-
}
|
|
574
|
-
else if (isTriggerUpdateHalf) {
|
|
575
|
-
// 如果触发了onUpdate时的索引变更
|
|
576
|
-
handleEnd(eventData);
|
|
577
|
-
}
|
|
578
|
-
else if (half) {
|
|
579
|
-
handleEnd(eventData);
|
|
580
|
-
}
|
|
581
|
-
else {
|
|
582
|
-
handleBack(eventData);
|
|
583
|
-
}
|
|
575
|
+
return half;
|
|
584
576
|
}
|
|
585
577
|
function reachBoundary(eventData) {
|
|
586
578
|
'worklet';
|
|
587
579
|
// 1. 基于当前的offset和translation判断是否超过当前边界值
|
|
588
580
|
const { translation } = eventData;
|
|
589
|
-
|
|
581
|
+
// 与终点的逻辑对齐,都是超过补位元素对应的起点offset
|
|
582
|
+
const boundaryStart = 0;
|
|
590
583
|
const boundaryEnd = -(childrenLength.value + patchElmNumShared.value) * step.value;
|
|
591
584
|
const moveToOffset = offset.value + translation;
|
|
592
585
|
let isBoundary = false;
|
|
@@ -603,7 +596,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
603
596
|
// 超过边界的距离
|
|
604
597
|
const exceedLength = Math.abs(boundaryStart) - Math.abs(moveToOffset);
|
|
605
598
|
// 计算对标正常元素所在的offset
|
|
606
|
-
resetOffset = (patchElmNumShared.value + childrenLength.value - 1) * step.value
|
|
599
|
+
resetOffset = (patchElmNumShared.value + childrenLength.value - 1) * step.value - exceedLength;
|
|
607
600
|
}
|
|
608
601
|
return {
|
|
609
602
|
isBoundary,
|
|
@@ -642,6 +635,14 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
642
635
|
}
|
|
643
636
|
return finalOffset;
|
|
644
637
|
}
|
|
638
|
+
// 设置手势移动的方向
|
|
639
|
+
function setMoveDir(curAbsoPos) {
|
|
640
|
+
'worklet';
|
|
641
|
+
const distance = curAbsoPos - preAbsolutePos.value;
|
|
642
|
+
if (distance) {
|
|
643
|
+
moveDir.value = curAbsoPos - preAbsolutePos.value;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
645
646
|
const gesturePan = Gesture.Pan()
|
|
646
647
|
.onBegin((e) => {
|
|
647
648
|
'worklet';
|
|
@@ -663,9 +664,9 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
663
664
|
transdir: moveDistance
|
|
664
665
|
};
|
|
665
666
|
// 1. 支持滑动中超出一半更新索引的能力:只更新索引并不会影响onFinalize依据当前offset计算的索引
|
|
666
|
-
const
|
|
667
|
-
if (childrenLength.value > 1 &&
|
|
668
|
-
const { selectedIndex } = getTargetPosition(
|
|
667
|
+
const offsetHalf = computeHalf();
|
|
668
|
+
if (childrenLength.value > 1 && offsetHalf) {
|
|
669
|
+
const { selectedIndex } = getTargetPosition({ transdir: moveDistance });
|
|
669
670
|
currentIndex.value = selectedIndex;
|
|
670
671
|
}
|
|
671
672
|
// 2. 非循环: 处理用户一直拖拽到临界点的场景,如果放到onFinalize无法阻止offset.value更新为越界的值
|
|
@@ -677,6 +678,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
677
678
|
const finalOffset = handleResistanceMove(eventData);
|
|
678
679
|
offset.value = finalOffset;
|
|
679
680
|
}
|
|
681
|
+
setMoveDir(e[strAbso]);
|
|
680
682
|
preAbsolutePos.value = e[strAbso];
|
|
681
683
|
return;
|
|
682
684
|
}
|
|
@@ -684,6 +686,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
684
686
|
if (circularShared.value && childrenLength.value === 1) {
|
|
685
687
|
const finalOffset = handleResistanceMove(eventData);
|
|
686
688
|
offset.value = finalOffset;
|
|
689
|
+
setMoveDir(e[strAbso]);
|
|
687
690
|
preAbsolutePos.value = e[strAbso];
|
|
688
691
|
return;
|
|
689
692
|
}
|
|
@@ -695,6 +698,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
695
698
|
else {
|
|
696
699
|
offset.value = moveDistance + offset.value;
|
|
697
700
|
}
|
|
701
|
+
setMoveDir(e[strAbso]);
|
|
698
702
|
preAbsolutePos.value = e[strAbso];
|
|
699
703
|
})
|
|
700
704
|
.onFinalize((e) => {
|
|
@@ -703,10 +707,21 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
703
707
|
return;
|
|
704
708
|
touchfinish.value = true;
|
|
705
709
|
// 触发过onUpdate正常情况下e[strAbso] - preAbsolutePos.value=0; 未触发过onUpdate的情况下e[strAbso] - preAbsolutePos.value 不为0
|
|
710
|
+
// 正常状态下基于onUpdate时的moveDir判断方向、未触发onUpdate的则基于onBegin的moveTranstion判断方向
|
|
706
711
|
const moveDistance = e[strAbso] - preAbsolutePos.value;
|
|
712
|
+
// 默认兜底方向: 以onBegin为起点,因一些原因未触发onUpdate但是触发了位移
|
|
713
|
+
const defaultDir = e[strAbso] - moveTranstion.value;
|
|
714
|
+
// 实时方向:方向基于onUpdate时的方向,滑动的速度超过阈值时基于实时的滑动方向计算
|
|
715
|
+
const realtimeData = {
|
|
716
|
+
transdir: moveDir.value || defaultDir
|
|
717
|
+
};
|
|
718
|
+
// 起始方向:基于用户起始手势
|
|
719
|
+
const originData = {
|
|
720
|
+
transdir: defaultDir
|
|
721
|
+
};
|
|
707
722
|
const eventData = {
|
|
708
723
|
translation: moveDistance,
|
|
709
|
-
transdir:
|
|
724
|
+
transdir: realtimeData.transdir
|
|
710
725
|
};
|
|
711
726
|
// 1. 只有一个元素:循环 和 非循环状态,都走回弹效果
|
|
712
727
|
if (childrenLength.value === 1) {
|
|
@@ -720,21 +735,39 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
720
735
|
// 非循环支持最后元素可滑动能力后,向左快速移动未超过最大可移动范围一半,因为offset为正值,向左滑动handleBack,默认向上取整
|
|
721
736
|
// 但是在offset大于0时,取0。[-100, 0](back取0), [0, 100](back取1), 所以handleLongPress里的处理逻辑需要兼容支持,因此这里直接单独处理,不耦合下方公共的判断逻辑。
|
|
722
737
|
if (!circularShared.value && !canMove(eventData)) {
|
|
723
|
-
if (
|
|
724
|
-
handleBack(
|
|
738
|
+
if (realtimeData.transdir < 0) {
|
|
739
|
+
handleBack(realtimeData);
|
|
725
740
|
}
|
|
726
741
|
else {
|
|
727
|
-
handleEnd(
|
|
742
|
+
handleEnd(realtimeData);
|
|
728
743
|
}
|
|
729
744
|
return;
|
|
730
745
|
}
|
|
731
746
|
// 3. 非循环状态可移动态、循环状态, 正常逻辑处理
|
|
732
747
|
const velocity = e[strVelocity];
|
|
733
|
-
|
|
734
|
-
|
|
748
|
+
// 用于判断是否超过一半,基于索引判断是否超过一半不可行(1.滑动过程中索引会变更导致计算反向, 2.边界场景会更新offset也会导致基于索引+offset判断实效)
|
|
749
|
+
const tmp = offset.value % step.value > step.value / 2;
|
|
750
|
+
// 小于0手向左滑动
|
|
751
|
+
const offsetHalf = originData.transdir < 0 ? tmp : !tmp;
|
|
752
|
+
if (offsetHalf) {
|
|
753
|
+
if (Math.abs(velocity) > longPressRatio) {
|
|
754
|
+
// 超过速度阈值,按照实时方向(快速来回滑动)
|
|
755
|
+
handleEnd(realtimeData);
|
|
756
|
+
}
|
|
757
|
+
else {
|
|
758
|
+
// 超过速度阈值,按照起始方向(慢速长按)
|
|
759
|
+
handleEnd(originData);
|
|
760
|
+
}
|
|
735
761
|
}
|
|
736
762
|
else {
|
|
737
|
-
|
|
763
|
+
if (Math.abs(velocity) > longPressRatio) {
|
|
764
|
+
// 超过速度阈值,按照实时方向(快速来回滑动)
|
|
765
|
+
handleEnd(realtimeData);
|
|
766
|
+
}
|
|
767
|
+
else {
|
|
768
|
+
// 超过速度阈值,按照起始方向(慢速长按)
|
|
769
|
+
handleBack(originData);
|
|
770
|
+
}
|
|
738
771
|
}
|
|
739
772
|
})
|
|
740
773
|
.withRef(swiperGestureRef);
|
|
@@ -770,6 +803,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
770
803
|
style: [normalStyle, layoutStyle, styles.swiper]
|
|
771
804
|
}, layoutProps, innerProps);
|
|
772
805
|
const animateComponent = createElement(Animated.View, {
|
|
806
|
+
key: 'swiperContainer',
|
|
773
807
|
style: [{ flexDirection: dir === 'x' ? 'row' : 'column', width: '100%', height: '100%' }, animatedStyles]
|
|
774
808
|
}, wrapChildren({
|
|
775
809
|
children: arrPages
|
|
@@ -5,4 +5,3 @@ import { HandlerRef } from './useNodesRef';
|
|
|
5
5
|
export type TextareProps = Omit<InputProps & PrivateInputProps, 'type' | 'password' | 'multiline' | 'confirm-hold'>;
|
|
6
6
|
declare const Textarea: import("react").ForwardRefExoticComponent<TextareProps & import("react").RefAttributes<HandlerRef<TextInput, TextareProps>>>;
|
|
7
7
|
export default Textarea;
|
|
8
|
-
//# sourceMappingURL=mpx-textarea.d.ts.map
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { View, NativeSyntheticEvent, ViewProps } from 'react-native';
|
|
8
8
|
import { ReactNode } from 'react';
|
|
9
|
-
import
|
|
9
|
+
import { AnimationType } from './animationHooks/index';
|
|
10
|
+
import type { AnimationProp } from './animationHooks/utils';
|
|
10
11
|
import { ExtendedViewStyle } from './types/common';
|
|
11
12
|
import { HandlerRef } from './useNodesRef';
|
|
12
13
|
export interface _ViewProps extends ViewProps {
|
|
@@ -23,7 +24,7 @@ export interface _ViewProps extends ViewProps {
|
|
|
23
24
|
'parent-font-size'?: number;
|
|
24
25
|
'parent-width'?: number;
|
|
25
26
|
'parent-height'?: number;
|
|
26
|
-
'enable-animation'?: boolean;
|
|
27
|
+
'enable-animation'?: boolean | AnimationType;
|
|
27
28
|
bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
28
29
|
bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
29
30
|
bindtouchend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
@@ -32,4 +33,3 @@ export interface _ViewProps extends ViewProps {
|
|
|
32
33
|
}
|
|
33
34
|
declare const _View: import("react").ForwardRefExoticComponent<_ViewProps & import("react").RefAttributes<HandlerRef<View, _ViewProps>>>;
|
|
34
35
|
export default _View;
|
|
35
|
-
//# sourceMappingURL=mpx-view.d.ts.map
|
|
@@ -8,7 +8,7 @@ import { View, StyleSheet, Image } from 'react-native';
|
|
|
8
8
|
import { useRef, useState, useEffect, forwardRef, createElement } from 'react';
|
|
9
9
|
import useInnerProps from './getInnerListeners';
|
|
10
10
|
import Animated from 'react-native-reanimated';
|
|
11
|
-
import useAnimationHooks from './
|
|
11
|
+
import useAnimationHooks from './animationHooks/index';
|
|
12
12
|
import useNodesRef from './useNodesRef';
|
|
13
13
|
import { parseUrl, PERCENT_REGEX, splitStyle, splitProps, useTransformStyle, wrapChildren, useLayout, renderImage, pickStyle, extendObject, useHover } from './utils';
|
|
14
14
|
import { error, isFunction } from '@mpxjs/utils';
|
|
@@ -203,7 +203,7 @@ function backgroundSize(imageProps, preImageInfo, imageSize, layoutInfo) {
|
|
|
203
203
|
else { // 数值类型 ImageStyle
|
|
204
204
|
// 数值类型设置为 stretch
|
|
205
205
|
imageProps.resizeMode = 'stretch';
|
|
206
|
-
if (type === 'linear' && (!layoutWidth || !layoutHeight)) {
|
|
206
|
+
if (type === 'linear' && (!layoutWidth || !layoutHeight) && (isPercent(width) || isPercent(height))) {
|
|
207
207
|
// ios 上 linear 组件只要重新触发渲染,在渲染过程中外层容器 width 或者 height 被设置为 0,通过设置 % 的方式会渲染不出来,即使后面再更新为正常宽高也渲染不出来
|
|
208
208
|
// 所以 hack 手动先将 linear 宽高也设置为 0,后面再更新为正确的数值或 %。
|
|
209
209
|
dimensions = {
|
|
@@ -274,6 +274,18 @@ function normalizeBackgroundPosition(parts) {
|
|
|
274
274
|
let hOffset = 0;
|
|
275
275
|
let vStart = 'top';
|
|
276
276
|
let vOffset = 0;
|
|
277
|
+
if (!Array.isArray(parts)) {
|
|
278
|
+
// 模板 style 属性传入单个数值时不会和 class 一样转成数组,需要手动转换
|
|
279
|
+
parts = [parts];
|
|
280
|
+
}
|
|
281
|
+
// 模板 style 属性传入时, 需要额外转换处理单位 px/rpx/vh 以及 center 转化为 50%
|
|
282
|
+
parts = parts.map((part) => {
|
|
283
|
+
if (typeof part !== 'string')
|
|
284
|
+
return part;
|
|
285
|
+
if (part === 'center')
|
|
286
|
+
return '50%';
|
|
287
|
+
return global.__formatValue(part);
|
|
288
|
+
});
|
|
277
289
|
if (parts.length === 4)
|
|
278
290
|
return parts;
|
|
279
291
|
// 归一化
|
|
@@ -415,14 +427,16 @@ function normalizeBackgroundSize(backgroundSize, type) {
|
|
|
415
427
|
const sizeList = backgroundSize.slice();
|
|
416
428
|
if (sizeList.length === 1)
|
|
417
429
|
sizeList.push('auto');
|
|
418
|
-
|
|
430
|
+
return sizeList.map((val) => {
|
|
431
|
+
if (typeof val !== 'string')
|
|
432
|
+
return val;
|
|
419
433
|
// 处理当使用渐变的时候,background-size出现cover, contain, auto,当作100%处理
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
sizeList[i] = /^cover|contain|auto$/.test(val) ? '100%' : val;
|
|
434
|
+
if (type === 'linear' && /^cover|contain|auto$/.test(val)) {
|
|
435
|
+
val = '100%';
|
|
423
436
|
}
|
|
424
|
-
|
|
425
|
-
|
|
437
|
+
// 模板 style 属性传入时, 需要额外转换处理单位 px/rpx/vh
|
|
438
|
+
return global.__formatValue(val);
|
|
439
|
+
});
|
|
426
440
|
}
|
|
427
441
|
function preParseImage(imageStyle) {
|
|
428
442
|
const { backgroundImage = '', backgroundSize = ['auto'], backgroundPosition = [0, 0] } = normalizeStyle(imageStyle) || {};
|
|
@@ -20,4 +20,3 @@ interface WebViewProps {
|
|
|
20
20
|
}
|
|
21
21
|
declare const _WebView: import("react").ForwardRefExoticComponent<Omit<WebViewProps, "ref"> & import("react").RefAttributes<HandlerRef<WebView<{}>, WebViewProps>>>;
|
|
22
22
|
export default _WebView;
|
|
23
|
-
//# sourceMappingURL=mpx-web-view.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode, ReactElement, Dispatch, SetStateAction, MutableRefObject } from 'react';
|
|
2
2
|
import { LayoutChangeEvent, TextStyle, ImageProps } from 'react-native';
|
|
3
|
-
import { FastImageProps } from '@d11/react-native-fast-image';
|
|
3
|
+
import type { FastImageProps } from '@d11/react-native-fast-image';
|
|
4
4
|
import type { AnyFunc } from './types/common';
|
|
5
5
|
export declare const TEXT_STYLE_REGEX: RegExp;
|
|
6
6
|
export declare const PERCENT_REGEX: RegExp;
|
|
@@ -15,6 +15,12 @@ export declare const HIDDEN_STYLE: {
|
|
|
15
15
|
export declare const isIOS: boolean;
|
|
16
16
|
export declare const isAndroid: boolean;
|
|
17
17
|
export declare const isHarmony: boolean;
|
|
18
|
+
export declare const extendObject: {
|
|
19
|
+
<T extends {}, U>(target: T, source: U): T & U;
|
|
20
|
+
<T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
|
|
21
|
+
<T_2 extends {}, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
|
|
22
|
+
(target: object, ...sources: any[]): any;
|
|
23
|
+
};
|
|
18
24
|
export declare function useNavigation(): Record<string, any> | undefined;
|
|
19
25
|
export declare function omit<T, K extends string>(obj: T, fields: K[]): Omit<T, K>;
|
|
20
26
|
/**
|
|
@@ -32,14 +38,16 @@ export declare function splitStyle<T extends Record<string, any>>(styleObj: T):
|
|
|
32
38
|
backgroundStyle?: Partial<T>;
|
|
33
39
|
innerStyle?: Partial<T>;
|
|
34
40
|
};
|
|
41
|
+
export declare function parseValues(str: string, char?: string): string[];
|
|
35
42
|
interface TransformStyleConfig {
|
|
36
43
|
enableVar?: boolean;
|
|
37
44
|
externalVarContext?: Record<string, any>;
|
|
38
45
|
parentFontSize?: number;
|
|
39
46
|
parentWidth?: number;
|
|
40
47
|
parentHeight?: number;
|
|
48
|
+
transformRadiusPercent?: boolean;
|
|
41
49
|
}
|
|
42
|
-
export declare function useTransformStyle(styleObj: Record<string, any> | undefined, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight }: TransformStyleConfig): {
|
|
50
|
+
export declare function useTransformStyle(styleObj: Record<string, any> | undefined, { enableVar, transformRadiusPercent, externalVarContext, parentFontSize, parentWidth, parentHeight }: TransformStyleConfig): {
|
|
43
51
|
hasVarDec: boolean;
|
|
44
52
|
varContextRef: MutableRefObject<{}>;
|
|
45
53
|
setWidth: Dispatch<SetStateAction<number>>;
|
|
@@ -97,12 +105,6 @@ export interface GestureHandler {
|
|
|
97
105
|
current?: unknown;
|
|
98
106
|
}
|
|
99
107
|
export declare function flatGesture(gestures?: Array<GestureHandler>): any[];
|
|
100
|
-
export declare const extendObject: {
|
|
101
|
-
<T extends {}, U>(target: T, source: U): T & U;
|
|
102
|
-
<T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
|
|
103
|
-
<T_2 extends {}, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
|
|
104
|
-
(target: object, ...sources: any[]): any;
|
|
105
|
-
};
|
|
106
108
|
export declare function getCurrentPage(pageId: number | null | undefined): any;
|
|
107
109
|
export declare function renderImage(imageProps: ImageProps | FastImageProps, enableFastImage?: boolean): ReactElement<ImageProps | FastImageProps, string | import("react").JSXElementConstructor<any>>;
|
|
108
110
|
export declare function pickStyle(styleObj: Record<string, any> | undefined, pickedKeys: Array<string>, callback?: (key: string, val: number | string) => number | string): Record<string, any>;
|
|
@@ -120,4 +122,3 @@ export declare function useHover({ enableHover, hoverStartTime, hoverStayTime, d
|
|
|
120
122
|
};
|
|
121
123
|
export declare function useRunOnJSCallback(callbackMapRef: MutableRefObject<Record<string, AnyFunc>>): (key: string, ...args: any) => any;
|
|
122
124
|
export {};
|
|
123
|
-
//# sourceMappingURL=utils.d.ts.map
|