@tarojs/components-react 4.0.0-beta.1 → 4.0.0-beta.100

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