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