@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,21 +1,16 @@
1
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
- import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
3
- import _createClass from '@babel/runtime/helpers/createClass';
4
- import _assertThisInitialized from '@babel/runtime/helpers/assertThisInitialized';
5
- import _inherits from '@babel/runtime/helpers/inherits';
6
- import _createSuper from '@babel/runtime/helpers/createSuper';
7
- import { __rest } from '../../node_modules/.pnpm/tslib@2.6.2/node_modules/tslib/tslib.es6.js';
8
- import './style/index.js';
1
+ import { __rest } from 'tslib';
2
+ import './style/index.css.js';
9
3
  import Taro from '@tarojs/taro';
10
4
  import classNames from 'classnames';
11
- import React from 'react';
5
+ import React__default from 'react';
6
+ import { jsx, jsxs } from 'react/jsx-runtime';
12
7
 
13
8
  function setTransform(nodeStyle, value) {
14
9
  nodeStyle.transform = value;
15
10
  nodeStyle.webkitTransform = value;
16
11
  nodeStyle.MozTransform = value;
17
12
  }
18
- var isWebView = typeof navigator !== 'undefined' && /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent);
13
+ const isWebView = typeof navigator !== 'undefined' && /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent);
19
14
  var PullDownState;
20
15
  (function (PullDownState) {
21
16
  PullDownState["activate"] = "activate";
@@ -30,112 +25,103 @@ var INDICATOR;
30
25
  INDICATOR["release"] = "loading";
31
26
  INDICATOR["finish"] = "finish";
32
27
  })(INDICATOR || (INDICATOR = {}));
33
- var supportsPassive = false;
28
+ let supportsPassive = false;
34
29
  try {
35
- var opts = Object.defineProperty({}, 'passive', {
36
- get: function get() {
30
+ const opts = Object.defineProperty({}, 'passive', {
31
+ get() {
37
32
  supportsPassive = true;
38
33
  }
39
34
  });
40
- window.addEventListener('cancel', function () {
41
- return {};
42
- }, opts);
35
+ window.addEventListener('cancel', () => ({}), opts);
43
36
  } catch (e) {} // eslint-disable-line no-empty
44
- var willPreventDefault = supportsPassive ? {
37
+ const willPreventDefault = supportsPassive ? {
45
38
  passive: false
46
39
  } : false;
47
- var PullDownRefresh = /*#__PURE__*/function (_React$Component) {
48
- _inherits(PullDownRefresh, _React$Component);
49
- var _super = _createSuper(PullDownRefresh);
50
- function PullDownRefresh() {
51
- var _this;
52
- _classCallCheck(this, PullDownRefresh);
53
- _this = _super.apply(this, arguments);
40
+ class PullDownRefresh extends React__default.Component {
41
+ constructor() {
42
+ super(...arguments);
54
43
  // https://github.com/yiminghe/zscroller/blob/2d97973287135745818a0537712235a39a6a62a1/src/Scroller.js#L355
55
44
  // currSt: `activate` / `deactivate` / `release` / `finish`
56
- _this.state = {
45
+ this.state = {
57
46
  currSt: PullDownState.deactivate,
58
47
  dragOnEdge: false
59
48
  };
60
- _this._ScreenY = 0;
61
- _this._startScreenY = 0;
62
- _this._lastScreenY = 0;
63
- _this._isMounted = false;
64
- _this.listeners = [];
65
- _this.triggerPullDownRefresh = function (flag) {
49
+ this._ScreenY = 0;
50
+ this._startScreenY = 0;
51
+ this._lastScreenY = 0;
52
+ this._isMounted = false;
53
+ this.listeners = [];
54
+ this.triggerPullDownRefresh = flag => {
66
55
  // 在初始化时、用代码 自动 触发 pullDownRefresh
67
56
  // 添加this._isMounted的判断,否则组建一实例化,currSt就会是finish
68
- if (!_this.state.dragOnEdge && _this._isMounted) {
57
+ if (!this.state.dragOnEdge && this._isMounted) {
69
58
  if (flag) {
70
- _this._lastScreenY = _this.props.distanceToRefresh + 1;
59
+ this._lastScreenY = this.props.distanceToRefresh + 1;
71
60
  // change dom need after setState
72
- _this.setState({
61
+ this.setState({
73
62
  currSt: PullDownState.release
74
- }, function () {
75
- return _this.setContentStyle(_this._lastScreenY);
76
- });
63
+ }, () => this.setContentStyle(this._lastScreenY));
77
64
  } else {
78
- _this.setState({
65
+ this.setState({
79
66
  currSt: PullDownState.finish
80
- }, function () {
81
- return _this.reset();
82
- });
67
+ }, () => this.reset());
83
68
  }
84
69
  }
85
70
  };
86
- _this.init = function () {
87
- var ele = _this.scrollContainer;
88
- _this._to = {
89
- touchstart: _this.onTouchStart.bind(_assertThisInitialized(_this), ele),
90
- touchmove: _this.onTouchMove.bind(_assertThisInitialized(_this), ele),
91
- touchend: _this.onTouchEnd.bind(_assertThisInitialized(_this), ele),
92
- touchcancel: _this.onTouchEnd.bind(_assertThisInitialized(_this), ele)
71
+ this.init = () => {
72
+ const ele = this.scrollContainer;
73
+ this._to = {
74
+ touchstart: this.onTouchStart.bind(this, ele),
75
+ touchmove: this.onTouchMove.bind(this, ele),
76
+ touchend: this.onTouchEnd.bind(this, ele),
77
+ touchcancel: this.onTouchEnd.bind(this, ele)
93
78
  };
94
- Object.keys(_this._to).forEach(function (key) {
95
- ele.addEventListener(key, _this._to[key], willPreventDefault);
79
+ Object.keys(this._to).forEach(key => {
80
+ ele.addEventListener(key, this._to[key], willPreventDefault);
96
81
  });
97
82
  };
98
- _this.destroy = function () {
99
- var ele = _this.scrollContainer;
100
- Object.keys(_this._to).forEach(function (key) {
101
- ele.removeEventListener(key, _this._to[key]);
83
+ this.destroy = () => {
84
+ if (!this._to) return;
85
+ const ele = this.scrollContainer;
86
+ Object.keys(this._to).forEach(key => {
87
+ ele.removeEventListener(key, this._to[key]);
102
88
  });
103
89
  };
104
- _this.onTouchStart = function (_, e) {
105
- _this._ScreenY = _this._startScreenY = e.touches[0].screenY;
90
+ this.onTouchStart = (_, e) => {
91
+ this._ScreenY = this._startScreenY = e.touches[0].screenY;
106
92
  // 一开始 refreshing 为 true 时 this._lastScreenY 有值
107
- _this._lastScreenY = _this._lastScreenY || 0;
93
+ this._lastScreenY = this._lastScreenY || 0;
108
94
  };
109
- _this.isEdge = function (ele) {
110
- var container = _this.scrollContainer;
95
+ this.isEdge = ele => {
96
+ const container = this.scrollContainer;
111
97
  if (container && container === document.body) {
112
98
  // In chrome61 `document.body.scrollTop` is invalid
113
- var scrollNode = document.scrollingElement ? document.scrollingElement : document.body;
99
+ const scrollNode = document.scrollingElement ? document.scrollingElement : document.body;
114
100
  return scrollNode.scrollTop <= 0;
115
101
  }
116
102
  return ele.scrollTop <= 0;
117
103
  };
118
- _this.damping = function (dy) {
119
- if (Math.abs(_this._lastScreenY) > _this.props.damping) {
104
+ this.damping = dy => {
105
+ if (Math.abs(this._lastScreenY) > this.props.damping) {
120
106
  return 0;
121
107
  }
122
- var ratio = Math.abs(_this._ScreenY - _this._startScreenY) / window.screen.height;
108
+ const ratio = Math.abs(this._ScreenY - this._startScreenY) / window.screen.height;
123
109
  dy *= (1 - ratio) * 0.6;
124
110
  return dy;
125
111
  };
126
- _this.onTouchMove = function (ele, e) {
112
+ this.onTouchMove = (ele, e) => {
127
113
  // 使用 pageY 对比有问题
128
- var _screenY = e.touches[0].screenY;
114
+ const _screenY = e.touches[0].screenY;
129
115
  // 拖动方向不符合的不处理
130
- if (_this._startScreenY > _screenY) {
116
+ if (this._startScreenY > _screenY) {
131
117
  return;
132
118
  }
133
- if (_this.isEdge(ele)) {
134
- if (!_this.state.dragOnEdge) {
119
+ if (this.isEdge(ele)) {
120
+ if (!this.state.dragOnEdge) {
135
121
  // 当用户开始往上滑的时候isEdge还是false的话,会导致this._ScreenY不是想要的,只有当isEdge为true时,再上滑,才有意义
136
122
  // 下面这行代码解决了上面这个问题
137
- _this._ScreenY = _this._startScreenY = e.touches[0].screenY;
138
- _this.setState({
123
+ this._ScreenY = this._startScreenY = e.touches[0].screenY;
124
+ this.setState({
139
125
  dragOnEdge: true
140
126
  });
141
127
  }
@@ -145,21 +131,21 @@ var PullDownRefresh = /*#__PURE__*/function (_React$Component) {
145
131
  // add stopPropagation with fastclick will trigger content onClick event. why?
146
132
  // ref https://github.com/ant-design/ant-design-mobile/issues/2141
147
133
  // e.stopPropagation();
148
- var _diff = Math.round(_screenY - _this._ScreenY);
149
- _this._ScreenY = _screenY;
150
- _this._lastScreenY += _this.damping(_diff);
151
- _this.setContentStyle(_this._lastScreenY);
152
- if (Math.abs(_this._lastScreenY) < _this.props.distanceToRefresh) {
153
- if (_this.state.currSt !== PullDownState.deactivate) {
134
+ const _diff = Math.round(_screenY - this._ScreenY);
135
+ this._ScreenY = _screenY;
136
+ this._lastScreenY += this.damping(_diff);
137
+ this.setContentStyle(this._lastScreenY);
138
+ if (Math.abs(this._lastScreenY) < this.props.distanceToRefresh) {
139
+ if (this.state.currSt !== PullDownState.deactivate) {
154
140
  // console.log('back to the distance');
155
- _this.setState({
141
+ this.setState({
156
142
  currSt: PullDownState.deactivate
157
143
  });
158
144
  }
159
145
  } else {
160
- if (_this.state.currSt === PullDownState.deactivate) {
146
+ if (this.state.currSt === PullDownState.deactivate) {
161
147
  // console.log('reach to the distance');
162
- _this.setState({
148
+ this.setState({
163
149
  currSt: PullDownState.activate
164
150
  });
165
151
  }
@@ -167,163 +153,156 @@ var PullDownRefresh = /*#__PURE__*/function (_React$Component) {
167
153
  // https://github.com/ant-design/ant-design-mobile/issues/573#issuecomment-339560829
168
154
  // iOS UIWebView issue, It seems no problem in WKWebView
169
155
  if (isWebView && e.changedTouches[0].clientY < 0) {
170
- _this.onTouchEnd();
156
+ this.onTouchEnd();
171
157
  }
172
158
  }
173
159
  };
174
- _this.onTouchEnd = function () {
160
+ this.onTouchEnd = () => {
175
161
  var _a, _b;
176
- if (_this.state.dragOnEdge) {
177
- _this.setState({
162
+ if (this.state.dragOnEdge) {
163
+ this.setState({
178
164
  dragOnEdge: false
179
165
  });
180
166
  }
181
- if (_this.state.currSt === PullDownState.activate) {
182
- _this.setState({
167
+ if (this.state.currSt === PullDownState.activate) {
168
+ this.setState({
183
169
  currSt: PullDownState.release
184
170
  });
185
- (_b = (_a = _this.props).onRefresh) === null || _b === void 0 ? void 0 : _b.call(_a);
186
- _this._lastScreenY = _this.props.distanceToRefresh + 1;
187
- _this.setContentStyle(_this._lastScreenY);
188
- } else if (_this.state.currSt === 'release') {
189
- _this._lastScreenY = _this.props.distanceToRefresh + 1;
190
- _this.setContentStyle(_this._lastScreenY);
171
+ (_b = (_a = this.props).onRefresh) === null || _b === void 0 ? void 0 : _b.call(_a);
172
+ this._lastScreenY = this.props.distanceToRefresh + 1;
173
+ this.setContentStyle(this._lastScreenY);
174
+ } else if (this.state.currSt === 'release') {
175
+ this._lastScreenY = this.props.distanceToRefresh + 1;
176
+ this.setContentStyle(this._lastScreenY);
191
177
  } else {
192
- _this.reset();
178
+ this.reset();
193
179
  }
194
180
  };
195
- _this.reset = function () {
196
- _this._lastScreenY = 0;
197
- _this.setContentStyle(0);
181
+ this.reset = () => {
182
+ this._lastScreenY = 0;
183
+ this.setContentStyle(0);
198
184
  };
199
- _this.setContentStyle = function (ty) {
185
+ this.setContentStyle = ty => {
200
186
  // TODO: Why sometimes do not have `this.contentRef` ?
201
- if (_this.contentRef) {
187
+ if (this.contentRef) {
202
188
  // translate3d 不清理 会影响内部元素定位
203
189
  if (ty) {
204
- setTransform(_this.contentRef.style, "translate3d(0px,".concat(ty, "px,0)"));
190
+ setTransform(this.contentRef.style, `translate3d(0px,${ty}px,0)`);
205
191
  } else {
206
- setTransform(_this.contentRef.style, '');
192
+ setTransform(this.contentRef.style, '');
207
193
  }
208
194
  }
209
195
  };
210
- return _this;
211
196
  }
212
- _createClass(PullDownRefresh, [{
213
- key: "scrollContainer",
214
- get: function get() {
215
- var _a, _b;
216
- return ((_a = this.contentRef) === null || _a === void 0 ? void 0 : _a.parentElement) || ((_b = this.contentRef) === null || _b === void 0 ? void 0 : _b.closest('.taro_page_stationed')) || document.querySelector('.taro_page_stationed') || document.querySelector('.taro_page') || document.querySelector('.taro_router') || document.querySelector('.taro-tabbar__panel') || document.body;
217
- }
218
- }, {
219
- key: "componentDidMount",
220
- value: function componentDidMount() {
221
- var _this2 = this;
222
- this.init();
223
- this._isMounted = true;
224
- this.listeners = [['__taroStartPullDownRefresh', function (_ref) {
225
- var successHandler = _ref.successHandler,
226
- errorHandler = _ref.errorHandler;
227
- try {
228
- _this2.triggerPullDownRefresh(true);
229
- successHandler({
230
- errMsg: 'startPullDownRefresh: ok'
231
- });
232
- } catch (e) {
233
- errorHandler({
234
- errMsg: 'startPullDownRefresh: fail'
235
- });
236
- }
237
- }], ['__taroStopPullDownRefresh', function (_ref2) {
238
- var successHandler = _ref2.successHandler,
239
- errorHandler = _ref2.errorHandler;
240
- try {
241
- _this2.triggerPullDownRefresh(false);
242
- successHandler({
243
- errMsg: 'stopPullDownRefresh: ok'
244
- });
245
- } catch (e) {
246
- errorHandler({
247
- errMsg: 'stopPullDownRefresh: fail'
248
- });
249
- }
250
- }]];
251
- this.listeners.forEach(function (_ref3) {
252
- var _ref4 = _slicedToArray(_ref3, 2),
253
- evtName = _ref4[0],
254
- callback = _ref4[1];
255
- Taro.eventCenter.on(evtName, callback);
256
- });
257
- }
258
- }, {
259
- key: "componentWillUnmount",
260
- value: function componentWillUnmount() {
261
- this.destroy();
262
- this.listeners.forEach(function (_ref5) {
263
- var _ref6 = _slicedToArray(_ref5, 2),
264
- evtName = _ref6[0],
265
- callback = _ref6[1];
266
- Taro.eventCenter.off(evtName, callback);
267
- });
268
- }
269
- }, {
270
- key: "componentDidUpdate",
271
- value: function componentDidUpdate(_, prevState) {
272
- var _a, _b, _c, _d;
273
- if (prevState.currSt !== this.state.currSt) {
274
- var pageEl = this.scrollContainer;
275
- switch (this.state.currSt) {
276
- case PullDownState.release:
277
- (_b = (_a = pageEl === null || pageEl === void 0 ? void 0 : pageEl.__page) === null || _a === void 0 ? void 0 : _a.onPullDownRefresh) === null || _b === void 0 ? void 0 : _b.call(_a);
278
- break;
279
- case PullDownState.deactivate:
280
- (_d = (_c = pageEl === null || pageEl === void 0 ? void 0 : pageEl.__page) === null || _c === void 0 ? void 0 : _c.onPullIntercept) === null || _d === void 0 ? void 0 : _d.call(_c);
281
- }
197
+ get scrollContainer() {
198
+ var _a, _b;
199
+ return ((_a = this.contentRef) === null || _a === void 0 ? void 0 : _a.parentElement) || ((_b = this.contentRef) === null || _b === void 0 ? void 0 : _b.closest('.taro_page_stationed')) || document.querySelector('.taro_page_stationed') || document.querySelector('.taro_page') || document.querySelector('.taro_router') || document.querySelector('.taro-tabbar__panel') || document.body;
200
+ }
201
+ componentDidMount() {
202
+ this.init();
203
+ this._isMounted = true;
204
+ this.listeners = [['__taroStartPullDownRefresh', _ref => {
205
+ let {
206
+ successHandler,
207
+ errorHandler
208
+ } = _ref;
209
+ try {
210
+ this.triggerPullDownRefresh(true);
211
+ successHandler({
212
+ errMsg: 'startPullDownRefresh: ok'
213
+ });
214
+ } catch (e) {
215
+ errorHandler({
216
+ errMsg: 'startPullDownRefresh: fail'
217
+ });
218
+ }
219
+ }], ['__taroStopPullDownRefresh', _ref2 => {
220
+ let {
221
+ successHandler,
222
+ errorHandler
223
+ } = _ref2;
224
+ try {
225
+ this.triggerPullDownRefresh(false);
226
+ successHandler({
227
+ errMsg: 'stopPullDownRefresh: ok'
228
+ });
229
+ } catch (e) {
230
+ errorHandler({
231
+ errMsg: 'stopPullDownRefresh: fail'
232
+ });
233
+ }
234
+ }]];
235
+ this.listeners.forEach(_ref3 => {
236
+ let [evtName, callback] = _ref3;
237
+ Taro.eventCenter.on(evtName, callback);
238
+ });
239
+ }
240
+ componentWillUnmount() {
241
+ this.destroy();
242
+ this.listeners.forEach(_ref4 => {
243
+ let [evtName, callback] = _ref4;
244
+ Taro.eventCenter.off(evtName, callback);
245
+ });
246
+ }
247
+ componentDidUpdate(_, prevState) {
248
+ var _a, _b, _c, _d;
249
+ if (prevState.currSt !== this.state.currSt) {
250
+ const pageEl = this.scrollContainer;
251
+ switch (this.state.currSt) {
252
+ case PullDownState.release:
253
+ (_b = (_a = pageEl === null || pageEl === void 0 ? void 0 : pageEl.__page) === null || _a === void 0 ? void 0 : _a.onPullDownRefresh) === null || _b === void 0 ? void 0 : _b.call(_a);
254
+ break;
255
+ case PullDownState.deactivate:
256
+ (_d = (_c = pageEl === null || pageEl === void 0 ? void 0 : pageEl.__page) === null || _c === void 0 ? void 0 : _c.onPullIntercept) === null || _d === void 0 ? void 0 : _d.call(_c);
282
257
  }
283
258
  }
284
- }, {
285
- key: "render",
286
- value: function render() {
287
- var _this3 = this;
288
- var props = Object.assign({}, this.props);
289
- delete props.damping;
290
- delete props.indicator;
291
- delete props.distanceToRefresh;
292
- delete props.onRefresh;
293
- var className = props.className,
294
- prefixCls = props.prefixCls,
295
- children = props.children,
296
- restProps = __rest(props, ["className", "prefixCls", "children"]);
297
- var renderRefresh = function renderRefresh(cls) {
298
- var _this3$state = _this3.state,
299
- currSt = _this3$state.currSt,
300
- dragOnEdge = _this3$state.dragOnEdge;
301
- var cla = classNames(cls, !dragOnEdge && "".concat(prefixCls, "-transition"));
302
- var showIndicator = currSt === 'activate' || currSt === 'release';
303
- return React.createElement("div", {
304
- className: "".concat(prefixCls, "-content-wrapper")
305
- }, React.createElement("div", {
259
+ }
260
+ render() {
261
+ const props = Object.assign({}, this.props);
262
+ delete props.damping;
263
+ delete props.indicator;
264
+ delete props.distanceToRefresh;
265
+ delete props.onRefresh;
266
+ const {
267
+ className,
268
+ prefixCls,
269
+ children
270
+ } = props,
271
+ restProps = __rest(props, ["className", "prefixCls", "children"]);
272
+ const renderRefresh = cls => {
273
+ const {
274
+ currSt,
275
+ dragOnEdge
276
+ } = this.state;
277
+ const cla = classNames(cls, !dragOnEdge && `${prefixCls}-transition`);
278
+ const showIndicator = currSt === 'activate' || currSt === 'release';
279
+ return /*#__PURE__*/jsx("div", {
280
+ className: `${prefixCls}-content-wrapper`,
281
+ children: /*#__PURE__*/jsxs("div", {
306
282
  className: cla,
307
- ref: function ref(el) {
308
- _this3.contentRef = el;
309
- }
310
- }, showIndicator && React.createElement("div", {
311
- className: "".concat(prefixCls, "-indicator")
312
- }, React.createElement("div", null), React.createElement("div", null), React.createElement("div", null)), children));
313
- };
314
- if (this.scrollContainer) {
315
- return renderRefresh("".concat(prefixCls, "-content ").concat(prefixCls, "-down"));
316
- }
317
- return React.createElement("pull-down-refresh", Object.assign({
318
- ref: function ref(el) {
319
- _this3.containerRef = el;
320
- },
321
- className: classNames(className, prefixCls, "".concat(prefixCls, "-down"))
322
- }, restProps), renderRefresh("".concat(prefixCls, "-content")));
283
+ ref: el => {
284
+ this.contentRef = el;
285
+ },
286
+ children: [showIndicator && /*#__PURE__*/jsxs("div", {
287
+ className: `${prefixCls}-indicator`,
288
+ children: [/*#__PURE__*/jsx("div", {}), /*#__PURE__*/jsx("div", {}), /*#__PURE__*/jsx("div", {})]
289
+ }), children]
290
+ })
291
+ });
292
+ };
293
+ if (this.scrollContainer) {
294
+ return renderRefresh(`${prefixCls}-content ${prefixCls}-down`);
323
295
  }
324
- }]);
325
- return PullDownRefresh;
326
- }(React.Component);
296
+ return /*#__PURE__*/jsx("pull-down-refresh", {
297
+ ref: el => {
298
+ this.containerRef = el;
299
+ },
300
+ className: classNames(className, prefixCls, `${prefixCls}-down`),
301
+ ...restProps,
302
+ children: renderRefresh(`${prefixCls}-content`)
303
+ });
304
+ }
305
+ }
327
306
  PullDownRefresh.defaultProps = {
328
307
  prefixCls: 'rmc-pull-to-refresh',
329
308
  distanceToRefresh: 50,