@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
|
@@ -11,6 +11,11 @@ import Portal from './mpx-portal'
|
|
|
11
11
|
/**
|
|
12
12
|
* ✔ indicator-dots
|
|
13
13
|
* ✔ indicator-color
|
|
14
|
+
* ✔ indicator-width
|
|
15
|
+
* ✔ indicator-height
|
|
16
|
+
* ✔ indicator-radius
|
|
17
|
+
* ✔ indicator-spacing
|
|
18
|
+
* ✔ indicator-margin
|
|
14
19
|
* ✔ indicator-active-color
|
|
15
20
|
* ✔ autoplay
|
|
16
21
|
* ✔ current
|
|
@@ -46,6 +51,11 @@ interface SwiperProps {
|
|
|
46
51
|
scale?: boolean
|
|
47
52
|
'indicator-dots'?: boolean
|
|
48
53
|
'indicator-color'?: string
|
|
54
|
+
'indicator-width'?: number
|
|
55
|
+
'indicator-height'?: number
|
|
56
|
+
'indicator-spacing'?: number
|
|
57
|
+
'indicator-radius'?: number
|
|
58
|
+
'indicator-margin'?: number
|
|
49
59
|
'indicator-active-color'?: string
|
|
50
60
|
vertical?: boolean
|
|
51
61
|
style: {
|
|
@@ -63,6 +73,7 @@ interface SwiperProps {
|
|
|
63
73
|
'wait-for'?: Array<GestureHandler>
|
|
64
74
|
'simultaneous-handlers'?: Array<GestureHandler>
|
|
65
75
|
disableGesture?: boolean
|
|
76
|
+
'display-multiple-items'?: number
|
|
66
77
|
bindchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void
|
|
67
78
|
}
|
|
68
79
|
|
|
@@ -72,23 +83,23 @@ interface SwiperProps {
|
|
|
72
83
|
const styles: { [key: string]: Object } = {
|
|
73
84
|
pagination_x: {
|
|
74
85
|
position: 'absolute',
|
|
75
|
-
bottom:
|
|
86
|
+
bottom: 0,
|
|
76
87
|
left: 0,
|
|
77
88
|
right: 0,
|
|
78
89
|
flexDirection: 'row',
|
|
79
90
|
flex: 1,
|
|
80
91
|
justifyContent: 'center',
|
|
81
|
-
alignItems: '
|
|
92
|
+
alignItems: 'flex-end'
|
|
82
93
|
},
|
|
83
94
|
pagination_y: {
|
|
84
95
|
position: 'absolute',
|
|
85
|
-
right:
|
|
96
|
+
right: 0,
|
|
86
97
|
top: 0,
|
|
87
98
|
bottom: 0,
|
|
88
99
|
flexDirection: 'column',
|
|
89
100
|
flex: 1,
|
|
90
101
|
justifyContent: 'center',
|
|
91
|
-
alignItems: '
|
|
102
|
+
alignItems: 'flex-end'
|
|
92
103
|
},
|
|
93
104
|
pagerWrapperx: {
|
|
94
105
|
position: 'absolute',
|
|
@@ -109,16 +120,6 @@ const styles: { [key: string]: Object } = {
|
|
|
109
120
|
}
|
|
110
121
|
}
|
|
111
122
|
|
|
112
|
-
const dotCommonStyle = {
|
|
113
|
-
width: 8,
|
|
114
|
-
height: 8,
|
|
115
|
-
borderRadius: 4,
|
|
116
|
-
marginLeft: 3,
|
|
117
|
-
marginRight: 3,
|
|
118
|
-
marginTop: 3,
|
|
119
|
-
marginBottom: 3,
|
|
120
|
-
zIndex: 98
|
|
121
|
-
}
|
|
122
123
|
const activeDotStyle = {
|
|
123
124
|
zIndex: 99
|
|
124
125
|
}
|
|
@@ -136,6 +137,11 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
136
137
|
const {
|
|
137
138
|
'indicator-dots': showPagination,
|
|
138
139
|
'indicator-color': dotColor = 'rgba(0, 0, 0, .3)',
|
|
140
|
+
'indicator-width': dotWidth = 8,
|
|
141
|
+
'indicator-height': dotHeight = 8,
|
|
142
|
+
'indicator-radius': dotRadius = 4,
|
|
143
|
+
'indicator-spacing': dotSpacing = 4,
|
|
144
|
+
'indicator-margin': paginationMargin = 10,
|
|
139
145
|
'indicator-active-color': activeDotColor = '#000000',
|
|
140
146
|
'enable-var': enableVar = false,
|
|
141
147
|
'parent-font-size': parentFontSize,
|
|
@@ -151,6 +157,18 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
151
157
|
current: propCurrent = 0,
|
|
152
158
|
bindchange
|
|
153
159
|
} = props
|
|
160
|
+
|
|
161
|
+
const dotCommonStyle = {
|
|
162
|
+
width: dotWidth,
|
|
163
|
+
height: dotHeight,
|
|
164
|
+
borderRadius: dotRadius,
|
|
165
|
+
marginLeft: dotSpacing,
|
|
166
|
+
marginRight: dotSpacing,
|
|
167
|
+
marginTop: dotSpacing,
|
|
168
|
+
marginBottom: dotSpacing,
|
|
169
|
+
zIndex: 98
|
|
170
|
+
}
|
|
171
|
+
const displayMultipleItems = props['display-multiple-items'] || 1
|
|
154
172
|
const easeingFunc = props['easing-function'] || 'default'
|
|
155
173
|
const easeDuration = props.duration || 500
|
|
156
174
|
const horizontal = props.vertical !== undefined ? !props.vertical : true
|
|
@@ -184,18 +202,19 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
184
202
|
const preMarginShared = useSharedValue(preMargin)
|
|
185
203
|
const nextMarginShared = useSharedValue(nextMargin)
|
|
186
204
|
const autoplayShared = useSharedValue(autoplay)
|
|
205
|
+
const children = Array.isArray(props.children) ? props.children.filter(child => child) : (props.children ? [props.children] : [])
|
|
187
206
|
// 默认前后补位的元素个数
|
|
188
|
-
const patchElmNum = circular
|
|
207
|
+
const patchElmNum = (circular && children.length > 1) ? displayMultipleItems + 1 : 0
|
|
189
208
|
const patchElmNumShared = useSharedValue(patchElmNum)
|
|
209
|
+
const displayMultipleItemsShared = useSharedValue(displayMultipleItems)
|
|
190
210
|
const circularShared = useSharedValue(circular)
|
|
191
|
-
const children = Array.isArray(props.children) ? props.children.filter(child => child) : (props.children ? [props.children] : [])
|
|
192
211
|
// 对有变化的变量,在worklet中只能使用sharedValue变量,useRef不能更新
|
|
193
212
|
const childrenLength = useSharedValue(children.length)
|
|
194
213
|
const initWidth = typeof normalStyle?.width === 'number' ? normalStyle.width - preMargin - nextMargin : normalStyle.width
|
|
195
214
|
const initHeight = typeof normalStyle?.height === 'number' ? normalStyle.height - preMargin - nextMargin : normalStyle.height
|
|
196
215
|
const dir = horizontal === false ? 'y' : 'x'
|
|
197
216
|
const pstep = dir === 'x' ? initWidth : initHeight
|
|
198
|
-
const initStep: number = isNaN(pstep) ? 0 : pstep
|
|
217
|
+
const initStep: number = isNaN(pstep) ? 0 : pstep / displayMultipleItems
|
|
199
218
|
// 每个元素的宽度 or 高度,有固定值直接初始化无则0
|
|
200
219
|
const step = useSharedValue(initStep)
|
|
201
220
|
// 记录选中元素的索引值
|
|
@@ -252,6 +271,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
252
271
|
'style',
|
|
253
272
|
'indicator-dots',
|
|
254
273
|
'indicator-color',
|
|
274
|
+
'indicator-width',
|
|
255
275
|
'indicator-active-color',
|
|
256
276
|
'previous-margin',
|
|
257
277
|
'vertical',
|
|
@@ -268,7 +288,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
268
288
|
const { width, height } = e.nativeEvent.layout
|
|
269
289
|
const realWidth = dir === 'x' ? width - preMargin - nextMargin : width
|
|
270
290
|
const realHeight = dir === 'y' ? height - preMargin - nextMargin : height
|
|
271
|
-
const iStep = dir === 'x' ? realWidth : realHeight
|
|
291
|
+
const iStep = (dir === 'x' ? realWidth : realHeight) / displayMultipleItems
|
|
272
292
|
if (iStep !== step.value) {
|
|
273
293
|
step.value = iStep
|
|
274
294
|
updateCurrent(propCurrent, iStep)
|
|
@@ -294,8 +314,18 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
294
314
|
for (let i = 0; i < children.length; i++) {
|
|
295
315
|
dots.push(<View style={[dotCommonStyle, { backgroundColor: unActionColor }]} key={i}></View>)
|
|
296
316
|
}
|
|
317
|
+
let paginationStyle = styles['pagination_' + dir]
|
|
318
|
+
if (paginationMargin) {
|
|
319
|
+
paginationStyle = {
|
|
320
|
+
...paginationStyle,
|
|
321
|
+
marginBottom: paginationMargin,
|
|
322
|
+
marginLeft: paginationMargin,
|
|
323
|
+
marginRight: paginationMargin,
|
|
324
|
+
marginTop: paginationMargin
|
|
325
|
+
}
|
|
326
|
+
}
|
|
297
327
|
return (
|
|
298
|
-
<View pointerEvents="none" style={
|
|
328
|
+
<View pointerEvents="none" style={paginationStyle} key="pagination">
|
|
299
329
|
<View style={[styles['pagerWrapper' + dir]]}>
|
|
300
330
|
<Animated.View style={[
|
|
301
331
|
dotCommonStyle,
|
|
@@ -317,18 +347,35 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
317
347
|
function renderItems () {
|
|
318
348
|
const intLen = children.length
|
|
319
349
|
let renderChild = children.slice()
|
|
350
|
+
// if (circular && intLen > 1) {
|
|
351
|
+
// // 最前面加最后一个元素
|
|
352
|
+
// const lastChild = React.cloneElement(children[intLen - 1] as ReactElement, { key: 'clone0' })
|
|
353
|
+
// // 最后面加第一个元素
|
|
354
|
+
// const firstChild = React.cloneElement(children[0] as ReactElement, { key: 'clone1' })
|
|
355
|
+
// if (preMargin) {
|
|
356
|
+
// const lastChild1 = React.cloneElement(children[intLen - 2] as ReactElement, { key: 'clone2' })
|
|
357
|
+
// const firstChild1 = React.cloneElement(children[1] as ReactElement, { key: 'clone3' })
|
|
358
|
+
// renderChild = [lastChild1, lastChild].concat(renderChild).concat([firstChild, firstChild1])
|
|
359
|
+
// } else {
|
|
360
|
+
// renderChild = [lastChild].concat(renderChild).concat([firstChild])
|
|
361
|
+
// }
|
|
362
|
+
// }
|
|
320
363
|
if (circular && intLen > 1) {
|
|
321
|
-
//
|
|
322
|
-
const
|
|
323
|
-
//
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
364
|
+
// 动态生成前置补位元素
|
|
365
|
+
const frontClones = []
|
|
366
|
+
// 计算补位序列的起始索引。例如 len=3, patch=2 -> start=1 (即从B开始)
|
|
367
|
+
const startIndex = intLen - (patchElmNum % intLen)
|
|
368
|
+
for (let i = 0; i < patchElmNum; i++) {
|
|
369
|
+
const sourceIndex = (startIndex + i) % intLen
|
|
370
|
+
frontClones.push(React.cloneElement(children[sourceIndex], { key: `clone_front_${i}` }))
|
|
371
|
+
}
|
|
372
|
+
// 动态生成后置补位元素
|
|
373
|
+
const backClones = []
|
|
374
|
+
for (let i = 0; i < patchElmNum; i++) {
|
|
375
|
+
const sourceIndex = i % intLen
|
|
376
|
+
backClones.push(React.cloneElement(children[sourceIndex], { key: `clone_back_${i}` }))
|
|
331
377
|
}
|
|
378
|
+
renderChild = [...frontClones, ...renderChild, ...backClones]
|
|
332
379
|
}
|
|
333
380
|
const arrChildren = renderChild.map((child, index) => {
|
|
334
381
|
const extraStyle = {} as { [key: string]: any }
|
|
@@ -363,7 +410,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
363
410
|
let nextIndex = currentIndex.value
|
|
364
411
|
if (!circularShared.value) {
|
|
365
412
|
// 获取下一个位置的坐标, 循环到最后一个元素,直接停止, 取消定时器
|
|
366
|
-
if (currentIndex.value === childrenLength.value -
|
|
413
|
+
if (currentIndex.value === childrenLength.value - displayMultipleItemsShared.value) {
|
|
367
414
|
pauseLoop()
|
|
368
415
|
return
|
|
369
416
|
}
|
|
@@ -533,14 +580,14 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
533
580
|
}
|
|
534
581
|
}
|
|
535
582
|
}, [autoplay])
|
|
536
|
-
|
|
537
583
|
useEffect(() => {
|
|
538
|
-
if (circular !== circularShared.value) {
|
|
584
|
+
if (circular !== circularShared.value || patchElmNum !== patchElmNumShared.value || displayMultipleItems !== displayMultipleItemsShared.value) {
|
|
539
585
|
circularShared.value = circular
|
|
540
|
-
patchElmNumShared.value =
|
|
586
|
+
patchElmNumShared.value = patchElmNum
|
|
587
|
+
displayMultipleItemsShared.value = displayMultipleItems
|
|
541
588
|
offset.value = getOffset(currentIndex.value, step.value)
|
|
542
589
|
}
|
|
543
|
-
}, [circular,
|
|
590
|
+
}, [circular, patchElmNum, displayMultipleItems])
|
|
544
591
|
const { gestureHandler } = useMemo(() => {
|
|
545
592
|
function getTargetPosition (eventData: EventDataType) {
|
|
546
593
|
'worklet'
|
|
@@ -558,7 +605,8 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
558
605
|
const moveToIndex = transdir < 0 ? Math.ceil(computedIndex) : Math.floor(computedIndex)
|
|
559
606
|
// 实际应该定位的索引值
|
|
560
607
|
if (!circularShared.value) {
|
|
561
|
-
|
|
608
|
+
const maxIndex = Math.max(0, childrenLength.value - displayMultipleItemsShared.value)
|
|
609
|
+
selectedIndex = Math.min(Math.max(moveToIndex, 0), maxIndex)
|
|
562
610
|
moveToTargetPos = selectedIndex * step.value
|
|
563
611
|
} else {
|
|
564
612
|
if (moveToIndex >= childrenLength.value + patchElmNumShared.value) {
|
|
@@ -591,7 +639,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
591
639
|
const gestureMovePos = offset.value + translation
|
|
592
640
|
if (!circularShared.value) {
|
|
593
641
|
// 如果只判断区间,中间非滑动状态(handleResistanceMove)向左滑动,突然改为向右滑动,但是还在非滑动态,本应该可滑动判断为了不可滑动
|
|
594
|
-
const posEnd = -step.value * (childrenLength.value -
|
|
642
|
+
const posEnd = -step.value * (childrenLength.value - displayMultipleItemsShared.value)
|
|
595
643
|
if (transdir < 0) {
|
|
596
644
|
return gestureMovePos > posEnd
|
|
597
645
|
} else {
|
|
@@ -715,7 +763,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
715
763
|
const { translation, transdir } = eventData
|
|
716
764
|
const moveToOffset = offset.value + translation
|
|
717
765
|
const maxOverDrag = Math.floor(step.value / 2)
|
|
718
|
-
const maxOffset = translation < 0 ? -(childrenLength.value -
|
|
766
|
+
const maxOffset = translation < 0 ? -(childrenLength.value - displayMultipleItemsShared.value) * step.value : 0
|
|
719
767
|
let resistance = 0.1
|
|
720
768
|
let overDrag = 0
|
|
721
769
|
let finalOffset = 0
|
|
@@ -861,6 +909,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
861
909
|
style: [normalStyle, layoutStyle, styles.swiper]
|
|
862
910
|
}, layoutProps, innerProps)
|
|
863
911
|
const animateComponent = createElement(Animated.View, {
|
|
912
|
+
key: 'swiperContainer',
|
|
864
913
|
style: [{ flexDirection: dir === 'x' ? 'row' : 'column', width: '100%', height: '100%' }, animatedStyles]
|
|
865
914
|
}, wrapChildren({
|
|
866
915
|
children: arrPages
|
|
@@ -8,8 +8,8 @@ import { View, TextStyle, NativeSyntheticEvent, ViewProps, ImageStyle, StyleShee
|
|
|
8
8
|
import { useRef, useState, useEffect, forwardRef, ReactNode, JSX, createElement } from 'react'
|
|
9
9
|
import useInnerProps from './getInnerListeners'
|
|
10
10
|
import Animated from 'react-native-reanimated'
|
|
11
|
-
import useAnimationHooks from './
|
|
12
|
-
import type { AnimationProp } from './
|
|
11
|
+
import useAnimationHooks, { AnimationType } from './animationHooks/index'
|
|
12
|
+
import type { AnimationProp } from './animationHooks/utils'
|
|
13
13
|
import { ExtendedViewStyle } from './types/common'
|
|
14
14
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
15
15
|
import { parseUrl, PERCENT_REGEX, splitStyle, splitProps, useTransformStyle, wrapChildren, useLayout, renderImage, pickStyle, extendObject, useHover } from './utils'
|
|
@@ -32,7 +32,7 @@ export interface _ViewProps extends ViewProps {
|
|
|
32
32
|
'parent-font-size'?: number
|
|
33
33
|
'parent-width'?: number
|
|
34
34
|
'parent-height'?: number
|
|
35
|
-
'enable-animation'?: boolean
|
|
35
|
+
'enable-animation'?: boolean | AnimationType
|
|
36
36
|
bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void
|
|
37
37
|
bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void
|
|
38
38
|
bindtouchend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void
|
|
@@ -287,7 +287,7 @@ function backgroundSize (imageProps: ImageProps, preImageInfo: PreImageInfo, ima
|
|
|
287
287
|
} else { // 数值类型 ImageStyle
|
|
288
288
|
// 数值类型设置为 stretch
|
|
289
289
|
imageProps.resizeMode = 'stretch'
|
|
290
|
-
if (type === 'linear' && (!layoutWidth || !layoutHeight)) {
|
|
290
|
+
if (type === 'linear' && (!layoutWidth || !layoutHeight) && (isPercent(width) || isPercent(height))) {
|
|
291
291
|
// ios 上 linear 组件只要重新触发渲染,在渲染过程中外层容器 width 或者 height 被设置为 0,通过设置 % 的方式会渲染不出来,即使后面再更新为正常宽高也渲染不出来
|
|
292
292
|
// 所以 hack 手动先将 linear 宽高也设置为 0,后面再更新为正确的数值或 %。
|
|
293
293
|
dimensions = {
|
|
@@ -369,6 +369,17 @@ function normalizeBackgroundPosition (parts: PositionVal[]): backgroundPositionL
|
|
|
369
369
|
let vStart: 'top' | 'bottom' = 'top'
|
|
370
370
|
let vOffset: PositionVal = 0
|
|
371
371
|
|
|
372
|
+
if (!Array.isArray(parts)) {
|
|
373
|
+
// 模板 style 属性传入单个数值时不会和 class 一样转成数组,需要手动转换
|
|
374
|
+
parts = [parts]
|
|
375
|
+
}
|
|
376
|
+
// 模板 style 属性传入时, 需要额外转换处理单位 px/rpx/vh 以及 center 转化为 50%
|
|
377
|
+
parts = (parts as (PositionVal | string)[]).map((part) => {
|
|
378
|
+
if (typeof part !== 'string') return part
|
|
379
|
+
if (part === 'center') return '50%'
|
|
380
|
+
return global.__formatValue(part) as PositionVal
|
|
381
|
+
})
|
|
382
|
+
|
|
372
383
|
if (parts.length === 4) return parts as backgroundPositionList
|
|
373
384
|
|
|
374
385
|
// 归一化
|
|
@@ -514,19 +525,24 @@ function parseBgImage (text: string): {
|
|
|
514
525
|
}
|
|
515
526
|
}
|
|
516
527
|
|
|
517
|
-
function normalizeBackgroundSize (
|
|
528
|
+
function normalizeBackgroundSize (
|
|
529
|
+
backgroundSize: NonNullable<ExtendedViewStyle['backgroundSize']>,
|
|
530
|
+
type: 'image' | 'linear' | undefined
|
|
531
|
+
): DimensionValue[] {
|
|
518
532
|
const sizeList = backgroundSize.slice()
|
|
519
533
|
if (sizeList.length === 1) sizeList.push('auto')
|
|
520
534
|
|
|
521
|
-
|
|
535
|
+
return sizeList.map((val) => {
|
|
536
|
+
if (typeof val !== 'string') return val
|
|
537
|
+
|
|
522
538
|
// 处理当使用渐变的时候,background-size出现cover, contain, auto,当作100%处理
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
sizeList[i] = /^cover|contain|auto$/.test(val as string) ? '100%' : val
|
|
539
|
+
if (type === 'linear' && /^cover|contain|auto$/.test(val)) {
|
|
540
|
+
val = '100%'
|
|
526
541
|
}
|
|
527
|
-
}
|
|
528
542
|
|
|
529
|
-
|
|
543
|
+
// 模板 style 属性传入时, 需要额外转换处理单位 px/rpx/vh
|
|
544
|
+
return global.__formatValue(val) as DimensionValue
|
|
545
|
+
})
|
|
530
546
|
}
|
|
531
547
|
|
|
532
548
|
function preParseImage (imageStyle?: ExtendedViewStyle) {
|
|
@@ -777,7 +793,6 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
|
|
|
777
793
|
ref: nodeRef,
|
|
778
794
|
style: enableStyleAnimation ? [viewStyle, animationStyle] : viewStyle
|
|
779
795
|
}
|
|
780
|
-
|
|
781
796
|
),
|
|
782
797
|
[
|
|
783
798
|
'hover-start-time',
|
|
@@ -234,7 +234,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
|
|
|
234
234
|
}
|
|
235
235
|
break
|
|
236
236
|
case 'postMessage':
|
|
237
|
-
bindmessage && bindmessage(getCustomEvent('
|
|
237
|
+
bindmessage && bindmessage(getCustomEvent('message', {}, { // RN组件销毁顺序与小程序不一致,所以改成和支付宝消息一致
|
|
238
238
|
detail: {
|
|
239
239
|
data: params[0]?.data
|
|
240
240
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// 用于 react 生成
|
|
2
|
+
{
|
|
3
|
+
"include": [
|
|
4
|
+
"./"
|
|
5
|
+
],
|
|
6
|
+
"exclude": [],
|
|
7
|
+
"compilerOptions": {
|
|
8
|
+
"target": "esnext",
|
|
9
|
+
"module": "esnext",
|
|
10
|
+
"outDir": "./dist",
|
|
11
|
+
"rootDir": "./",
|
|
12
|
+
"noImplicitThis": true,
|
|
13
|
+
"noImplicitAny": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"strictNullChecks": true,
|
|
16
|
+
"moduleResolution": "node",
|
|
17
|
+
"declaration": true,
|
|
18
|
+
"allowSyntheticDefaultImports": true,
|
|
19
|
+
"jsx": "preserve",
|
|
20
|
+
"lib": [
|
|
21
|
+
"esnext",
|
|
22
|
+
"dom",
|
|
23
|
+
"dom.iterable"
|
|
24
|
+
],
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useCallback, useMemo, useRef, ReactNode, ReactElement, isValidElement, useContext, useState, Dispatch, SetStateAction, Children, cloneElement, createElement, MutableRefObject } from 'react'
|
|
2
2
|
import { LayoutChangeEvent, TextStyle, ImageProps, 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'
|
|
@@ -238,7 +238,7 @@ function transformVar (styleObj: Record<string, any>, varKeyPaths: Array<Array<s
|
|
|
238
238
|
const resolved = resolveVar(value, varContext)
|
|
239
239
|
if (resolved === undefined) {
|
|
240
240
|
delete target[key]
|
|
241
|
-
error(`Can not resolve css var at ${varKeyPath.join('.')}:${value}.`)
|
|
241
|
+
// error(`Can not resolve css var at ${varKeyPath.join('.')}:${value}.`)
|
|
242
242
|
return
|
|
243
243
|
}
|
|
244
244
|
target[key] = resolved
|
|
@@ -288,6 +288,10 @@ function transformStringify (styleObj: Record<string, any>) {
|
|
|
288
288
|
if (isNumber(styleObj.fontWeight)) {
|
|
289
289
|
styleObj.fontWeight = '' + styleObj.fontWeight
|
|
290
290
|
}
|
|
291
|
+
// transformOrigin 20px 需要转换为 transformOrigin '20'
|
|
292
|
+
if (isNumber(styleObj.transformOrigin)) {
|
|
293
|
+
styleObj.transformOrigin = '' + styleObj.transformOrigin
|
|
294
|
+
}
|
|
291
295
|
}
|
|
292
296
|
|
|
293
297
|
function transformPosition (styleObj: Record<string, any>, meta: PositionMeta) {
|
|
@@ -297,7 +301,7 @@ function transformPosition (styleObj: Record<string, any>, meta: PositionMeta) {
|
|
|
297
301
|
}
|
|
298
302
|
}
|
|
299
303
|
// 多value解析
|
|
300
|
-
function parseValues (str: string, char = ' ') {
|
|
304
|
+
export function parseValues (str: string, char = ' ') {
|
|
301
305
|
let stack = 0
|
|
302
306
|
let temp = ''
|
|
303
307
|
const result = []
|
|
@@ -308,11 +312,11 @@ function parseValues (str: string, char = ' ') {
|
|
|
308
312
|
stack--
|
|
309
313
|
}
|
|
310
314
|
// 非括号内 或者 非分隔字符且非空
|
|
311
|
-
if (stack !== 0 ||
|
|
315
|
+
if (stack !== 0 || str[i] !== char) {
|
|
312
316
|
temp += str[i]
|
|
313
317
|
}
|
|
314
318
|
if ((stack === 0 && str[i] === char) || i === str.length - 1) {
|
|
315
|
-
result.push(temp)
|
|
319
|
+
result.push(temp.trim())
|
|
316
320
|
temp = ''
|
|
317
321
|
}
|
|
318
322
|
}
|
|
@@ -321,6 +325,8 @@ function parseValues (str: string, char = ' ') {
|
|
|
321
325
|
// parse string transform, eg: transform: 'rotateX(45deg) rotateZ(0.785398rad)'
|
|
322
326
|
function parseTransform (transformStr: string) {
|
|
323
327
|
const values = parseValues(transformStr)
|
|
328
|
+
// Todo transform 排序不一致时,transform动画会闪烁,故这里同样的排序输出 transform
|
|
329
|
+
values.sort()
|
|
324
330
|
const transform: { [propName: string]: string | number | number[] }[] = []
|
|
325
331
|
values.forEach(item => {
|
|
326
332
|
const match = item.match(/([/\w]+)\((.+)\)/)
|
|
@@ -384,6 +390,14 @@ function transformBoxShadow (styleObj: Record<string, any>) {
|
|
|
384
390
|
}, '')
|
|
385
391
|
}
|
|
386
392
|
|
|
393
|
+
function transformZIndex (styleObj: Record<string, any>) {
|
|
394
|
+
if (!styleObj.zIndex || typeof styleObj.zIndex === 'number') return
|
|
395
|
+
if (styleObj.zIndex === 'auto') {
|
|
396
|
+
error('Property [z-index] does not supported [auto], please check again!')
|
|
397
|
+
styleObj.zIndex = 0
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
387
401
|
interface TransformStyleConfig {
|
|
388
402
|
enableVar?: boolean
|
|
389
403
|
externalVarContext?: Record<string, any>
|
|
@@ -440,17 +454,20 @@ export function useTransformStyle (styleObj: Record<string, any> = {}, { enableV
|
|
|
440
454
|
}
|
|
441
455
|
}
|
|
442
456
|
|
|
443
|
-
function calcVisitor ({ value, keyPath }: VisitorArg) {
|
|
457
|
+
function calcVisitor ({ key, value, keyPath }: VisitorArg) {
|
|
444
458
|
if (calcUseRegExp.test(value)) {
|
|
459
|
+
// calc translate & border-radius 的百分比计算
|
|
460
|
+
if (hasOwn(selfPercentRule, key) && /%/.test(value)) {
|
|
461
|
+
hasSelfPercent = true
|
|
462
|
+
percentKeyPaths.push(keyPath.slice())
|
|
463
|
+
}
|
|
445
464
|
calcKeyPaths.push(keyPath.slice())
|
|
446
465
|
}
|
|
447
466
|
}
|
|
448
467
|
|
|
449
468
|
function percentVisitor ({ key, value, keyPath }: VisitorArg) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
percentKeyPaths.push(keyPath.slice())
|
|
453
|
-
} else if ((key === 'fontSize' || key === 'lineHeight') && PERCENT_REGEX.test(value)) {
|
|
469
|
+
// fixme 去掉 translate & border-radius 的百分比计算
|
|
470
|
+
if ((key === 'fontSize' || key === 'lineHeight') && PERCENT_REGEX.test(value)) {
|
|
454
471
|
percentKeyPaths.push(keyPath.slice())
|
|
455
472
|
}
|
|
456
473
|
}
|
|
@@ -460,10 +477,10 @@ export function useTransformStyle (styleObj: Record<string, any> = {}, { enableV
|
|
|
460
477
|
[envVisitor, percentVisitor, calcVisitor].forEach(visitor => visitor({ target, key, value, keyPath }))
|
|
461
478
|
}
|
|
462
479
|
}
|
|
463
|
-
|
|
480
|
+
// transform 字符串格式转化数组格式(先转数组再处理css var)
|
|
481
|
+
transformTransform(styleObj)
|
|
464
482
|
// traverse var & generate normalStyle
|
|
465
483
|
traverseStyle(styleObj, [varVisitor])
|
|
466
|
-
|
|
467
484
|
hasVarDec = hasVarDec || !!externalVarContext
|
|
468
485
|
enableVar = enableVar || hasVarDec || hasVarUse
|
|
469
486
|
const enableVarRef = useRef(enableVar)
|
|
@@ -527,10 +544,11 @@ export function useTransformStyle (styleObj: Record<string, any> = {}, { enableV
|
|
|
527
544
|
transformStringify(normalStyle)
|
|
528
545
|
// transform rpx to px
|
|
529
546
|
transformBoxShadow(normalStyle)
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
547
|
+
// transform z-index auto to 0
|
|
548
|
+
transformZIndex(normalStyle)
|
|
549
|
+
if (Array.isArray(normalStyle.transform)) {
|
|
550
|
+
normalStyle.transform = normalStyle.transform.filter(item => !isEmptyObject(item))
|
|
551
|
+
}
|
|
534
552
|
return {
|
|
535
553
|
hasVarDec,
|
|
536
554
|
varContextRef,
|
|
@@ -2,6 +2,7 @@ import { hasOwn, isEmptyObject, extend } from './utils'
|
|
|
2
2
|
import { isBrowser } from './env'
|
|
3
3
|
import transRpxStyle from './transRpxStyle'
|
|
4
4
|
import animation from './animation'
|
|
5
|
+
import { error } from '@mpxjs/utils'
|
|
5
6
|
const dash2hump = require('../utils/hump-dash').dash2hump
|
|
6
7
|
|
|
7
8
|
export function processComponentOption (
|
|
@@ -107,6 +108,10 @@ registered in parent context!`)
|
|
|
107
108
|
|
|
108
109
|
export function getComponent (component, extendOptions) {
|
|
109
110
|
component = component.__esModule ? component.default : component
|
|
111
|
+
if (!component) {
|
|
112
|
+
error('getComponent() expected component options as the first argument, but got undefined.')
|
|
113
|
+
return null
|
|
114
|
+
}
|
|
110
115
|
// eslint-disable-next-line
|
|
111
116
|
if (extendOptions && !component.__mpxExtended) {
|
|
112
117
|
extend(component, extendOptions, { __mpxExtended: true })
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import AsyncSuspense from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-async-suspense'
|
|
2
2
|
import { memo, forwardRef, createElement } from 'react'
|
|
3
|
+
import { error } from '@mpxjs/utils'
|
|
3
4
|
import { extend } from './utils'
|
|
4
5
|
|
|
5
6
|
export function getComponent (component, extendOptions) {
|
|
6
7
|
component = component.__esModule ? component.default : component
|
|
8
|
+
if (!component) {
|
|
9
|
+
error(
|
|
10
|
+
`getComponent expecting function/class component ${extendOptions?.displayName ? `[${extendOptions.displayName}] ` : ''}as the first argument, but got undefined.`
|
|
11
|
+
)
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
7
14
|
// eslint-disable-next-line
|
|
8
15
|
if (extendOptions && !component.__mpxExtended) {
|
|
9
16
|
extend(component, extendOptions, { __mpxExtended: true })
|
|
@@ -45,7 +45,7 @@ function objectKeys (obj) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
function genRegExp (str, flags) {
|
|
48
|
-
if (!__mpx_wxs__) {
|
|
48
|
+
if (!__mpx_wxs__ || __mpx_mode__ === 'ks') {
|
|
49
49
|
return new RegExp(str, flags)
|
|
50
50
|
} else {
|
|
51
51
|
return getRegExp(str, flags)
|
|
@@ -234,4 +234,4 @@ module.exports = {
|
|
|
234
234
|
var parsedStaticStyle = typeof staticStyle === 'string' ? parseStyleText(staticStyle) : {}
|
|
235
235
|
return genStyleText(extend(parsedStaticStyle, normalizedDynamicStyle))
|
|
236
236
|
}
|
|
237
|
-
}
|
|
237
|
+
}
|