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