@mpxjs/webpack-plugin 2.10.17-beta.3 → 2.10.17-beta.6
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 +245 -0
- package/lib/index.js +29 -2
- 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 +57 -33
- 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 +25 -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 +11 -1
- 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 +20 -3
- package/lib/platform/template/wx/component-config/unsupported.js +10 -1
- 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/style-helper.js +76 -13
- package/lib/resolver/AddModePlugin.js +23 -8
- package/lib/runtime/components/react/animationHooks/index.ts +75 -0
- package/lib/runtime/components/react/animationHooks/useAnimationAPIHooks.ts +198 -0
- package/lib/runtime/components/react/animationHooks/useTransitionHooks.ts +297 -0
- package/lib/runtime/components/react/animationHooks/utils.ts +196 -0
- package/lib/runtime/components/react/context.ts +7 -1
- 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 +182 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.d.ts +3 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.js +274 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.d.ts +109 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.js +150 -0
- package/lib/runtime/components/react/dist/context.d.ts +6 -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-button.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +31 -0
- package/lib/runtime/components/react/dist/mpx-camera.jsx +236 -0
- 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-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 +10 -9
- 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 +7 -2
- 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-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-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 +11 -1
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +71 -39
- 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-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/mpx-web-view.jsx +1 -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 +1 -1
- package/lib/runtime/components/react/dist/utils.jsx +34 -13
- package/lib/runtime/components/react/mpx-camera.tsx +327 -0
- package/lib/runtime/components/react/mpx-input.tsx +15 -9
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +7 -2
- package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +2 -2
- package/lib/runtime/components/react/mpx-swiper.tsx +86 -37
- package/lib/runtime/components/react/mpx-view.tsx +27 -12
- package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
- 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 +34 -16
- package/lib/runtime/optionProcessor.js +5 -0
- package/lib/runtime/optionProcessorReact.js +7 -0
- package/lib/runtime/stringify.wxs +2 -2
- package/lib/style-compiler/strip-conditional-loader/rebaseUrl.js +225 -0
- package/lib/style-compiler/strip-conditional-loader.js +76 -185
- package/lib/template-compiler/compiler.js +1 -3
- package/lib/utils/dom-tag-config.js +1 -1
- package/lib/utils/string.js +25 -1
- package/package.json +6 -4
- 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
|
@@ -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,18 @@ 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
|
+
const displayMultipleItems = props['display-multiple-items'] || 1;
|
|
75
76
|
const easeingFunc = props['easing-function'] || 'default';
|
|
76
77
|
const easeDuration = props.duration || 500;
|
|
77
78
|
const horizontal = props.vertical !== undefined ? !props.vertical : true;
|
|
@@ -97,18 +98,19 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
97
98
|
const preMarginShared = useSharedValue(preMargin);
|
|
98
99
|
const nextMarginShared = useSharedValue(nextMargin);
|
|
99
100
|
const autoplayShared = useSharedValue(autoplay);
|
|
101
|
+
const children = Array.isArray(props.children) ? props.children.filter(child => child) : (props.children ? [props.children] : []);
|
|
100
102
|
// 默认前后补位的元素个数
|
|
101
|
-
const patchElmNum = circular
|
|
103
|
+
const patchElmNum = (circular && children.length > 1) ? displayMultipleItems + 1 : 0;
|
|
102
104
|
const patchElmNumShared = useSharedValue(patchElmNum);
|
|
105
|
+
const displayMultipleItemsShared = useSharedValue(displayMultipleItems);
|
|
103
106
|
const circularShared = useSharedValue(circular);
|
|
104
|
-
const children = Array.isArray(props.children) ? props.children.filter(child => child) : (props.children ? [props.children] : []);
|
|
105
107
|
// 对有变化的变量,在worklet中只能使用sharedValue变量,useRef不能更新
|
|
106
108
|
const childrenLength = useSharedValue(children.length);
|
|
107
109
|
const initWidth = typeof normalStyle?.width === 'number' ? normalStyle.width - preMargin - nextMargin : normalStyle.width;
|
|
108
110
|
const initHeight = typeof normalStyle?.height === 'number' ? normalStyle.height - preMargin - nextMargin : normalStyle.height;
|
|
109
111
|
const dir = horizontal === false ? 'y' : 'x';
|
|
110
112
|
const pstep = dir === 'x' ? initWidth : initHeight;
|
|
111
|
-
const initStep = isNaN(pstep) ? 0 : pstep;
|
|
113
|
+
const initStep = isNaN(pstep) ? 0 : pstep / displayMultipleItems;
|
|
112
114
|
// 每个元素的宽度 or 高度,有固定值直接初始化无则0
|
|
113
115
|
const step = useSharedValue(initStep);
|
|
114
116
|
// 记录选中元素的索引值
|
|
@@ -152,6 +154,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
152
154
|
'style',
|
|
153
155
|
'indicator-dots',
|
|
154
156
|
'indicator-color',
|
|
157
|
+
'indicator-width',
|
|
155
158
|
'indicator-active-color',
|
|
156
159
|
'previous-margin',
|
|
157
160
|
'vertical',
|
|
@@ -167,7 +170,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
167
170
|
const { width, height } = e.nativeEvent.layout;
|
|
168
171
|
const realWidth = dir === 'x' ? width - preMargin - nextMargin : width;
|
|
169
172
|
const realHeight = dir === 'y' ? height - preMargin - nextMargin : height;
|
|
170
|
-
const iStep = dir === 'x' ? realWidth : realHeight;
|
|
173
|
+
const iStep = (dir === 'x' ? realWidth : realHeight) / displayMultipleItems;
|
|
171
174
|
if (iStep !== step.value) {
|
|
172
175
|
step.value = iStep;
|
|
173
176
|
updateCurrent(propCurrent, iStep);
|
|
@@ -193,7 +196,17 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
193
196
|
for (let i = 0; i < children.length; i++) {
|
|
194
197
|
dots.push(<View style={[dotCommonStyle, { backgroundColor: unActionColor }]} key={i}></View>);
|
|
195
198
|
}
|
|
196
|
-
|
|
199
|
+
let paginationStyle = styles['pagination_' + dir];
|
|
200
|
+
if (paginationMargin) {
|
|
201
|
+
paginationStyle = {
|
|
202
|
+
...paginationStyle,
|
|
203
|
+
marginBottom: paginationMargin,
|
|
204
|
+
marginLeft: paginationMargin,
|
|
205
|
+
marginRight: paginationMargin,
|
|
206
|
+
marginTop: paginationMargin
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
return (<View pointerEvents="none" style={paginationStyle} key="pagination">
|
|
197
210
|
<View style={[styles['pagerWrapper' + dir]]}>
|
|
198
211
|
<Animated.View style={[
|
|
199
212
|
dotCommonStyle,
|
|
@@ -213,19 +226,35 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
213
226
|
function renderItems() {
|
|
214
227
|
const intLen = children.length;
|
|
215
228
|
let renderChild = children.slice();
|
|
229
|
+
// if (circular && intLen > 1) {
|
|
230
|
+
// // 最前面加最后一个元素
|
|
231
|
+
// const lastChild = React.cloneElement(children[intLen - 1] as ReactElement, { key: 'clone0' })
|
|
232
|
+
// // 最后面加第一个元素
|
|
233
|
+
// const firstChild = React.cloneElement(children[0] as ReactElement, { key: 'clone1' })
|
|
234
|
+
// if (preMargin) {
|
|
235
|
+
// const lastChild1 = React.cloneElement(children[intLen - 2] as ReactElement, { key: 'clone2' })
|
|
236
|
+
// const firstChild1 = React.cloneElement(children[1] as ReactElement, { key: 'clone3' })
|
|
237
|
+
// renderChild = [lastChild1, lastChild].concat(renderChild).concat([firstChild, firstChild1])
|
|
238
|
+
// } else {
|
|
239
|
+
// renderChild = [lastChild].concat(renderChild).concat([firstChild])
|
|
240
|
+
// }
|
|
241
|
+
// }
|
|
216
242
|
if (circular && intLen > 1) {
|
|
217
|
-
//
|
|
218
|
-
const
|
|
219
|
-
//
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
243
|
+
// 动态生成前置补位元素
|
|
244
|
+
const frontClones = [];
|
|
245
|
+
// 计算补位序列的起始索引。例如 len=3, patch=2 -> start=1 (即从B开始)
|
|
246
|
+
const startIndex = intLen - (patchElmNum % intLen);
|
|
247
|
+
for (let i = 0; i < patchElmNum; i++) {
|
|
248
|
+
const sourceIndex = (startIndex + i) % intLen;
|
|
249
|
+
frontClones.push(React.cloneElement(children[sourceIndex], { key: `clone_front_${i}` }));
|
|
250
|
+
}
|
|
251
|
+
// 动态生成后置补位元素
|
|
252
|
+
const backClones = [];
|
|
253
|
+
for (let i = 0; i < patchElmNum; i++) {
|
|
254
|
+
const sourceIndex = i % intLen;
|
|
255
|
+
backClones.push(React.cloneElement(children[sourceIndex], { key: `clone_back_${i}` }));
|
|
256
|
+
}
|
|
257
|
+
renderChild = [...frontClones, ...renderChild, ...backClones];
|
|
229
258
|
}
|
|
230
259
|
const arrChildren = renderChild.map((child, index) => {
|
|
231
260
|
const extraStyle = {};
|
|
@@ -260,7 +289,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
260
289
|
let nextIndex = currentIndex.value;
|
|
261
290
|
if (!circularShared.value) {
|
|
262
291
|
// 获取下一个位置的坐标, 循环到最后一个元素,直接停止, 取消定时器
|
|
263
|
-
if (currentIndex.value === childrenLength.value -
|
|
292
|
+
if (currentIndex.value === childrenLength.value - displayMultipleItemsShared.value) {
|
|
264
293
|
pauseLoop();
|
|
265
294
|
return;
|
|
266
295
|
}
|
|
@@ -427,12 +456,13 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
427
456
|
};
|
|
428
457
|
}, [autoplay]);
|
|
429
458
|
useEffect(() => {
|
|
430
|
-
if (circular !== circularShared.value) {
|
|
459
|
+
if (circular !== circularShared.value || patchElmNum !== patchElmNumShared.value || displayMultipleItems !== displayMultipleItemsShared.value) {
|
|
431
460
|
circularShared.value = circular;
|
|
432
|
-
patchElmNumShared.value =
|
|
461
|
+
patchElmNumShared.value = patchElmNum;
|
|
462
|
+
displayMultipleItemsShared.value = displayMultipleItems;
|
|
433
463
|
offset.value = getOffset(currentIndex.value, step.value);
|
|
434
464
|
}
|
|
435
|
-
}, [circular,
|
|
465
|
+
}, [circular, patchElmNum, displayMultipleItems]);
|
|
436
466
|
const { gestureHandler } = useMemo(() => {
|
|
437
467
|
function getTargetPosition(eventData) {
|
|
438
468
|
'worklet';
|
|
@@ -450,7 +480,8 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
450
480
|
const moveToIndex = transdir < 0 ? Math.ceil(computedIndex) : Math.floor(computedIndex);
|
|
451
481
|
// 实际应该定位的索引值
|
|
452
482
|
if (!circularShared.value) {
|
|
453
|
-
|
|
483
|
+
const maxIndex = Math.max(0, childrenLength.value - displayMultipleItemsShared.value);
|
|
484
|
+
selectedIndex = Math.min(Math.max(moveToIndex, 0), maxIndex);
|
|
454
485
|
moveToTargetPos = selectedIndex * step.value;
|
|
455
486
|
}
|
|
456
487
|
else {
|
|
@@ -486,7 +517,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
486
517
|
const gestureMovePos = offset.value + translation;
|
|
487
518
|
if (!circularShared.value) {
|
|
488
519
|
// 如果只判断区间,中间非滑动状态(handleResistanceMove)向左滑动,突然改为向右滑动,但是还在非滑动态,本应该可滑动判断为了不可滑动
|
|
489
|
-
const posEnd = -step.value * (childrenLength.value -
|
|
520
|
+
const posEnd = -step.value * (childrenLength.value - displayMultipleItemsShared.value);
|
|
490
521
|
if (transdir < 0) {
|
|
491
522
|
return gestureMovePos > posEnd;
|
|
492
523
|
}
|
|
@@ -616,7 +647,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
616
647
|
const { translation, transdir } = eventData;
|
|
617
648
|
const moveToOffset = offset.value + translation;
|
|
618
649
|
const maxOverDrag = Math.floor(step.value / 2);
|
|
619
|
-
const maxOffset = translation < 0 ? -(childrenLength.value -
|
|
650
|
+
const maxOffset = translation < 0 ? -(childrenLength.value - displayMultipleItemsShared.value) * step.value : 0;
|
|
620
651
|
let resistance = 0.1;
|
|
621
652
|
let overDrag = 0;
|
|
622
653
|
let finalOffset = 0;
|
|
@@ -770,6 +801,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
770
801
|
style: [normalStyle, layoutStyle, styles.swiper]
|
|
771
802
|
}, layoutProps, innerProps);
|
|
772
803
|
const animateComponent = createElement(Animated.View, {
|
|
804
|
+
key: 'swiperContainer',
|
|
773
805
|
style: [{ flexDirection: dir === 'x' ? 'row' : 'column', width: '100%', height: '100%' }, animatedStyles]
|
|
774
806
|
}, wrapChildren({
|
|
775
807
|
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
|
|
@@ -184,7 +184,7 @@ const _WebView = forwardRef((props, ref) => {
|
|
|
184
184
|
}
|
|
185
185
|
break;
|
|
186
186
|
case 'postMessage':
|
|
187
|
-
bindmessage && bindmessage(getCustomEvent('
|
|
187
|
+
bindmessage && bindmessage(getCustomEvent('message', {}, {
|
|
188
188
|
detail: {
|
|
189
189
|
data: params[0]?.data
|
|
190
190
|
}
|
|
@@ -32,6 +32,7 @@ export declare function splitStyle<T extends Record<string, any>>(styleObj: T):
|
|
|
32
32
|
backgroundStyle?: Partial<T>;
|
|
33
33
|
innerStyle?: Partial<T>;
|
|
34
34
|
};
|
|
35
|
+
export declare function parseValues(str: string, char?: string): string[];
|
|
35
36
|
interface TransformStyleConfig {
|
|
36
37
|
enableVar?: boolean;
|
|
37
38
|
externalVarContext?: Record<string, any>;
|
|
@@ -120,4 +121,3 @@ export declare function useHover({ enableHover, hoverStartTime, hoverStayTime, d
|
|
|
120
121
|
};
|
|
121
122
|
export declare function useRunOnJSCallback(callbackMapRef: MutableRefObject<Record<string, AnyFunc>>): (key: string, ...args: any) => any;
|
|
122
123
|
export {};
|
|
123
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useCallback, useMemo, useRef, isValidElement, useContext, useState, Children, cloneElement, createElement } from 'react';
|
|
2
2
|
import { Image } from 'react-native';
|
|
3
|
-
import { isObject, isFunction, isNumber, hasOwn, diffAndCloneA, error, warn } from '@mpxjs/utils';
|
|
3
|
+
import { isObject, isFunction, isNumber, hasOwn, diffAndCloneA, error, warn, isEmptyObject } from '@mpxjs/utils';
|
|
4
4
|
import { VarContext, ScrollViewContext, RouteContext } from './context';
|
|
5
5
|
import { ExpressionParser, parseFunc, ReplaceSource } from './parser';
|
|
6
6
|
import { initialWindowMetrics } from 'react-native-safe-area-context';
|
|
@@ -193,7 +193,7 @@ function transformVar(styleObj, varKeyPaths, varContext, visitOther) {
|
|
|
193
193
|
const resolved = resolveVar(value, varContext);
|
|
194
194
|
if (resolved === undefined) {
|
|
195
195
|
delete target[key];
|
|
196
|
-
error(`Can not resolve css var at ${varKeyPath.join('.')}:${value}.`)
|
|
196
|
+
// error(`Can not resolve css var at ${varKeyPath.join('.')}:${value}.`)
|
|
197
197
|
return;
|
|
198
198
|
}
|
|
199
199
|
target[key] = resolved;
|
|
@@ -241,6 +241,10 @@ function transformStringify(styleObj) {
|
|
|
241
241
|
if (isNumber(styleObj.fontWeight)) {
|
|
242
242
|
styleObj.fontWeight = '' + styleObj.fontWeight;
|
|
243
243
|
}
|
|
244
|
+
// transformOrigin 20px 需要转换为 transformOrigin '20'
|
|
245
|
+
if (isNumber(styleObj.transformOrigin)) {
|
|
246
|
+
styleObj.transformOrigin = '' + styleObj.transformOrigin;
|
|
247
|
+
}
|
|
244
248
|
}
|
|
245
249
|
function transformPosition(styleObj, meta) {
|
|
246
250
|
if (styleObj.position === 'fixed') {
|
|
@@ -249,7 +253,7 @@ function transformPosition(styleObj, meta) {
|
|
|
249
253
|
}
|
|
250
254
|
}
|
|
251
255
|
// 多value解析
|
|
252
|
-
function parseValues(str, char = ' ') {
|
|
256
|
+
export function parseValues(str, char = ' ') {
|
|
253
257
|
let stack = 0;
|
|
254
258
|
let temp = '';
|
|
255
259
|
const result = [];
|
|
@@ -261,11 +265,11 @@ function parseValues(str, char = ' ') {
|
|
|
261
265
|
stack--;
|
|
262
266
|
}
|
|
263
267
|
// 非括号内 或者 非分隔字符且非空
|
|
264
|
-
if (stack !== 0 ||
|
|
268
|
+
if (stack !== 0 || str[i] !== char) {
|
|
265
269
|
temp += str[i];
|
|
266
270
|
}
|
|
267
271
|
if ((stack === 0 && str[i] === char) || i === str.length - 1) {
|
|
268
|
-
result.push(temp);
|
|
272
|
+
result.push(temp.trim());
|
|
269
273
|
temp = '';
|
|
270
274
|
}
|
|
271
275
|
}
|
|
@@ -274,6 +278,8 @@ function parseValues(str, char = ' ') {
|
|
|
274
278
|
// parse string transform, eg: transform: 'rotateX(45deg) rotateZ(0.785398rad)'
|
|
275
279
|
function parseTransform(transformStr) {
|
|
276
280
|
const values = parseValues(transformStr);
|
|
281
|
+
// Todo transform 排序不一致时,transform动画会闪烁,故这里同样的排序输出 transform
|
|
282
|
+
values.sort();
|
|
277
283
|
const transform = [];
|
|
278
284
|
values.forEach(item => {
|
|
279
285
|
const match = item.match(/([/\w]+)\((.+)\)/);
|
|
@@ -337,6 +343,14 @@ function transformBoxShadow(styleObj) {
|
|
|
337
343
|
return `${res}${idx === 0 ? '' : ' '}${global.__formatValue(i)}`;
|
|
338
344
|
}, '');
|
|
339
345
|
}
|
|
346
|
+
function transformZIndex(styleObj) {
|
|
347
|
+
if (!styleObj.zIndex || typeof styleObj.zIndex === 'number')
|
|
348
|
+
return;
|
|
349
|
+
if (styleObj.zIndex === 'auto') {
|
|
350
|
+
error('Property [z-index] does not supported [auto], please check again!');
|
|
351
|
+
styleObj.zIndex = 0;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
340
354
|
export function useTransformStyle(styleObj = {}, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight }) {
|
|
341
355
|
const varStyle = {};
|
|
342
356
|
const unoVarStyle = {};
|
|
@@ -386,17 +400,19 @@ export function useTransformStyle(styleObj = {}, { enableVar, externalVarContext
|
|
|
386
400
|
envKeyPaths.push(keyPath.slice());
|
|
387
401
|
}
|
|
388
402
|
}
|
|
389
|
-
function calcVisitor({ value, keyPath }) {
|
|
403
|
+
function calcVisitor({ key, value, keyPath }) {
|
|
390
404
|
if (calcUseRegExp.test(value)) {
|
|
405
|
+
// calc translate & border-radius 的百分比计算
|
|
406
|
+
if (hasOwn(selfPercentRule, key) && /%/.test(value)) {
|
|
407
|
+
hasSelfPercent = true;
|
|
408
|
+
percentKeyPaths.push(keyPath.slice());
|
|
409
|
+
}
|
|
391
410
|
calcKeyPaths.push(keyPath.slice());
|
|
392
411
|
}
|
|
393
412
|
}
|
|
394
413
|
function percentVisitor({ key, value, keyPath }) {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
percentKeyPaths.push(keyPath.slice());
|
|
398
|
-
}
|
|
399
|
-
else if ((key === 'fontSize' || key === 'lineHeight') && PERCENT_REGEX.test(value)) {
|
|
414
|
+
// fixme 去掉 translate & border-radius 的百分比计算
|
|
415
|
+
if ((key === 'fontSize' || key === 'lineHeight') && PERCENT_REGEX.test(value)) {
|
|
400
416
|
percentKeyPaths.push(keyPath.slice());
|
|
401
417
|
}
|
|
402
418
|
}
|
|
@@ -405,6 +421,8 @@ export function useTransformStyle(styleObj = {}, { enableVar, externalVarContext
|
|
|
405
421
|
[envVisitor, percentVisitor, calcVisitor].forEach(visitor => visitor({ target, key, value, keyPath }));
|
|
406
422
|
}
|
|
407
423
|
}
|
|
424
|
+
// transform 字符串格式转化数组格式(先转数组再处理css var)
|
|
425
|
+
transformTransform(styleObj);
|
|
408
426
|
// traverse var & generate normalStyle
|
|
409
427
|
traverseStyle(styleObj, [varVisitor]);
|
|
410
428
|
hasVarDec = hasVarDec || !!externalVarContext;
|
|
@@ -467,8 +485,11 @@ export function useTransformStyle(styleObj = {}, { enableVar, externalVarContext
|
|
|
467
485
|
transformStringify(normalStyle);
|
|
468
486
|
// transform rpx to px
|
|
469
487
|
transformBoxShadow(normalStyle);
|
|
470
|
-
// transform
|
|
471
|
-
|
|
488
|
+
// transform z-index auto to 0
|
|
489
|
+
transformZIndex(normalStyle);
|
|
490
|
+
if (Array.isArray(normalStyle.transform)) {
|
|
491
|
+
normalStyle.transform = normalStyle.transform.filter(item => !isEmptyObject(item));
|
|
492
|
+
}
|
|
472
493
|
return {
|
|
473
494
|
hasVarDec,
|
|
474
495
|
varContextRef,
|