@tarojs/components-react 4.0.1-alpha.0 → 4.0.1
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/LICENSE +8 -8
- package/dist/components/button/index.js +103 -78
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/icon/index.js +17 -26
- package/dist/components/icon/index.js.map +1 -1
- package/dist/components/image/index.js +101 -76
- package/dist/components/image/index.js.map +1 -1
- package/dist/components/input/index.js +206 -183
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/pull-down-refresh/index.js +211 -195
- package/dist/components/pull-down-refresh/index.js.map +1 -1
- package/dist/components/scroll-view/index.js +167 -137
- package/dist/components/scroll-view/index.js.map +1 -1
- package/dist/components/swiper/index.js +268 -248
- package/dist/components/swiper/index.js.map +1 -1
- package/dist/components/text/index.js +31 -22
- package/dist/components/text/index.js.map +1 -1
- package/dist/components/view/index.js +97 -72
- package/dist/components/view/index.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/utils/index.js +15 -26
- package/dist/utils/index.js.map +1 -1
- package/package.json +18 -19
- package/dist/solid/components/button/index.js +0 -95
- package/dist/solid/components/button/index.js.map +0 -1
- package/dist/solid/components/button/style/index.scss.js +0 -4
- package/dist/solid/components/button/style/index.scss.js.map +0 -1
- package/dist/solid/components/icon/index.js +0 -39
- package/dist/solid/components/icon/index.js.map +0 -1
- package/dist/solid/components/icon/style/index.scss.js +0 -4
- package/dist/solid/components/icon/style/index.scss.js.map +0 -1
- package/dist/solid/components/image/index.js +0 -94
- package/dist/solid/components/image/index.js.map +0 -1
- package/dist/solid/components/input/index.js +0 -256
- package/dist/solid/components/input/index.js.map +0 -1
- package/dist/solid/components/input/style/index.scss.js +0 -4
- package/dist/solid/components/input/style/index.scss.js.map +0 -1
- package/dist/solid/components/pull-down-refresh/index.js +0 -334
- package/dist/solid/components/pull-down-refresh/index.js.map +0 -1
- package/dist/solid/components/pull-down-refresh/style/index.css.js +0 -4
- package/dist/solid/components/pull-down-refresh/style/index.css.js.map +0 -1
- package/dist/solid/components/scroll-view/index.js +0 -188
- package/dist/solid/components/scroll-view/index.js.map +0 -1
- package/dist/solid/components/scroll-view/style/index.css.js +0 -4
- package/dist/solid/components/scroll-view/style/index.css.js.map +0 -1
- package/dist/solid/components/swiper/index.js +0 -307
- package/dist/solid/components/swiper/index.js.map +0 -1
- package/dist/solid/components/swiper/style/index.css.js +0 -4
- package/dist/solid/components/swiper/style/index.css.js.map +0 -1
- package/dist/solid/components/text/index.js +0 -32
- package/dist/solid/components/text/index.js.map +0 -1
- package/dist/solid/components/text/style/index.css.js +0 -4
- package/dist/solid/components/text/style/index.css.js.map +0 -1
- package/dist/solid/components/view/index.js +0 -88
- package/dist/solid/components/view/index.js.map +0 -1
- package/dist/solid/index.css +0 -1
- package/dist/solid/index.js +0 -13
- package/dist/solid/index.js.map +0 -1
- package/dist/solid/utils/hooks.solid.js +0 -54
- package/dist/solid/utils/hooks.solid.js.map +0 -1
- package/dist/solid/utils/index.js +0 -58
- package/dist/solid/utils/index.js.map +0 -1
- package/dist/utils/hooks.react.js +0 -15
- package/dist/utils/hooks.react.js.map +0 -1
- package/types/index.d.ts +0 -17
- /package/dist/{solid/components/image → components/view}/style/index.css.js +0 -0
- /package/dist/{solid/components/image → components/view}/style/index.css.js.map +0 -0
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
import _typeof from '@babel/runtime/helpers/typeof';
|
|
2
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
3
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
4
|
+
import _inherits from '@babel/runtime/helpers/inherits';
|
|
5
|
+
import _createSuper from '@babel/runtime/helpers/createSuper';
|
|
1
6
|
import { __rest } from 'tslib';
|
|
2
7
|
import 'swiper/swiper-bundle.min.css';
|
|
3
8
|
import './style/index.css.js';
|
|
4
9
|
import classNames from 'classnames';
|
|
5
|
-
import
|
|
10
|
+
import React from 'react';
|
|
6
11
|
import Swipers from 'swiper/swiper-bundle.esm.js';
|
|
7
|
-
import { debounce
|
|
8
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
12
|
+
import { debounce } from '../../utils/index.js';
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
var INSTANCE_ID = 0;
|
|
15
|
+
var createEvent = function createEvent(type) {
|
|
16
|
+
var e;
|
|
13
17
|
try {
|
|
14
18
|
e = new TouchEvent(type);
|
|
15
19
|
} catch (err) {
|
|
@@ -18,281 +22,297 @@ const createEvent = type => {
|
|
|
18
22
|
}
|
|
19
23
|
return e;
|
|
20
24
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
itemId,
|
|
28
|
-
children,
|
|
29
|
-
forwardedRef
|
|
30
|
-
} = _a,
|
|
31
|
-
restProps = __rest(_a, ["className", "style", "itemId", "children", "forwardedRef"]);
|
|
32
|
-
const cls = classNames('swiper-slide', className);
|
|
33
|
-
return /*#__PURE__*/jsx("div", {
|
|
34
|
-
ref: e => {
|
|
35
|
-
if (e && forwardedRef) {
|
|
36
|
-
forwardedRef.current = e;
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
className: cls,
|
|
40
|
-
style: style,
|
|
41
|
-
"item-id": itemId,
|
|
42
|
-
...restProps,
|
|
43
|
-
children: children
|
|
44
|
-
});
|
|
25
|
+
var SwiperItem = /*#__PURE__*/function (_React$Component) {
|
|
26
|
+
_inherits(SwiperItem, _React$Component);
|
|
27
|
+
var _super = _createSuper(SwiperItem);
|
|
28
|
+
function SwiperItem() {
|
|
29
|
+
_classCallCheck(this, SwiperItem);
|
|
30
|
+
return _super.apply(this, arguments);
|
|
45
31
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
32
|
+
_createClass(SwiperItem, [{
|
|
33
|
+
key: "render",
|
|
34
|
+
value: function render() {
|
|
35
|
+
var _a = this.props,
|
|
36
|
+
className = _a.className,
|
|
37
|
+
style = _a.style,
|
|
38
|
+
itemId = _a.itemId,
|
|
39
|
+
children = _a.children,
|
|
40
|
+
restProps = __rest(_a, ["className", "style", "itemId", "children"]);
|
|
41
|
+
var cls = classNames('swiper-slide', className);
|
|
42
|
+
return React.createElement("div", Object.assign({
|
|
43
|
+
className: cls,
|
|
44
|
+
style: style,
|
|
45
|
+
"item-id": itemId
|
|
46
|
+
}, restProps), children);
|
|
47
|
+
}
|
|
48
|
+
}]);
|
|
49
|
+
return SwiperItem;
|
|
50
|
+
}(React.Component);
|
|
51
|
+
var Swiper = /*#__PURE__*/function (_React$Component2) {
|
|
52
|
+
_inherits(Swiper, _React$Component2);
|
|
53
|
+
var _super2 = _createSuper(Swiper);
|
|
54
|
+
function Swiper() {
|
|
55
|
+
var _this;
|
|
56
|
+
_classCallCheck(this, Swiper);
|
|
57
|
+
_this = _super2.apply(this, arguments);
|
|
58
|
+
_this._id = 1 + INSTANCE_ID++;
|
|
59
|
+
_this._$current = 0;
|
|
60
|
+
_this._$width = 0;
|
|
61
|
+
_this._$height = 0;
|
|
62
|
+
_this.handleSwiperLoopListen = function () {
|
|
55
63
|
var _a, _b, _c, _d;
|
|
56
|
-
(_b = (_a =
|
|
57
|
-
(_d = (_c =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
(_b = (_a = _this.observerFirst) === null || _a === void 0 ? void 0 : _a.disconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
65
|
+
(_d = (_c = _this.observerLast) === null || _c === void 0 ? void 0 : _c.disconnect) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
66
|
+
_this.observerFirst = new MutationObserver(_this.handleSwiperLoop);
|
|
67
|
+
_this.observerLast = new MutationObserver(_this.handleSwiperLoop);
|
|
68
|
+
var wrapper = _this.mySwiper.$wrapperEl[0];
|
|
69
|
+
var list = wrapper.querySelectorAll('taro-swiper-item-core:not(.swiper-slide-duplicate)');
|
|
62
70
|
if (list.length >= 1) {
|
|
63
|
-
|
|
71
|
+
_this.observerFirst.observe(list[0], {
|
|
64
72
|
characterData: true
|
|
65
73
|
});
|
|
66
74
|
} else if (list.length >= 2) {
|
|
67
|
-
|
|
75
|
+
_this.observerLast.observe(list[list.length - 1], {
|
|
68
76
|
characterData: true
|
|
69
77
|
});
|
|
70
78
|
}
|
|
71
79
|
};
|
|
72
|
-
|
|
73
|
-
if (
|
|
80
|
+
_this.handleSwiperLoop = debounce(function () {
|
|
81
|
+
if (_this.mySwiper && _this.mySwiper.$wrapperEl && _this.props.circular) {
|
|
74
82
|
// @ts-ignore
|
|
75
|
-
|
|
83
|
+
_this.mySwiper.loopDestroy();
|
|
76
84
|
// @ts-ignore
|
|
77
|
-
|
|
85
|
+
_this.mySwiper.loopCreate();
|
|
78
86
|
}
|
|
79
87
|
}, 500);
|
|
88
|
+
return _this;
|
|
80
89
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
on: {
|
|
107
|
-
slideChange() {
|
|
108
|
-
const e = createEvent('touchend');
|
|
109
|
-
try {
|
|
110
|
-
Object.defineProperty(e, 'detail', {
|
|
111
|
-
enumerable: true,
|
|
112
|
-
value: {
|
|
113
|
-
current: this.realIndex
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
} catch (err) {} // eslint-disable-line no-empty
|
|
117
|
-
that._$current = this.realIndex;
|
|
118
|
-
that.handleOnChange(e);
|
|
90
|
+
_createClass(Swiper, [{
|
|
91
|
+
key: "componentDidMount",
|
|
92
|
+
value: function componentDidMount() {
|
|
93
|
+
var _this2 = this;
|
|
94
|
+
var _this$props = this.props,
|
|
95
|
+
_this$props$autoplay = _this$props.autoplay,
|
|
96
|
+
autoplay = _this$props$autoplay === void 0 ? false : _this$props$autoplay,
|
|
97
|
+
_this$props$circular = _this$props.circular,
|
|
98
|
+
circular = _this$props$circular === void 0 ? true : _this$props$circular,
|
|
99
|
+
_this$props$current = _this$props.current,
|
|
100
|
+
current = _this$props$current === void 0 ? 0 : _this$props$current,
|
|
101
|
+
_this$props$displayMu = _this$props.displayMultipleItems,
|
|
102
|
+
displayMultipleItems = _this$props$displayMu === void 0 ? 1 : _this$props$displayMu,
|
|
103
|
+
_this$props$duration = _this$props.duration,
|
|
104
|
+
duration = _this$props$duration === void 0 ? 500 : _this$props$duration,
|
|
105
|
+
_this$props$interval = _this$props.interval,
|
|
106
|
+
interval = _this$props$interval === void 0 ? 5000 : _this$props$interval,
|
|
107
|
+
spaceBetween = _this$props.spaceBetween,
|
|
108
|
+
vertical = _this$props.vertical;
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
110
|
+
var that = this;
|
|
111
|
+
var opt = {
|
|
112
|
+
// 指示器
|
|
113
|
+
pagination: {
|
|
114
|
+
el: ".taro-swiper-".concat(this._id, " > .swiper-container > .swiper-pagination")
|
|
119
115
|
},
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
116
|
+
direction: vertical ? 'vertical' : 'horizontal',
|
|
117
|
+
loop: circular,
|
|
118
|
+
slidesPerView: parseFloat(String(displayMultipleItems)),
|
|
119
|
+
initialSlide: parseInt(String(current), 10),
|
|
120
|
+
speed: parseInt(String(duration), 10),
|
|
121
|
+
observer: true,
|
|
122
|
+
observeParents: true,
|
|
123
|
+
on: {
|
|
124
|
+
slideChange: function slideChange() {
|
|
125
|
+
var e = createEvent('touchend');
|
|
126
|
+
try {
|
|
127
|
+
Object.defineProperty(e, 'detail', {
|
|
128
|
+
enumerable: true,
|
|
129
|
+
value: {
|
|
130
|
+
current: this.realIndex
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
} catch (err) {} // eslint-disable-line no-empty
|
|
134
|
+
that._$current = this.realIndex;
|
|
135
|
+
that.handleOnChange(e);
|
|
136
|
+
},
|
|
137
|
+
transitionEnd: function transitionEnd() {
|
|
138
|
+
var e = createEvent('touchend');
|
|
139
|
+
try {
|
|
140
|
+
Object.defineProperty(e, 'detail', {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
value: {
|
|
143
|
+
current: this.mySwiper.realIndex
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
if (this.mySwiper.isBeginning) {
|
|
147
|
+
this.mySwiper.slideToLoop(this.props.children.length - 1, 0);
|
|
148
|
+
} else if (this.mySwiper.isEnd) {
|
|
149
|
+
this.mySwiper.slideToLoop(0, 0);
|
|
127
150
|
}
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (that.props.autoplay && target.contains(_swiper.$el[0])) {
|
|
142
|
-
if (that.props.circular) {
|
|
143
|
-
_swiper.slideToLoop(this.realIndex, 0); // 更新下标
|
|
144
|
-
} else {
|
|
145
|
-
_swiper.slideTo(this.realIndex);
|
|
151
|
+
} catch (err) {} // eslint-disable-line no-empty
|
|
152
|
+
that.handleOnAnimationFinish(e);
|
|
153
|
+
},
|
|
154
|
+
observerUpdate: function observerUpdate(_swiper, e) {
|
|
155
|
+
var target = e.target;
|
|
156
|
+
var className = target && typeof target.className === 'string' ? target.className : '';
|
|
157
|
+
if (className.includes('taro_page') && target.style.display !== 'none') {
|
|
158
|
+
if (that.props.autoplay && target.contains(_swiper.$el[0])) {
|
|
159
|
+
if (that.props.circular) {
|
|
160
|
+
_swiper.slideToLoop(this.realIndex, 0); // 更新下标
|
|
161
|
+
} else {
|
|
162
|
+
_swiper.slideTo(this.realIndex);
|
|
163
|
+
}
|
|
146
164
|
}
|
|
147
165
|
}
|
|
148
166
|
}
|
|
149
167
|
}
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
// 自动播放
|
|
153
|
-
if (autoplay) {
|
|
154
|
-
opt.autoplay = {
|
|
155
|
-
delay: parseInt(String(interval), 10),
|
|
156
|
-
disableOnInteraction: false
|
|
157
168
|
};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
setTimeout(() => {
|
|
165
|
-
this.mySwiper.update();
|
|
166
|
-
}, 500);
|
|
167
|
-
if (!this.mySwiper || !this.props.circular) return;
|
|
168
|
-
const wrapper = this.mySwiper.$wrapperEl[0];
|
|
169
|
-
this.observer = new MutationObserver(this.handleSwiperLoopListen);
|
|
170
|
-
this.observer.observe(wrapper, {
|
|
171
|
-
childList: true
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
175
|
-
if (this.mySwiper) {
|
|
176
|
-
const nextCurrent = typeof nextProps.current === 'number' ? nextProps.current : this._$current || 0;
|
|
177
|
-
this.handleSwiperLoop();
|
|
178
|
-
// 是否衔接滚动模式
|
|
179
|
-
if (nextProps.circular) {
|
|
180
|
-
if (!this.mySwiper.isBeginning && !this.mySwiper.isEnd) {
|
|
181
|
-
this.mySwiper.slideToLoop(parseInt(nextCurrent, 10)); // 更新下标
|
|
182
|
-
}
|
|
183
|
-
} else {
|
|
184
|
-
this.mySwiper.slideTo(parseInt(nextCurrent, 10) + 1); // 更新下标
|
|
169
|
+
// 自动播放
|
|
170
|
+
if (autoplay) {
|
|
171
|
+
opt.autoplay = {
|
|
172
|
+
delay: parseInt(String(interval), 10),
|
|
173
|
+
disableOnInteraction: false
|
|
174
|
+
};
|
|
185
175
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
176
|
+
// 两端距离
|
|
177
|
+
if (spaceBetween) {
|
|
178
|
+
opt.spaceBetween = spaceBetween;
|
|
179
|
+
}
|
|
180
|
+
this.mySwiper = new Swipers(this.$el, opt);
|
|
181
|
+
setTimeout(function () {
|
|
182
|
+
_this2.mySwiper.update();
|
|
183
|
+
}, 500);
|
|
184
|
+
if (!this.mySwiper || !this.props.circular) return;
|
|
185
|
+
var wrapper = this.mySwiper.$wrapperEl[0];
|
|
186
|
+
this.observer = new MutationObserver(this.handleSwiperLoopListen);
|
|
187
|
+
this.observer.observe(wrapper, {
|
|
188
|
+
childList: true
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}, {
|
|
192
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
193
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
194
|
+
if (this.mySwiper) {
|
|
195
|
+
var nextCurrent = typeof nextProps.current === 'number' ? nextProps.current : this._$current || 0;
|
|
196
|
+
this.handleSwiperLoop();
|
|
197
|
+
// 是否衔接滚动模式
|
|
198
|
+
if (nextProps.circular) {
|
|
199
|
+
if (!this.mySwiper.isBeginning && !this.mySwiper.isEnd) {
|
|
200
|
+
this.mySwiper.slideToLoop(parseInt(nextCurrent, 10)); // 更新下标
|
|
193
201
|
}
|
|
194
|
-
autoplay.start();
|
|
195
202
|
} else {
|
|
196
|
-
|
|
203
|
+
this.mySwiper.slideTo(parseInt(nextCurrent, 10) + 1); // 更新下标
|
|
197
204
|
}
|
|
205
|
+
|
|
206
|
+
var autoplay = this.mySwiper.autoplay;
|
|
207
|
+
// 判断是否需要停止或开始自动轮播
|
|
208
|
+
if (autoplay.running !== nextProps.autoplay) {
|
|
209
|
+
if (nextProps.autoplay) {
|
|
210
|
+
if (_typeof(this.mySwiper.params.autoplay) === 'object') {
|
|
211
|
+
this.mySwiper.params.autoplay.disableOnInteraction = false;
|
|
212
|
+
this.mySwiper.params.autoplay.delay = parseInt(String(this.props.interval) || '3000', 10);
|
|
213
|
+
}
|
|
214
|
+
autoplay.start();
|
|
215
|
+
} else {
|
|
216
|
+
autoplay.stop();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
this.mySwiper.update(); // 更新子元素
|
|
198
220
|
}
|
|
199
|
-
this.mySwiper.update(); // 更新子元素
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
componentDidUpdate(preProps) {
|
|
203
|
-
if (preProps.children.length === 0 && this.props.children.length > 0) {
|
|
204
|
-
this.mySwiper.loopDestroy();
|
|
205
|
-
this.mySwiper.loopCreate();
|
|
206
221
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
222
|
+
}, {
|
|
223
|
+
key: "componentDidUpdate",
|
|
224
|
+
value: function componentDidUpdate(preProps) {
|
|
225
|
+
if (preProps.children.length === 0 && this.props.children.length > 0) {
|
|
226
|
+
this.mySwiper.loopDestroy();
|
|
227
|
+
this.mySwiper.loopCreate();
|
|
211
228
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
componentWillUnmount() {
|
|
217
|
-
var _a, _b, _c, _d, _e, _f;
|
|
218
|
-
this.$el = null;
|
|
219
|
-
if (this.mySwiper) this.mySwiper.destroy();
|
|
220
|
-
(_b = (_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
221
|
-
(_d = (_c = this.observerFirst) === null || _c === void 0 ? void 0 : _c.disconnect) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
222
|
-
(_f = (_e = this.observerLast) === null || _e === void 0 ? void 0 : _e.disconnect) === null || _f === void 0 ? void 0 : _f.call(_e);
|
|
223
|
-
}
|
|
224
|
-
handleOnChange(e) {
|
|
225
|
-
const func = this.props.onChange;
|
|
226
|
-
typeof func === 'function' && func(e);
|
|
227
|
-
}
|
|
228
|
-
handleOnAnimationFinish(e) {
|
|
229
|
-
const func = this.props.onAnimationFinish;
|
|
230
|
-
typeof func === 'function' && func(e);
|
|
231
|
-
}
|
|
232
|
-
parsePX() {
|
|
233
|
-
let s = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '0px';
|
|
234
|
-
return parseFloat(s.replace(/r*px/i, ''));
|
|
235
|
-
}
|
|
236
|
-
render() {
|
|
237
|
-
const {
|
|
238
|
-
className,
|
|
239
|
-
style,
|
|
240
|
-
vertical,
|
|
241
|
-
previousMargin,
|
|
242
|
-
nextMargin,
|
|
243
|
-
indicatorColor,
|
|
244
|
-
indicatorActiveColor,
|
|
245
|
-
forwardedRef
|
|
246
|
-
} = this.props;
|
|
247
|
-
const defaultIndicatorColor = indicatorColor || 'rgba(0, 0, 0, .3)';
|
|
248
|
-
const defaultIndicatorActiveColor = indicatorActiveColor || '#000';
|
|
249
|
-
const cls = classNames(`taro-swiper-${this._id}`, className);
|
|
250
|
-
const sty = Object.assign({
|
|
251
|
-
paddingTop: vertical ? this.parsePX(previousMargin) : 0,
|
|
252
|
-
paddingRight: vertical ? 0 : this.parsePX(nextMargin),
|
|
253
|
-
paddingBottom: vertical ? this.parsePX(nextMargin) : 0,
|
|
254
|
-
paddingLeft: vertical ? 0 : this.parsePX(previousMargin),
|
|
255
|
-
overflow: 'hidden'
|
|
256
|
-
}, style);
|
|
257
|
-
const paginationCls = classNames('swiper-pagination', {
|
|
258
|
-
'swiper-pagination-hidden': !this.props.indicatorDots,
|
|
259
|
-
'swiper-pagination-bullets': this.props.indicatorDots
|
|
260
|
-
});
|
|
261
|
-
return /*#__PURE__*/jsx("div", {
|
|
262
|
-
className: `swiper-container-wrapper ${cls}`,
|
|
263
|
-
style: sty,
|
|
264
|
-
ref: e => {
|
|
265
|
-
if (forwardedRef && e) {
|
|
266
|
-
forwardedRef.current = e;
|
|
229
|
+
if (!this.mySwiper) return;
|
|
230
|
+
if (this.props.autoplay) {
|
|
231
|
+
if (this._$width !== this.mySwiper.width || this._$height !== this.mySwiper.height) {
|
|
232
|
+
this.mySwiper.autoplay.start();
|
|
267
233
|
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
234
|
+
}
|
|
235
|
+
this._$width = this.mySwiper.width;
|
|
236
|
+
this._$height = this.mySwiper.height;
|
|
237
|
+
}
|
|
238
|
+
}, {
|
|
239
|
+
key: "componentWillUnmount",
|
|
240
|
+
value: function componentWillUnmount() {
|
|
241
|
+
var _a, _b, _c, _d, _e, _f;
|
|
242
|
+
this.$el = null;
|
|
243
|
+
if (this.mySwiper) this.mySwiper.destroy();
|
|
244
|
+
(_b = (_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
245
|
+
(_d = (_c = this.observerFirst) === null || _c === void 0 ? void 0 : _c.disconnect) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
246
|
+
(_f = (_e = this.observerLast) === null || _e === void 0 ? void 0 : _e.disconnect) === null || _f === void 0 ? void 0 : _f.call(_e);
|
|
247
|
+
}
|
|
248
|
+
}, {
|
|
249
|
+
key: "handleOnChange",
|
|
250
|
+
value: function handleOnChange(e) {
|
|
251
|
+
var func = this.props.onChange;
|
|
252
|
+
typeof func === 'function' && func(e);
|
|
253
|
+
}
|
|
254
|
+
}, {
|
|
255
|
+
key: "handleOnAnimationFinish",
|
|
256
|
+
value: function handleOnAnimationFinish(e) {
|
|
257
|
+
var func = this.props.onAnimationFinish;
|
|
258
|
+
typeof func === 'function' && func(e);
|
|
259
|
+
}
|
|
260
|
+
}, {
|
|
261
|
+
key: "parsePX",
|
|
262
|
+
value: function parsePX() {
|
|
263
|
+
var s = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '0px';
|
|
264
|
+
return parseFloat(s.replace(/r*px/i, ''));
|
|
265
|
+
}
|
|
266
|
+
}, {
|
|
267
|
+
key: "render",
|
|
268
|
+
value: function render() {
|
|
269
|
+
var _this3 = this;
|
|
270
|
+
var _this$props2 = this.props,
|
|
271
|
+
className = _this$props2.className,
|
|
272
|
+
style = _this$props2.style,
|
|
273
|
+
vertical = _this$props2.vertical,
|
|
274
|
+
previousMargin = _this$props2.previousMargin,
|
|
275
|
+
nextMargin = _this$props2.nextMargin,
|
|
276
|
+
indicatorColor = _this$props2.indicatorColor,
|
|
277
|
+
indicatorActiveColor = _this$props2.indicatorActiveColor;
|
|
278
|
+
var defaultIndicatorColor = indicatorColor || 'rgba(0, 0, 0, .3)';
|
|
279
|
+
var defaultIndicatorActiveColor = indicatorActiveColor || '#000';
|
|
280
|
+
var cls = classNames("taro-swiper-".concat(this._id), className);
|
|
281
|
+
var sty = Object.assign({
|
|
282
|
+
paddingTop: vertical ? this.parsePX(previousMargin) : 0,
|
|
283
|
+
paddingRight: vertical ? 0 : this.parsePX(nextMargin),
|
|
284
|
+
paddingBottom: vertical ? this.parsePX(nextMargin) : 0,
|
|
285
|
+
paddingLeft: vertical ? 0 : this.parsePX(previousMargin),
|
|
286
|
+
overflow: 'hidden'
|
|
287
|
+
}, style);
|
|
288
|
+
var paginationCls = classNames('swiper-pagination', {
|
|
289
|
+
'swiper-pagination-hidden': !this.props.indicatorDots,
|
|
290
|
+
'swiper-pagination-bullets': this.props.indicatorDots
|
|
291
|
+
});
|
|
292
|
+
return React.createElement("div", {
|
|
293
|
+
className: "swiper-container-wrapper ".concat(cls),
|
|
294
|
+
style: sty
|
|
295
|
+
}, React.createElement("div", {
|
|
296
|
+
className: 'swiper-container',
|
|
271
297
|
style: {
|
|
272
298
|
overflow: 'visible'
|
|
273
299
|
},
|
|
274
|
-
ref: el
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
})
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
const Swiper = createForwardRefComponent(SwiperInner);
|
|
295
|
-
const SwiperItem = createForwardRefComponent(SwiperItemInner);
|
|
300
|
+
ref: function ref(el) {
|
|
301
|
+
_this3.$el = el;
|
|
302
|
+
}
|
|
303
|
+
}, React.createElement("div", {
|
|
304
|
+
dangerouslySetInnerHTML: {
|
|
305
|
+
__html: "<style type='text/css'>\n .taro-swiper-".concat(this._id, " > .swiper-container > .swiper-pagination > .swiper-pagination-bullet { background: ").concat(defaultIndicatorColor, " }\n .taro-swiper-").concat(this._id, " > .swiper-container > .swiper-pagination > .swiper-pagination-bullet-active { background: ").concat(defaultIndicatorActiveColor, " }\n </style>")
|
|
306
|
+
}
|
|
307
|
+
}), React.createElement("div", {
|
|
308
|
+
className: 'swiper-wrapper'
|
|
309
|
+
}, this.props.children), React.createElement("div", {
|
|
310
|
+
className: paginationCls
|
|
311
|
+
})));
|
|
312
|
+
}
|
|
313
|
+
}]);
|
|
314
|
+
return Swiper;
|
|
315
|
+
}(React.Component);
|
|
296
316
|
|
|
297
317
|
export { Swiper, SwiperItem };
|
|
298
318
|
//# sourceMappingURL=index.js.map
|