@mpxjs/webpack-plugin 2.10.17-beta.4 → 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/global.d.ts +240 -11
- package/lib/index.js +7 -0
- package/lib/loader.js +4 -0
- package/lib/platform/template/wx/component-config/button.js +1 -1
- package/lib/platform/template/wx/component-config/input.js +1 -1
- package/lib/platform/template/wx/component-config/textarea.js +1 -1
- package/lib/runtime/components/react/dist/animationHooks/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.d.ts +0 -1
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.d.ts +0 -1
- package/lib/runtime/components/react/dist/animationHooks/utils.d.ts +0 -1
- package/lib/runtime/components/react/dist/context.d.ts +0 -1
- 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 +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-inline-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +1 -1
- 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 +4 -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-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 +1 -1
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +43 -23
- 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 +0 -1
- package/lib/runtime/components/react/dist/mpx-view.jsx +20 -6
- 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 +0 -1
- package/lib/runtime/components/react/mpx-input.tsx +1 -1
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +4 -2
- package/lib/runtime/components/react/mpx-swiper.tsx +43 -22
- package/lib/runtime/components/react/mpx-view.tsx +23 -7
- package/lib/runtime/components/react/tsconfig.json +26 -0
- package/lib/style-compiler/strip-conditional-loader.js +45 -29
- package/package.json +5 -4
- package/lib/runtime/components/react/dist/animationHooks/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/animationHooks/utils.d.ts.map +0 -1
- 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-camera.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/useNodesRef.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
|
@@ -14,4 +14,3 @@ export declare const degToRad: (deg: number) => number;
|
|
|
14
14
|
export declare const calcPickerHeight: (faces: Faces[], itemHeight: number) => number;
|
|
15
15
|
export declare const calcHeightOffsets: (itemHeight: number) => number[];
|
|
16
16
|
export declare const createFaces: (itemHeight: number, visibleCount: number) => Faces[];
|
|
17
|
-
//# sourceMappingURL=pickerViewFaces.d.ts.map
|
|
@@ -18,4 +18,3 @@ export interface RadioGroupProps {
|
|
|
18
18
|
}
|
|
19
19
|
declare const radioGroup: import("react").ForwardRefExoticComponent<RadioGroupProps & import("react").RefAttributes<HandlerRef<View, RadioGroupProps>>>;
|
|
20
20
|
export default radioGroup;
|
|
21
|
-
//# sourceMappingURL=mpx-radio-group.d.ts.map
|
|
@@ -52,4 +52,3 @@ declare const _ScrollView: import("react").ForwardRefExoticComponent<ScrollViewP
|
|
|
52
52
|
children?: ReactNode;
|
|
53
53
|
} & import("react-native-gesture-handler").NativeViewGestureHandlerProps & import("react").RefAttributes<import("react").ComponentType<any>>> & import("react-native").ScrollView & View, ScrollViewProps>>>;
|
|
54
54
|
export default _ScrollView;
|
|
55
|
-
//# sourceMappingURL=mpx-scroll-view.d.ts.map
|
|
@@ -15,4 +15,3 @@ interface StickyHeaderProps {
|
|
|
15
15
|
}
|
|
16
16
|
declare const _StickyHeader: import("react").ForwardRefExoticComponent<StickyHeaderProps & import("react").RefAttributes<HandlerRef<View, StickyHeaderProps>>>;
|
|
17
17
|
export default _StickyHeader;
|
|
18
|
-
//# sourceMappingURL=mpx-sticky-header.d.ts.map
|
|
@@ -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
|
|
@@ -56,8 +56,8 @@ interface SwiperProps {
|
|
|
56
56
|
'wait-for'?: Array<GestureHandler>;
|
|
57
57
|
'simultaneous-handlers'?: Array<GestureHandler>;
|
|
58
58
|
disableGesture?: boolean;
|
|
59
|
+
'display-multiple-items'?: number;
|
|
59
60
|
bindchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
60
61
|
}
|
|
61
62
|
declare const SwiperWrapper: React.ForwardRefExoticComponent<SwiperProps & React.RefAttributes<HandlerRef<View, SwiperProps>>>;
|
|
62
63
|
export default SwiperWrapper;
|
|
63
|
-
//# sourceMappingURL=mpx-swiper.d.ts.map
|
|
@@ -72,6 +72,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
72
72
|
marginBottom: dotSpacing,
|
|
73
73
|
zIndex: 98
|
|
74
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
|
// 记录选中元素的索引值
|
|
@@ -168,7 +170,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
168
170
|
const { width, height } = e.nativeEvent.layout;
|
|
169
171
|
const realWidth = dir === 'x' ? width - preMargin - nextMargin : width;
|
|
170
172
|
const realHeight = dir === 'y' ? height - preMargin - nextMargin : height;
|
|
171
|
-
const iStep = dir === 'x' ? realWidth : realHeight;
|
|
173
|
+
const iStep = (dir === 'x' ? realWidth : realHeight) / displayMultipleItems;
|
|
172
174
|
if (iStep !== step.value) {
|
|
173
175
|
step.value = iStep;
|
|
174
176
|
updateCurrent(propCurrent, iStep);
|
|
@@ -224,19 +226,35 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
224
226
|
function renderItems() {
|
|
225
227
|
const intLen = children.length;
|
|
226
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
|
+
// }
|
|
227
242
|
if (circular && intLen > 1) {
|
|
228
|
-
//
|
|
229
|
-
const
|
|
230
|
-
//
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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];
|
|
240
258
|
}
|
|
241
259
|
const arrChildren = renderChild.map((child, index) => {
|
|
242
260
|
const extraStyle = {};
|
|
@@ -271,7 +289,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
271
289
|
let nextIndex = currentIndex.value;
|
|
272
290
|
if (!circularShared.value) {
|
|
273
291
|
// 获取下一个位置的坐标, 循环到最后一个元素,直接停止, 取消定时器
|
|
274
|
-
if (currentIndex.value === childrenLength.value -
|
|
292
|
+
if (currentIndex.value === childrenLength.value - displayMultipleItemsShared.value) {
|
|
275
293
|
pauseLoop();
|
|
276
294
|
return;
|
|
277
295
|
}
|
|
@@ -438,12 +456,13 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
438
456
|
};
|
|
439
457
|
}, [autoplay]);
|
|
440
458
|
useEffect(() => {
|
|
441
|
-
if (circular !== circularShared.value) {
|
|
459
|
+
if (circular !== circularShared.value || patchElmNum !== patchElmNumShared.value || displayMultipleItems !== displayMultipleItemsShared.value) {
|
|
442
460
|
circularShared.value = circular;
|
|
443
|
-
patchElmNumShared.value =
|
|
461
|
+
patchElmNumShared.value = patchElmNum;
|
|
462
|
+
displayMultipleItemsShared.value = displayMultipleItems;
|
|
444
463
|
offset.value = getOffset(currentIndex.value, step.value);
|
|
445
464
|
}
|
|
446
|
-
}, [circular,
|
|
465
|
+
}, [circular, patchElmNum, displayMultipleItems]);
|
|
447
466
|
const { gestureHandler } = useMemo(() => {
|
|
448
467
|
function getTargetPosition(eventData) {
|
|
449
468
|
'worklet';
|
|
@@ -461,7 +480,8 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
461
480
|
const moveToIndex = transdir < 0 ? Math.ceil(computedIndex) : Math.floor(computedIndex);
|
|
462
481
|
// 实际应该定位的索引值
|
|
463
482
|
if (!circularShared.value) {
|
|
464
|
-
|
|
483
|
+
const maxIndex = Math.max(0, childrenLength.value - displayMultipleItemsShared.value);
|
|
484
|
+
selectedIndex = Math.min(Math.max(moveToIndex, 0), maxIndex);
|
|
465
485
|
moveToTargetPos = selectedIndex * step.value;
|
|
466
486
|
}
|
|
467
487
|
else {
|
|
@@ -497,7 +517,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
497
517
|
const gestureMovePos = offset.value + translation;
|
|
498
518
|
if (!circularShared.value) {
|
|
499
519
|
// 如果只判断区间,中间非滑动状态(handleResistanceMove)向左滑动,突然改为向右滑动,但是还在非滑动态,本应该可滑动判断为了不可滑动
|
|
500
|
-
const posEnd = -step.value * (childrenLength.value -
|
|
520
|
+
const posEnd = -step.value * (childrenLength.value - displayMultipleItemsShared.value);
|
|
501
521
|
if (transdir < 0) {
|
|
502
522
|
return gestureMovePos > posEnd;
|
|
503
523
|
}
|
|
@@ -627,7 +647,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
627
647
|
const { translation, transdir } = eventData;
|
|
628
648
|
const moveToOffset = offset.value + translation;
|
|
629
649
|
const maxOverDrag = Math.floor(step.value / 2);
|
|
630
|
-
const maxOffset = translation < 0 ? -(childrenLength.value -
|
|
650
|
+
const maxOffset = translation < 0 ? -(childrenLength.value - displayMultipleItemsShared.value) * step.value : 0;
|
|
631
651
|
let resistance = 0.1;
|
|
632
652
|
let overDrag = 0;
|
|
633
653
|
let finalOffset = 0;
|
|
@@ -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
|
|
@@ -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
|
|
@@ -121,4 +121,3 @@ export declare function useHover({ enableHover, hoverStartTime, hoverStayTime, d
|
|
|
121
121
|
};
|
|
122
122
|
export declare function useRunOnJSCallback(callbackMapRef: MutableRefObject<Record<string, AnyFunc>>): (key: string, ...args: any) => any;
|
|
123
123
|
export {};
|
|
124
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -285,11 +285,11 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
285
285
|
|
|
286
286
|
const setKeyboardAvoidContext = () => {
|
|
287
287
|
if (keyboardAvoid) {
|
|
288
|
-
keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition, holdKeyboard }
|
|
289
288
|
keyboardAvoid.current = {
|
|
290
289
|
cursorSpacing,
|
|
291
290
|
ref: nodeRef,
|
|
292
291
|
adjustPosition,
|
|
292
|
+
holdKeyboard,
|
|
293
293
|
// fix: iOS 会在 onFocus 之前触发 keyboardWillShow 并且赋值 keyboardHeight
|
|
294
294
|
// 这里手动同步下 keyboardHeight,防止 onFocus setKeyboardAvoidContext 删掉 keyboardHeight
|
|
295
295
|
keyboardHeight: keyboardAvoid?.current?.keyboardHeight
|
|
@@ -25,8 +25,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
25
25
|
const isShow = useRef<boolean>(false)
|
|
26
26
|
|
|
27
27
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
28
|
-
// translate/position top
|
|
29
|
-
|
|
28
|
+
// translate/position top+ overflow hidden 在 android 上时因为键盘顶起让页面高度变小,同时元素位置上移
|
|
29
|
+
// 此时最底部的区域是超出了页面高度的,hidden生效就被隐藏掉,因此需要 android 配置聚焦时禁用高度缩小
|
|
30
|
+
// margin-top 因为在 react-native 上和 flex 1 同时存在时,负值只会让容器高度整体变高,不会让元素上移
|
|
31
|
+
transform: [{ translateY: -offset.value }],
|
|
30
32
|
flexBasis: basic.value as DimensionValue
|
|
31
33
|
}))
|
|
32
34
|
|
|
@@ -73,6 +73,7 @@ interface SwiperProps {
|
|
|
73
73
|
'wait-for'?: Array<GestureHandler>
|
|
74
74
|
'simultaneous-handlers'?: Array<GestureHandler>
|
|
75
75
|
disableGesture?: boolean
|
|
76
|
+
'display-multiple-items'?: number
|
|
76
77
|
bindchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void
|
|
77
78
|
}
|
|
78
79
|
|
|
@@ -167,6 +168,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
167
168
|
marginBottom: dotSpacing,
|
|
168
169
|
zIndex: 98
|
|
169
170
|
}
|
|
171
|
+
const displayMultipleItems = props['display-multiple-items'] || 1
|
|
170
172
|
const easeingFunc = props['easing-function'] || 'default'
|
|
171
173
|
const easeDuration = props.duration || 500
|
|
172
174
|
const horizontal = props.vertical !== undefined ? !props.vertical : true
|
|
@@ -200,18 +202,19 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
200
202
|
const preMarginShared = useSharedValue(preMargin)
|
|
201
203
|
const nextMarginShared = useSharedValue(nextMargin)
|
|
202
204
|
const autoplayShared = useSharedValue(autoplay)
|
|
205
|
+
const children = Array.isArray(props.children) ? props.children.filter(child => child) : (props.children ? [props.children] : [])
|
|
203
206
|
// 默认前后补位的元素个数
|
|
204
|
-
const patchElmNum = circular
|
|
207
|
+
const patchElmNum = (circular && children.length > 1) ? displayMultipleItems + 1 : 0
|
|
205
208
|
const patchElmNumShared = useSharedValue(patchElmNum)
|
|
209
|
+
const displayMultipleItemsShared = useSharedValue(displayMultipleItems)
|
|
206
210
|
const circularShared = useSharedValue(circular)
|
|
207
|
-
const children = Array.isArray(props.children) ? props.children.filter(child => child) : (props.children ? [props.children] : [])
|
|
208
211
|
// 对有变化的变量,在worklet中只能使用sharedValue变量,useRef不能更新
|
|
209
212
|
const childrenLength = useSharedValue(children.length)
|
|
210
213
|
const initWidth = typeof normalStyle?.width === 'number' ? normalStyle.width - preMargin - nextMargin : normalStyle.width
|
|
211
214
|
const initHeight = typeof normalStyle?.height === 'number' ? normalStyle.height - preMargin - nextMargin : normalStyle.height
|
|
212
215
|
const dir = horizontal === false ? 'y' : 'x'
|
|
213
216
|
const pstep = dir === 'x' ? initWidth : initHeight
|
|
214
|
-
const initStep: number = isNaN(pstep) ? 0 : pstep
|
|
217
|
+
const initStep: number = isNaN(pstep) ? 0 : pstep / displayMultipleItems
|
|
215
218
|
// 每个元素的宽度 or 高度,有固定值直接初始化无则0
|
|
216
219
|
const step = useSharedValue(initStep)
|
|
217
220
|
// 记录选中元素的索引值
|
|
@@ -285,7 +288,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
285
288
|
const { width, height } = e.nativeEvent.layout
|
|
286
289
|
const realWidth = dir === 'x' ? width - preMargin - nextMargin : width
|
|
287
290
|
const realHeight = dir === 'y' ? height - preMargin - nextMargin : height
|
|
288
|
-
const iStep = dir === 'x' ? realWidth : realHeight
|
|
291
|
+
const iStep = (dir === 'x' ? realWidth : realHeight) / displayMultipleItems
|
|
289
292
|
if (iStep !== step.value) {
|
|
290
293
|
step.value = iStep
|
|
291
294
|
updateCurrent(propCurrent, iStep)
|
|
@@ -344,18 +347,35 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
344
347
|
function renderItems () {
|
|
345
348
|
const intLen = children.length
|
|
346
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
|
+
// }
|
|
347
363
|
if (circular && intLen > 1) {
|
|
348
|
-
//
|
|
349
|
-
const
|
|
350
|
-
//
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
renderChild = [lastChild1, lastChild].concat(renderChild).concat([firstChild, firstChild1])
|
|
356
|
-
} else {
|
|
357
|
-
renderChild = [lastChild].concat(renderChild).concat([firstChild])
|
|
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}` }))
|
|
358
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}` }))
|
|
377
|
+
}
|
|
378
|
+
renderChild = [...frontClones, ...renderChild, ...backClones]
|
|
359
379
|
}
|
|
360
380
|
const arrChildren = renderChild.map((child, index) => {
|
|
361
381
|
const extraStyle = {} as { [key: string]: any }
|
|
@@ -390,7 +410,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
390
410
|
let nextIndex = currentIndex.value
|
|
391
411
|
if (!circularShared.value) {
|
|
392
412
|
// 获取下一个位置的坐标, 循环到最后一个元素,直接停止, 取消定时器
|
|
393
|
-
if (currentIndex.value === childrenLength.value -
|
|
413
|
+
if (currentIndex.value === childrenLength.value - displayMultipleItemsShared.value) {
|
|
394
414
|
pauseLoop()
|
|
395
415
|
return
|
|
396
416
|
}
|
|
@@ -560,14 +580,14 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
560
580
|
}
|
|
561
581
|
}
|
|
562
582
|
}, [autoplay])
|
|
563
|
-
|
|
564
583
|
useEffect(() => {
|
|
565
|
-
if (circular !== circularShared.value) {
|
|
584
|
+
if (circular !== circularShared.value || patchElmNum !== patchElmNumShared.value || displayMultipleItems !== displayMultipleItemsShared.value) {
|
|
566
585
|
circularShared.value = circular
|
|
567
|
-
patchElmNumShared.value =
|
|
586
|
+
patchElmNumShared.value = patchElmNum
|
|
587
|
+
displayMultipleItemsShared.value = displayMultipleItems
|
|
568
588
|
offset.value = getOffset(currentIndex.value, step.value)
|
|
569
589
|
}
|
|
570
|
-
}, [circular,
|
|
590
|
+
}, [circular, patchElmNum, displayMultipleItems])
|
|
571
591
|
const { gestureHandler } = useMemo(() => {
|
|
572
592
|
function getTargetPosition (eventData: EventDataType) {
|
|
573
593
|
'worklet'
|
|
@@ -585,7 +605,8 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
585
605
|
const moveToIndex = transdir < 0 ? Math.ceil(computedIndex) : Math.floor(computedIndex)
|
|
586
606
|
// 实际应该定位的索引值
|
|
587
607
|
if (!circularShared.value) {
|
|
588
|
-
|
|
608
|
+
const maxIndex = Math.max(0, childrenLength.value - displayMultipleItemsShared.value)
|
|
609
|
+
selectedIndex = Math.min(Math.max(moveToIndex, 0), maxIndex)
|
|
589
610
|
moveToTargetPos = selectedIndex * step.value
|
|
590
611
|
} else {
|
|
591
612
|
if (moveToIndex >= childrenLength.value + patchElmNumShared.value) {
|
|
@@ -618,7 +639,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
618
639
|
const gestureMovePos = offset.value + translation
|
|
619
640
|
if (!circularShared.value) {
|
|
620
641
|
// 如果只判断区间,中间非滑动状态(handleResistanceMove)向左滑动,突然改为向右滑动,但是还在非滑动态,本应该可滑动判断为了不可滑动
|
|
621
|
-
const posEnd = -step.value * (childrenLength.value -
|
|
642
|
+
const posEnd = -step.value * (childrenLength.value - displayMultipleItemsShared.value)
|
|
622
643
|
if (transdir < 0) {
|
|
623
644
|
return gestureMovePos > posEnd
|
|
624
645
|
} else {
|
|
@@ -742,7 +763,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
742
763
|
const { translation, transdir } = eventData
|
|
743
764
|
const moveToOffset = offset.value + translation
|
|
744
765
|
const maxOverDrag = Math.floor(step.value / 2)
|
|
745
|
-
const maxOffset = translation < 0 ? -(childrenLength.value -
|
|
766
|
+
const maxOffset = translation < 0 ? -(childrenLength.value - displayMultipleItemsShared.value) * step.value : 0
|
|
746
767
|
let resistance = 0.1
|
|
747
768
|
let overDrag = 0
|
|
748
769
|
let finalOffset = 0
|
|
@@ -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) {
|