@nutui/nutui-react-taro 2.0.0-alpha.7 → 2.0.0-alpha.9
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/CHANGELOG.md +26 -0
- package/dist/esm/Address.js +2 -2
- package/dist/esm/Audio.js +7 -6
- package/dist/esm/Card.js +5 -5
- package/dist/esm/Cascader.js +2 -2
- package/dist/esm/DatePicker.js +2 -3
- package/dist/esm/Elevator.js +1 -1
- package/dist/esm/ImagePreview.js +4 -7
- package/dist/esm/Indicator.js +1 -1
- package/dist/esm/InputNumber.js +1 -1
- package/dist/esm/Notify.js +2 -3
- package/dist/esm/NumberKeyboard.js +3 -5
- package/dist/esm/Picker.js +1 -2
- package/dist/esm/Price.js +2 -3
- package/dist/esm/PullToRefresh.js +4 -6
- package/dist/esm/Radio.js +3 -3
- package/dist/esm/RadioGroup.js +3 -3
- package/dist/esm/Range/style/index.js +1 -1
- package/dist/esm/Range.js +5 -7
- package/dist/esm/Sticky.js +1 -2
- package/dist/esm/Swiper.js +3 -5
- package/dist/esm/SwiperItem.js +1 -5
- package/dist/esm/Tabs.js +1 -1
- package/dist/esm/{address.taro-1c534feb.js → address.taro-1a8ab3f1.js} +1 -1
- package/dist/esm/{audio.taro-ec96ef80.js → audio.taro-bbd39f93.js} +2 -2
- package/dist/esm/{card.taro-a46fdf25.js → card.taro-2080f4d2.js} +1 -1
- package/dist/esm/{cascader.taro-0a2694ed.js → cascader.taro-fb7a0230.js} +21 -13
- package/dist/esm/{datepicker.taro-3f718964.js → datepicker.taro-65dbeceb.js} +1 -1
- package/dist/esm/{elevator.taro-bc162e4f.js → elevator.taro-df8fde9d.js} +20 -15
- package/dist/esm/{imagepreview.taro-8832dc01.js → imagepreview.taro-2508d412.js} +8 -5
- package/dist/esm/{indicator.taro-f2bd212f.js → indicator.taro-edbc71df.js} +3 -3
- package/dist/esm/{inputnumber.taro-877dc947.js → inputnumber.taro-6657d2c1.js} +1 -1
- package/dist/esm/{notify.taro-6b6eb6bf.js → notify.taro-5768403d.js} +11 -18
- package/dist/esm/numberkeyboard.taro-ad8afaf9.js +136 -0
- package/dist/esm/nutui-react.es.js +20 -25
- package/dist/esm/{picker.taro-a5603921.js → picker.taro-0570ec32.js} +14 -1
- package/dist/esm/{price.taro-c4f45310.js → price.taro-479f1b82.js} +17 -17
- package/dist/esm/pulltorefresh.taro-6afe4805.js +138 -0
- package/dist/esm/radio.taro-5d6ca4ad.js +153 -0
- package/dist/esm/range.taro-615e193a.js +259 -0
- package/dist/esm/{sticky.taro-3c03eb0a.js → sticky.taro-f8ae8d5e.js} +21 -1
- package/dist/esm/swiper.taro-53a36427.js +83 -0
- package/dist/esm/swiperitem.taro-ef7342e8.js +14 -0
- package/dist/esm/{tabs.taro-b75f20ff.js → tabs.taro-66164782.js} +8 -1
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/id-ID.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/locales/zh-UG.js +1 -1
- package/dist/nutui.react.mjs +1634 -6666
- package/dist/nutui.react.umd.js +2047 -7095
- package/dist/packages/imagepreview/imagepreview.scss +5 -0
- package/dist/packages/notify/notify.scss +1 -1
- package/dist/packages/numberkeyboard/numberkeyboard.scss +29 -77
- package/dist/packages/price/price.scss +8 -0
- package/dist/packages/pulltorefresh/pulltorefresh.scss +0 -8
- package/dist/packages/radio/radio.scss +13 -32
- package/dist/packages/radiogroup/radiogroup.scss +17 -51
- package/dist/packages/range/range.scss +24 -49
- package/dist/packages/swiper/swiper.scss +0 -15
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/variables-jmapp.scss +61 -61
- package/dist/styles/variables.scss +61 -60
- package/dist/types/index.d.ts +83 -118
- package/package.json +1 -1
- package/dist/esm/UserContext-735db09f.js +0 -5
- package/dist/esm/get-scroll-parent-8da04f2e.js +0 -24
- package/dist/esm/numberkeyboard.taro-0a0e866a.js +0 -183
- package/dist/esm/pulltorefresh.taro-c611fd92.js +0 -179
- package/dist/esm/radio.taro-3a54f4c8.js +0 -152
- package/dist/esm/range.taro-52cda918.js +0 -325
- package/dist/esm/supports-passive-aaaf0eff.js +0 -17
- package/dist/esm/swiper.taro-74cf9306.js +0 -430
- package/dist/esm/swiperitem-80df464a.js +0 -29
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState, useMemo, useEffect } from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
import { nextTick, useReady, createSelectorQuery } from "@tarojs/taro";
|
|
4
|
-
import { D as DataContext } from "./UserContext-735db09f.js";
|
|
5
|
-
import { c as cn } from "./bem-cdccae08.js";
|
|
6
|
-
const defaultProps = {
|
|
7
|
-
width: typeof window === "object" ? window.innerWidth : 375,
|
|
8
|
-
height: 0,
|
|
9
|
-
duration: 500,
|
|
10
|
-
initPage: 0,
|
|
11
|
-
autoPlay: 0,
|
|
12
|
-
direction: "horizontal",
|
|
13
|
-
paginationColor: "#fff",
|
|
14
|
-
paginationBgColor: "#ddd",
|
|
15
|
-
paginationVisible: false,
|
|
16
|
-
loop: true,
|
|
17
|
-
touchable: true,
|
|
18
|
-
isPreventDefault: true,
|
|
19
|
-
isStopPropagation: true,
|
|
20
|
-
isCenter: false,
|
|
21
|
-
className: ""
|
|
22
|
-
};
|
|
23
|
-
const DISTANCE = 5;
|
|
24
|
-
const Swiper = React.forwardRef((props, ref) => {
|
|
25
|
-
const propSwiper = { ...defaultProps, ...props };
|
|
26
|
-
const { children, direction, className, pageContent, onChange, initPage, paginationColor, paginationVisible, touchable, isPreventDefault, isStopPropagation, autoPlay, isCenter, ...rest } = propSwiper;
|
|
27
|
-
const container = useRef(null);
|
|
28
|
-
const innerRef = useRef(null);
|
|
29
|
-
const _swiper = useRef({
|
|
30
|
-
moving: false,
|
|
31
|
-
autoplayTimer: null,
|
|
32
|
-
width: 0,
|
|
33
|
-
height: 0,
|
|
34
|
-
offset: 0,
|
|
35
|
-
size: 0
|
|
36
|
-
});
|
|
37
|
-
const [refRandomId] = useState(Math.random().toString(36).slice(-8));
|
|
38
|
-
const isVertical = direction === "vertical";
|
|
39
|
-
const [rect, setRect] = useState(null);
|
|
40
|
-
let [active, setActive] = useState(0);
|
|
41
|
-
const [width, setWidth] = useState(0);
|
|
42
|
-
const [height, setHeight] = useState(0);
|
|
43
|
-
const [offset, setOffset] = useState(0);
|
|
44
|
-
const [childOffset, setChildOffset] = useState([]);
|
|
45
|
-
const [ready, setReady] = useState(false);
|
|
46
|
-
let size = isVertical ? height : width;
|
|
47
|
-
const [touch, setTouch] = useState({
|
|
48
|
-
startX: 0,
|
|
49
|
-
startY: 0,
|
|
50
|
-
deltaX: 0,
|
|
51
|
-
deltaY: 0,
|
|
52
|
-
offsetX: 0,
|
|
53
|
-
offsetY: 0,
|
|
54
|
-
stateDirection: "",
|
|
55
|
-
delta: 0,
|
|
56
|
-
touchTime: 0
|
|
57
|
-
});
|
|
58
|
-
const { childs, childCount } = useMemo(() => {
|
|
59
|
-
let childCount2 = 0;
|
|
60
|
-
const childs2 = React.Children.map(props.children, (child) => {
|
|
61
|
-
if (!React.isValidElement(child))
|
|
62
|
-
return null;
|
|
63
|
-
childCount2++;
|
|
64
|
-
return child;
|
|
65
|
-
});
|
|
66
|
-
return {
|
|
67
|
-
childs: childs2,
|
|
68
|
-
childCount: childCount2
|
|
69
|
-
};
|
|
70
|
-
}, [props.children]);
|
|
71
|
-
let trackSize = childCount * Number(size);
|
|
72
|
-
const parent = {
|
|
73
|
-
propSwiper,
|
|
74
|
-
size
|
|
75
|
-
};
|
|
76
|
-
const minOffset = (() => {
|
|
77
|
-
if (rect) {
|
|
78
|
-
const base = isVertical ? rect == null ? void 0 : rect.height : rect == null ? void 0 : rect.width;
|
|
79
|
-
return base - Number(size) * childCount;
|
|
80
|
-
}
|
|
81
|
-
return 0;
|
|
82
|
-
})();
|
|
83
|
-
const stopAutoPlay = () => {
|
|
84
|
-
clearTimeout(_swiper.current.autoplayTimer);
|
|
85
|
-
_swiper.current.autoplayTimer = null;
|
|
86
|
-
};
|
|
87
|
-
const autoplay = () => {
|
|
88
|
-
if (propSwiper.autoPlay <= 0 || childCount <= 1)
|
|
89
|
-
return;
|
|
90
|
-
stopAutoPlay();
|
|
91
|
-
_swiper.current.autoplayTimer = setTimeout(() => {
|
|
92
|
-
next();
|
|
93
|
-
autoplay();
|
|
94
|
-
}, Number(propSwiper.autoPlay));
|
|
95
|
-
};
|
|
96
|
-
const resettPosition = () => {
|
|
97
|
-
_swiper.current.moving = true;
|
|
98
|
-
if (active <= -1) {
|
|
99
|
-
move({ pace: childCount });
|
|
100
|
-
}
|
|
101
|
-
if (active >= childCount) {
|
|
102
|
-
move({ pace: -childCount });
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
const prev = () => {
|
|
106
|
-
resettPosition();
|
|
107
|
-
touchReset();
|
|
108
|
-
requestFrame(() => {
|
|
109
|
-
requestFrame(() => {
|
|
110
|
-
_swiper.current.moving = false;
|
|
111
|
-
move({
|
|
112
|
-
pace: -1,
|
|
113
|
-
isEmit: true
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
const next = () => {
|
|
119
|
-
resettPosition();
|
|
120
|
-
touchReset();
|
|
121
|
-
requestFrame(() => {
|
|
122
|
-
requestFrame(() => {
|
|
123
|
-
_swiper.current.moving = false;
|
|
124
|
-
move({
|
|
125
|
-
pace: 1,
|
|
126
|
-
isEmit: true
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
|
-
const to = (index) => {
|
|
132
|
-
resettPosition();
|
|
133
|
-
touchReset();
|
|
134
|
-
requestFrame(() => {
|
|
135
|
-
requestFrame(() => {
|
|
136
|
-
_swiper.current.moving = false;
|
|
137
|
-
let targetIndex;
|
|
138
|
-
if (props.loop && childCount === index) {
|
|
139
|
-
targetIndex = active === 0 ? 0 : index;
|
|
140
|
-
} else {
|
|
141
|
-
targetIndex = index % childCount;
|
|
142
|
-
}
|
|
143
|
-
move({
|
|
144
|
-
pace: targetIndex - active,
|
|
145
|
-
isEmit: true
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
const resize = () => {
|
|
151
|
-
init(active);
|
|
152
|
-
};
|
|
153
|
-
const move = ({ pace = 0, offset: offset2 = 0, isEmit = false, movingStatus = false }) => {
|
|
154
|
-
if (childCount <= 1)
|
|
155
|
-
return;
|
|
156
|
-
const targetActive = getActive(pace);
|
|
157
|
-
const targetOffset = getOffset(targetActive, offset2);
|
|
158
|
-
if (props.loop) {
|
|
159
|
-
if (Array.isArray(children) && children[0] && targetOffset !== minOffset) {
|
|
160
|
-
const rightBound = targetOffset < minOffset;
|
|
161
|
-
childOffset[0] = rightBound ? trackSize : 0;
|
|
162
|
-
}
|
|
163
|
-
if (Array.isArray(children) && children[childCount - 1] && targetOffset !== 0) {
|
|
164
|
-
const leftBound = targetOffset > 0;
|
|
165
|
-
childOffset[childCount - 1] = leftBound ? -trackSize : 0;
|
|
166
|
-
}
|
|
167
|
-
setChildOffset(childOffset);
|
|
168
|
-
}
|
|
169
|
-
if (isEmit && active !== targetActive) {
|
|
170
|
-
props.onChange && props.onChange((targetActive + childCount) % childCount);
|
|
171
|
-
}
|
|
172
|
-
active = targetActive;
|
|
173
|
-
setActive(targetActive);
|
|
174
|
-
setOffset(targetOffset);
|
|
175
|
-
getStyle(targetOffset);
|
|
176
|
-
};
|
|
177
|
-
const getActive = (pace) => {
|
|
178
|
-
if (pace) {
|
|
179
|
-
const _active = active + pace;
|
|
180
|
-
if (props.loop) {
|
|
181
|
-
return range(_active, -1, childCount);
|
|
182
|
-
}
|
|
183
|
-
return range(_active, 0, childCount - 1);
|
|
184
|
-
}
|
|
185
|
-
return active;
|
|
186
|
-
};
|
|
187
|
-
const getOffset = (active2, offset2 = 0) => {
|
|
188
|
-
let currentPosition = active2 * Number(size);
|
|
189
|
-
if (!props.loop) {
|
|
190
|
-
currentPosition = Math.min(currentPosition, -minOffset);
|
|
191
|
-
}
|
|
192
|
-
let targetOffset = offset2 - currentPosition;
|
|
193
|
-
if (!props.loop) {
|
|
194
|
-
targetOffset = range(targetOffset, minOffset, 0);
|
|
195
|
-
}
|
|
196
|
-
return targetOffset;
|
|
197
|
-
};
|
|
198
|
-
const requestFrame = (fn) => {
|
|
199
|
-
window.requestAnimationFrame.call(window, fn);
|
|
200
|
-
};
|
|
201
|
-
const range = (num, min, max) => {
|
|
202
|
-
return Math.min(Math.max(num, min), max);
|
|
203
|
-
};
|
|
204
|
-
const getDirection = (x, y) => {
|
|
205
|
-
if (x > y && x > DISTANCE)
|
|
206
|
-
return "horizontal";
|
|
207
|
-
if (y > x && y > DISTANCE)
|
|
208
|
-
return "vertical";
|
|
209
|
-
return "";
|
|
210
|
-
};
|
|
211
|
-
const touchReset = () => {
|
|
212
|
-
touch.startX = 0;
|
|
213
|
-
touch.startY = 0;
|
|
214
|
-
touch.deltaX = 0;
|
|
215
|
-
touch.deltaY = 0;
|
|
216
|
-
touch.offsetX = 0;
|
|
217
|
-
touch.offsetY = 0;
|
|
218
|
-
touch.delta = 0;
|
|
219
|
-
touch.stateDirection = "";
|
|
220
|
-
touch.touchTime = 0;
|
|
221
|
-
};
|
|
222
|
-
const touchStart = (e) => {
|
|
223
|
-
touchReset();
|
|
224
|
-
touch.startX = e.touches[0].clientX;
|
|
225
|
-
touch.startY = e.touches[0].clientY;
|
|
226
|
-
};
|
|
227
|
-
const touchMove = (e) => {
|
|
228
|
-
touch.deltaX = e.touches[0].clientX - touch.startX;
|
|
229
|
-
touch.deltaY = e.touches[0].clientY - touch.startY;
|
|
230
|
-
touch.offsetX = Math.abs(touch.deltaX);
|
|
231
|
-
touch.offsetY = Math.abs(touch.deltaY);
|
|
232
|
-
touch.delta = isVertical ? touch.deltaY : touch.deltaX;
|
|
233
|
-
if (!touch.stateDirection) {
|
|
234
|
-
touch.stateDirection = getDirection(touch.offsetX, touch.offsetY);
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
const b = cn("swiper");
|
|
238
|
-
const classes = classNames(b(""));
|
|
239
|
-
const contentClass = classNames({
|
|
240
|
-
[`${b("inner")}`]: true,
|
|
241
|
-
[`${b("vertical")}`]: isVertical
|
|
242
|
-
});
|
|
243
|
-
const getStyle = (moveOffset = offset) => {
|
|
244
|
-
const target = innerRef.current;
|
|
245
|
-
let _offset = 0;
|
|
246
|
-
if (!isCenter) {
|
|
247
|
-
_offset = moveOffset;
|
|
248
|
-
} else {
|
|
249
|
-
const _size = isVertical ? height : width;
|
|
250
|
-
const val = isVertical ? (rect == null ? void 0 : rect.height) - _size : (rect == null ? void 0 : rect.width) - _size;
|
|
251
|
-
_offset = moveOffset + (active === childCount - 1 && !props.loop ? -val / 2 : val / 2);
|
|
252
|
-
}
|
|
253
|
-
target.style.transitionDuration = `${_swiper.current.moving ? 0 : props.duration}ms`;
|
|
254
|
-
target.style[isVertical ? "height" : "width"] = `${Number(size) * childCount}px`;
|
|
255
|
-
target.style[isVertical ? "width" : "height"] = `${isVertical ? width : height}px`;
|
|
256
|
-
target.style.transform = `translate3D${!isVertical ? `(${_offset}px,0,0)` : `(0,${_offset}px,0)`}`;
|
|
257
|
-
};
|
|
258
|
-
const onTouchStart = (e) => {
|
|
259
|
-
if (props.isPreventDefault)
|
|
260
|
-
e.preventDefault();
|
|
261
|
-
if (props.isStopPropagation)
|
|
262
|
-
e.stopPropagation();
|
|
263
|
-
if (!props.touchable)
|
|
264
|
-
return;
|
|
265
|
-
touchStart(e);
|
|
266
|
-
touch.touchTime = Date.now();
|
|
267
|
-
stopAutoPlay();
|
|
268
|
-
resettPosition();
|
|
269
|
-
};
|
|
270
|
-
const onTouchMove = (e) => {
|
|
271
|
-
if (props.touchable && _swiper.current.moving) {
|
|
272
|
-
touchMove(e);
|
|
273
|
-
if (touch.stateDirection === props.direction) {
|
|
274
|
-
move({
|
|
275
|
-
offset: touch.delta
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
const onTouchEnd = (e) => {
|
|
281
|
-
if (!props.touchable || !_swiper.current.moving)
|
|
282
|
-
return;
|
|
283
|
-
const speed = touch.delta / (Date.now() - touch.touchTime);
|
|
284
|
-
const isShouldMove = Math.abs(speed) > 0.3 || Math.abs(touch.delta) > +(size / 2).toFixed(2);
|
|
285
|
-
let pace = 0;
|
|
286
|
-
_swiper.current.moving = false;
|
|
287
|
-
if (isShouldMove && touch.stateDirection === props.direction) {
|
|
288
|
-
const offset2 = isVertical ? touch.offsetY : touch.offsetX;
|
|
289
|
-
if (props.loop) {
|
|
290
|
-
if (offset2 > 0) {
|
|
291
|
-
pace = touch.delta > 0 ? -1 : 1;
|
|
292
|
-
} else {
|
|
293
|
-
pace = 0;
|
|
294
|
-
}
|
|
295
|
-
} else {
|
|
296
|
-
pace = -Math[touch.delta > 0 ? "ceil" : "floor"](touch.delta / size);
|
|
297
|
-
}
|
|
298
|
-
move({
|
|
299
|
-
pace,
|
|
300
|
-
isEmit: true
|
|
301
|
-
});
|
|
302
|
-
} else if (touch.delta) {
|
|
303
|
-
move({ pace: 0 });
|
|
304
|
-
} else {
|
|
305
|
-
getStyle();
|
|
306
|
-
}
|
|
307
|
-
autoplay();
|
|
308
|
-
};
|
|
309
|
-
useEffect(() => {
|
|
310
|
-
_swiper.current.activePagination = (active + childCount) % childCount;
|
|
311
|
-
}, [active]);
|
|
312
|
-
const queryRect = (element) => {
|
|
313
|
-
return new Promise((resolve) => {
|
|
314
|
-
const query = createSelectorQuery();
|
|
315
|
-
query.select(`#${element.id}`) && query.select(`#${element.id}`).boundingClientRect();
|
|
316
|
-
query.exec((res) => {
|
|
317
|
-
resolve(res[0]);
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
};
|
|
321
|
-
const init = async (active2 = +propSwiper.initPage) => {
|
|
322
|
-
const rect2 = await queryRect(container.current);
|
|
323
|
-
const _active = Math.max(Math.min(childCount - 1, active2), 0);
|
|
324
|
-
const _width = propSwiper.width ? +propSwiper.width : rect2 == null ? void 0 : rect2.width;
|
|
325
|
-
const _height = propSwiper.height ? +propSwiper.height : rect2 == null ? void 0 : rect2.height;
|
|
326
|
-
size = isVertical ? _height : _width;
|
|
327
|
-
trackSize = childCount * Number(size);
|
|
328
|
-
const targetOffset = getOffset(_active);
|
|
329
|
-
_swiper.current.moving = true;
|
|
330
|
-
if (ready) {
|
|
331
|
-
_swiper.current.moving = false;
|
|
332
|
-
}
|
|
333
|
-
setRect(rect2);
|
|
334
|
-
setActive(_active);
|
|
335
|
-
setWidth(_width);
|
|
336
|
-
setHeight(_height);
|
|
337
|
-
setOffset(targetOffset);
|
|
338
|
-
setReady(true);
|
|
339
|
-
};
|
|
340
|
-
useEffect(() => {
|
|
341
|
-
if (ready) {
|
|
342
|
-
getStyle();
|
|
343
|
-
}
|
|
344
|
-
}, [isVertical, width, height, offset, ready]);
|
|
345
|
-
useEffect(() => {
|
|
346
|
-
if (ready) {
|
|
347
|
-
stopAutoPlay();
|
|
348
|
-
autoplay();
|
|
349
|
-
}
|
|
350
|
-
return () => {
|
|
351
|
-
setReady(false);
|
|
352
|
-
};
|
|
353
|
-
}, [ready]);
|
|
354
|
-
useEffect(() => {
|
|
355
|
-
stopAutoPlay();
|
|
356
|
-
autoplay();
|
|
357
|
-
}, [children]);
|
|
358
|
-
useEffect(() => {
|
|
359
|
-
nextTick(() => {
|
|
360
|
-
init();
|
|
361
|
-
});
|
|
362
|
-
}, [propSwiper.initPage]);
|
|
363
|
-
useEffect(() => {
|
|
364
|
-
return () => {
|
|
365
|
-
stopAutoPlay();
|
|
366
|
-
};
|
|
367
|
-
}, []);
|
|
368
|
-
useReady(() => {
|
|
369
|
-
nextTick(() => {
|
|
370
|
-
init();
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
const itemStyle = (index) => {
|
|
374
|
-
const style = {};
|
|
375
|
-
const _direction = propSwiper.direction || direction;
|
|
376
|
-
const _size = size;
|
|
377
|
-
if (_size) {
|
|
378
|
-
style[_direction === "horizontal" ? "width" : "height"] = `${_size}px`;
|
|
379
|
-
}
|
|
380
|
-
const offset2 = childOffset[index];
|
|
381
|
-
if (offset2) {
|
|
382
|
-
style.transform = `translate3D${_direction === "horizontal" ? `(${offset2}px,0,0)` : `(0,${offset2}px,0)`}`;
|
|
383
|
-
}
|
|
384
|
-
return style;
|
|
385
|
-
};
|
|
386
|
-
React.useImperativeHandle(ref, () => ({
|
|
387
|
-
to,
|
|
388
|
-
next,
|
|
389
|
-
prev,
|
|
390
|
-
resize
|
|
391
|
-
}));
|
|
392
|
-
return React.createElement(
|
|
393
|
-
DataContext.Provider,
|
|
394
|
-
{ value: parent },
|
|
395
|
-
React.createElement(
|
|
396
|
-
"div",
|
|
397
|
-
{
|
|
398
|
-
className: `${classes} ${className}`,
|
|
399
|
-
ref: container,
|
|
400
|
-
...rest,
|
|
401
|
-
id: `container-${refRandomId}`,
|
|
402
|
-
onTouchStart,
|
|
403
|
-
onTouchMove,
|
|
404
|
-
onTouchEnd,
|
|
405
|
-
// @ts-ignore
|
|
406
|
-
catchMove: isVertical
|
|
407
|
-
},
|
|
408
|
-
React.createElement("div", { className: contentClass, ref: innerRef }, React.Children.map(childs, (child, index) => {
|
|
409
|
-
return React.createElement("div", { className: b("item-wrapper"), style: itemStyle(index), key: index }, child);
|
|
410
|
-
})),
|
|
411
|
-
propSwiper.paginationVisible && !("pageContent" in propSwiper) ? React.createElement("div", { className: classNames({
|
|
412
|
-
[`${b("pagination")}`]: true,
|
|
413
|
-
[`${b("pagination-vertical")}`]: isVertical
|
|
414
|
-
}) }, React.Children.map(childs, (item, index) => {
|
|
415
|
-
return React.createElement("i", { style: (active + childCount) % childCount === index ? {
|
|
416
|
-
backgroundColor: propSwiper.paginationColor
|
|
417
|
-
} : {
|
|
418
|
-
backgroundColor: propSwiper.paginationBgColor
|
|
419
|
-
}, className: classNames({
|
|
420
|
-
active: (active + childCount) % childCount === index
|
|
421
|
-
}), key: index });
|
|
422
|
-
})) : React.createElement("div", null, pageContent)
|
|
423
|
-
)
|
|
424
|
-
);
|
|
425
|
-
});
|
|
426
|
-
Swiper.defaultProps = defaultProps;
|
|
427
|
-
Swiper.displayName = "NutSwiper";
|
|
428
|
-
export {
|
|
429
|
-
Swiper as S
|
|
430
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from "react";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
import { D as DataContext } from "./UserContext-735db09f.js";
|
|
4
|
-
import { c as cn } from "./bem-cdccae08.js";
|
|
5
|
-
const defaultProps = {
|
|
6
|
-
direction: "horizontal"
|
|
7
|
-
};
|
|
8
|
-
const SwiperItem = React.forwardRef((props, ref) => {
|
|
9
|
-
const _props = { ...defaultProps, ...props };
|
|
10
|
-
const { className, style, children, direction, size } = _props;
|
|
11
|
-
const parent = useContext(DataContext);
|
|
12
|
-
const b = cn("swiper-item");
|
|
13
|
-
const classes = classNames(b(""), className);
|
|
14
|
-
const getStyle = () => {
|
|
15
|
-
const style2 = {};
|
|
16
|
-
const _direction = (parent == null ? void 0 : parent.propSwiper.direction) || direction;
|
|
17
|
-
const _size = (parent == null ? void 0 : parent.size) || size;
|
|
18
|
-
if (_size) {
|
|
19
|
-
style2[_direction === "horizontal" ? "width" : "height"] = `${_size}px`;
|
|
20
|
-
}
|
|
21
|
-
return style2;
|
|
22
|
-
};
|
|
23
|
-
return React.createElement("div", { className: classes, style: { ...style, ...getStyle() } }, children);
|
|
24
|
-
});
|
|
25
|
-
SwiperItem.defaultProps = defaultProps;
|
|
26
|
-
SwiperItem.displayName = "NutSwiperItem";
|
|
27
|
-
export {
|
|
28
|
-
SwiperItem as S
|
|
29
|
-
};
|