ns-base-module 2.0.5 → 2.0.7
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/dist/CopyCol/index.js +58 -11
- package/dist/FilterPopover/Filter.js +67 -32
- package/dist/FilterPopover/index.js +4 -0
- package/dist/TableHeaderConfigPopover/Dustbin.js +13 -4
- package/dist/TableHeaderConfigPopover/index.js +132 -63
- package/dist/TableHeaderConfigPopover/utils.js +21 -4
- package/dist/scroll/index.js +281 -0
- package/dist/scroll/stories/InfiniteScrollWithHeight.js +84 -0
- package/dist/scroll/stories/PullDownToRefreshInfScroll.js +83 -0
- package/dist/scroll/stories/ScrollableTargetInfScroll.js +78 -0
- package/dist/scroll/stories/ScrolleableTop.js +86 -0
- package/dist/scroll/stories/WindowInfiniteScrollComponent.js +68 -0
- package/dist/scroll/stories/stories.js +43 -0
- package/dist/scroll/utils/threshold.js +34 -0
- package/dist/umd/ns-base-module.min.css +1 -1
- package/dist/umd/ns-base-module.min.js +1 -1
- package/dist/utils/language.js +2 -1
- package/package.json +1 -1
- package/style/components/FilterPopover.scss +4 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
8
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
9
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
11
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
12
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
+
import React, { Component } from "react";
|
|
18
|
+
import { throttle } from "throttle-debounce";
|
|
19
|
+
import { ThresholdUnits, parseThreshold } from "./utils/threshold";
|
|
20
|
+
var InfiniteScroll = /*#__PURE__*/function (_Component) {
|
|
21
|
+
_inherits(InfiniteScroll, _Component);
|
|
22
|
+
var _super = _createSuper(InfiniteScroll);
|
|
23
|
+
function InfiniteScroll(props) {
|
|
24
|
+
var _this;
|
|
25
|
+
_classCallCheck(this, InfiniteScroll);
|
|
26
|
+
_this = _super.call(this, props);
|
|
27
|
+
_defineProperty(_assertThisInitialized(_this), "throttledOnScrollListener", void 0);
|
|
28
|
+
_defineProperty(_assertThisInitialized(_this), "_scrollableNode", void 0);
|
|
29
|
+
_defineProperty(_assertThisInitialized(_this), "el", void 0);
|
|
30
|
+
_defineProperty(_assertThisInitialized(_this), "_infScroll", void 0);
|
|
31
|
+
_defineProperty(_assertThisInitialized(_this), "lastScrollTop", 0);
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "actionTriggered", false);
|
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "_pullDown", void 0);
|
|
34
|
+
// variables to keep track of pull down behaviour
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "startY", 0);
|
|
36
|
+
_defineProperty(_assertThisInitialized(_this), "currentY", 0);
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "dragging", false);
|
|
38
|
+
// will be populated in componentDidMount
|
|
39
|
+
// based on the height of the pull down element
|
|
40
|
+
_defineProperty(_assertThisInitialized(_this), "maxPullDownDistance", 0);
|
|
41
|
+
_defineProperty(_assertThisInitialized(_this), "getScrollableTarget", function () {
|
|
42
|
+
console.log("document.getElementById(this.props.scrollableTarget):", _this.props.scrollableTarget, document.getElementById(_this.props.scrollableTarget));
|
|
43
|
+
if (_this.props.scrollableTarget instanceof HTMLElement) return _this.props.scrollableTarget;
|
|
44
|
+
if (typeof _this.props.scrollableTarget === "string") {
|
|
45
|
+
return document.getElementById(_this.props.scrollableTarget);
|
|
46
|
+
}
|
|
47
|
+
if (_this.props.scrollableTarget === null) {
|
|
48
|
+
console.warn("You are trying to pass scrollableTarget but it is null. This might\n happen because the element may not have been added to DOM yet.\n See https://github.com/ankeetmaini/react-infinite-scroll-component/issues/59 for more info.\n ");
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
});
|
|
52
|
+
_defineProperty(_assertThisInitialized(_this), "onStart", function (evt) {
|
|
53
|
+
if (_this.lastScrollTop) return;
|
|
54
|
+
_this.dragging = true;
|
|
55
|
+
if (evt instanceof MouseEvent) {
|
|
56
|
+
_this.startY = evt.pageY;
|
|
57
|
+
} else if (evt instanceof TouchEvent) {
|
|
58
|
+
_this.startY = evt.touches[0].pageY;
|
|
59
|
+
}
|
|
60
|
+
_this.currentY = _this.startY;
|
|
61
|
+
if (_this._infScroll) {
|
|
62
|
+
_this._infScroll.style.willChange = "transform";
|
|
63
|
+
_this._infScroll.style.transition = "transform 0.2s cubic-bezier(0,0,0.31,1)";
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
_defineProperty(_assertThisInitialized(_this), "onMove", function (evt) {
|
|
67
|
+
if (!_this.dragging) return;
|
|
68
|
+
if (evt instanceof MouseEvent) {
|
|
69
|
+
_this.currentY = evt.pageY;
|
|
70
|
+
} else if (evt instanceof TouchEvent) {
|
|
71
|
+
_this.currentY = evt.touches[0].pageY;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// user is scrolling down to up
|
|
75
|
+
if (_this.currentY < _this.startY) return;
|
|
76
|
+
if (_this.currentY - _this.startY >= Number(_this.props.pullDownToRefreshThreshold)) {
|
|
77
|
+
_this.setState({
|
|
78
|
+
pullToRefreshThresholdBreached: true
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// so you can drag upto 1.5 times of the maxPullDownDistance
|
|
83
|
+
if (_this.currentY - _this.startY > _this.maxPullDownDistance * 1.5) return;
|
|
84
|
+
if (_this._infScroll) {
|
|
85
|
+
_this._infScroll.style.overflow = "visible";
|
|
86
|
+
_this._infScroll.style.transform = "translate3d(0px, ".concat(_this.currentY - _this.startY, "px, 0px)");
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
_defineProperty(_assertThisInitialized(_this), "onEnd", function () {
|
|
90
|
+
_this.startY = 0;
|
|
91
|
+
_this.currentY = 0;
|
|
92
|
+
_this.dragging = false;
|
|
93
|
+
if (_this.state.pullToRefreshThresholdBreached) {
|
|
94
|
+
_this.props.refreshFunction && _this.props.refreshFunction();
|
|
95
|
+
_this.setState({
|
|
96
|
+
pullToRefreshThresholdBreached: false
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
requestAnimationFrame(function () {
|
|
100
|
+
// this._infScroll
|
|
101
|
+
if (_this._infScroll) {
|
|
102
|
+
_this._infScroll.style.overflow = "auto";
|
|
103
|
+
_this._infScroll.style.transform = "none";
|
|
104
|
+
_this._infScroll.style.willChange = "unset";
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
_defineProperty(_assertThisInitialized(_this), "onScrollListener", function (event) {
|
|
109
|
+
debugger;
|
|
110
|
+
if (typeof _this.props.onScroll === "function") {
|
|
111
|
+
// Execute this callback in next tick so that it does not affect the
|
|
112
|
+
// functionality of the library.
|
|
113
|
+
setTimeout(function () {
|
|
114
|
+
return _this.props.onScroll && _this.props.onScroll(event);
|
|
115
|
+
}, 0);
|
|
116
|
+
}
|
|
117
|
+
var target = _this.props.height || _this._scrollableNode ? event.target : document.documentElement.scrollTop ? document.documentElement : document.body;
|
|
118
|
+
|
|
119
|
+
// return immediately if the action has already been triggered,
|
|
120
|
+
// prevents multiple triggers.
|
|
121
|
+
if (_this.actionTriggered) return;
|
|
122
|
+
var atBottom = _this.props.inverse ? _this.isElementAtTop(target, _this.props.scrollThreshold) : _this.isElementAtBottom(target, _this.props.scrollThreshold);
|
|
123
|
+
|
|
124
|
+
// call the `next` function in the props to trigger the next data fetch
|
|
125
|
+
if (atBottom && _this.props.hasMore) {
|
|
126
|
+
_this.actionTriggered = true;
|
|
127
|
+
_this.setState({
|
|
128
|
+
showLoader: true
|
|
129
|
+
});
|
|
130
|
+
_this.props.next && _this.props.next();
|
|
131
|
+
}
|
|
132
|
+
_this.lastScrollTop = target.scrollTop;
|
|
133
|
+
});
|
|
134
|
+
_this.state = {
|
|
135
|
+
showLoader: false,
|
|
136
|
+
pullToRefreshThresholdBreached: false,
|
|
137
|
+
prevDataLength: props.dataLength
|
|
138
|
+
};
|
|
139
|
+
_this.throttledOnScrollListener = throttle(150, _this.onScrollListener).bind(_assertThisInitialized(_this));
|
|
140
|
+
_this.onStart = _this.onStart.bind(_assertThisInitialized(_this));
|
|
141
|
+
_this.onMove = _this.onMove.bind(_assertThisInitialized(_this));
|
|
142
|
+
_this.onEnd = _this.onEnd.bind(_assertThisInitialized(_this));
|
|
143
|
+
return _this;
|
|
144
|
+
}
|
|
145
|
+
_createClass(InfiniteScroll, [{
|
|
146
|
+
key: "componentDidMount",
|
|
147
|
+
value: function componentDidMount() {
|
|
148
|
+
if (typeof this.props.dataLength === "undefined") {
|
|
149
|
+
throw new Error("mandatory prop \"dataLength\" is missing. The prop is needed" + " when loading more content. Check README.md for usage");
|
|
150
|
+
}
|
|
151
|
+
this._scrollableNode = this.getScrollableTarget();
|
|
152
|
+
this.el = this.props.height ? this._infScroll : this._scrollableNode || window;
|
|
153
|
+
if (this.el) {
|
|
154
|
+
this.el.addEventListener("scroll", this.throttledOnScrollListener);
|
|
155
|
+
}
|
|
156
|
+
if (typeof this.props.initialScrollY === "number" && this.el && this.el instanceof HTMLElement && this.el.scrollHeight > this.props.initialScrollY) {
|
|
157
|
+
this.el.scrollTo(0, this.props.initialScrollY);
|
|
158
|
+
}
|
|
159
|
+
if (this.props.pullDownToRefresh && this.el) {
|
|
160
|
+
this.el.addEventListener("touchstart", this.onStart);
|
|
161
|
+
this.el.addEventListener("touchmove", this.onMove);
|
|
162
|
+
this.el.addEventListener("touchend", this.onEnd);
|
|
163
|
+
this.el.addEventListener("mousedown", this.onStart);
|
|
164
|
+
this.el.addEventListener("mousemove", this.onMove);
|
|
165
|
+
this.el.addEventListener("mouseup", this.onEnd);
|
|
166
|
+
|
|
167
|
+
// get BCR of pullDown element to position it above
|
|
168
|
+
this.maxPullDownDistance = this._pullDown && this._pullDown.firstChild && this._pullDown.firstChild.getBoundingClientRect().height || 0;
|
|
169
|
+
this.forceUpdate();
|
|
170
|
+
if (typeof this.props.refreshFunction !== "function") {
|
|
171
|
+
throw new Error("Mandatory prop \"refreshFunction\" missing.\n Pull Down To Refresh functionality will not work\n as expected. Check README.md for usage'");
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}, {
|
|
176
|
+
key: "componentWillUnmount",
|
|
177
|
+
value: function componentWillUnmount() {
|
|
178
|
+
if (this.el) {
|
|
179
|
+
this.el.removeEventListener("scroll", this.throttledOnScrollListener);
|
|
180
|
+
if (this.props.pullDownToRefresh) {
|
|
181
|
+
this.el.removeEventListener("touchstart", this.onStart);
|
|
182
|
+
this.el.removeEventListener("touchmove", this.onMove);
|
|
183
|
+
this.el.removeEventListener("touchend", this.onEnd);
|
|
184
|
+
this.el.removeEventListener("mousedown", this.onStart);
|
|
185
|
+
this.el.removeEventListener("mousemove", this.onMove);
|
|
186
|
+
this.el.removeEventListener("mouseup", this.onEnd);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
key: "componentDidUpdate",
|
|
192
|
+
value: function componentDidUpdate(prevProps) {
|
|
193
|
+
// do nothing when dataLength is unchanged
|
|
194
|
+
if (this.props.dataLength === prevProps.dataLength) return;
|
|
195
|
+
this.actionTriggered = false;
|
|
196
|
+
|
|
197
|
+
// update state when new data was sent in
|
|
198
|
+
this.setState({
|
|
199
|
+
showLoader: false
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}, {
|
|
203
|
+
key: "isElementAtTop",
|
|
204
|
+
value: function isElementAtTop(target) {
|
|
205
|
+
var scrollThreshold = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.8;
|
|
206
|
+
var clientHeight = target === document.body || target === document.documentElement ? window.screen.availHeight : target.clientHeight;
|
|
207
|
+
var threshold = parseThreshold(scrollThreshold);
|
|
208
|
+
if (threshold.unit === ThresholdUnits.Pixel) {
|
|
209
|
+
return target.scrollTop <= threshold.value + clientHeight - target.scrollHeight + 1;
|
|
210
|
+
}
|
|
211
|
+
return target.scrollTop <= threshold.value / 100 + clientHeight - target.scrollHeight + 1;
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
214
|
+
key: "isElementAtBottom",
|
|
215
|
+
value: function isElementAtBottom(target) {
|
|
216
|
+
var scrollThreshold = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.8;
|
|
217
|
+
var clientHeight = target === document.body || target === document.documentElement ? window.screen.availHeight : target.clientHeight;
|
|
218
|
+
var threshold = parseThreshold(scrollThreshold);
|
|
219
|
+
if (threshold.unit === ThresholdUnits.Pixel) {
|
|
220
|
+
return target.scrollTop + clientHeight >= target.scrollHeight - threshold.value;
|
|
221
|
+
}
|
|
222
|
+
return target.scrollTop + clientHeight >= threshold.value / 100 * target.scrollHeight;
|
|
223
|
+
}
|
|
224
|
+
}, {
|
|
225
|
+
key: "render",
|
|
226
|
+
value: function render() {
|
|
227
|
+
var _this2 = this;
|
|
228
|
+
var style = _objectSpread({
|
|
229
|
+
height: this.props.height || "auto",
|
|
230
|
+
overflow: "auto",
|
|
231
|
+
WebkitOverflowScrolling: "touch"
|
|
232
|
+
}, this.props.style);
|
|
233
|
+
var hasChildren = this.props.hasChildren || !!(this.props.children && this.props.children instanceof Array && this.props.children.length);
|
|
234
|
+
|
|
235
|
+
// because heighted infiniteScroll visualy breaks
|
|
236
|
+
// on drag down as overflow becomes visible
|
|
237
|
+
var outerDivStyle = this.props.pullDownToRefresh && this.props.height ? {
|
|
238
|
+
overflow: "auto"
|
|
239
|
+
} : {};
|
|
240
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
241
|
+
style: outerDivStyle,
|
|
242
|
+
className: "infinite-scroll-component__outerdiv"
|
|
243
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
244
|
+
className: "infinite-scroll-component ".concat(this.props.className || ""),
|
|
245
|
+
ref: function ref(infScroll) {
|
|
246
|
+
return _this2._infScroll = infScroll;
|
|
247
|
+
},
|
|
248
|
+
style: style
|
|
249
|
+
}, this.props.pullDownToRefresh && /*#__PURE__*/React.createElement("div", {
|
|
250
|
+
style: {
|
|
251
|
+
position: "relative"
|
|
252
|
+
},
|
|
253
|
+
ref: function ref(pullDown) {
|
|
254
|
+
return _this2._pullDown = pullDown;
|
|
255
|
+
}
|
|
256
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
257
|
+
style: {
|
|
258
|
+
position: "absolute",
|
|
259
|
+
left: 0,
|
|
260
|
+
right: 0,
|
|
261
|
+
top: -1 * this.maxPullDownDistance
|
|
262
|
+
}
|
|
263
|
+
}, this.state.pullToRefreshThresholdBreached ? this.props.releaseToRefreshContent : this.props.pullDownToRefreshContent)), this.props.children, !this.state.showLoader && !hasChildren && this.props.hasMore && this.props.loader, this.state.showLoader && this.props.hasMore && this.props.loader, !this.props.hasMore && this.props.endMessage));
|
|
264
|
+
}
|
|
265
|
+
}], [{
|
|
266
|
+
key: "getDerivedStateFromProps",
|
|
267
|
+
value: function getDerivedStateFromProps(nextProps, prevState) {
|
|
268
|
+
var dataLengthChanged = nextProps.dataLength !== prevState.prevDataLength;
|
|
269
|
+
|
|
270
|
+
// reset when data changes
|
|
271
|
+
if (dataLengthChanged) {
|
|
272
|
+
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
273
|
+
prevDataLength: nextProps.dataLength
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
}]);
|
|
279
|
+
return InfiniteScroll;
|
|
280
|
+
}(Component);
|
|
281
|
+
export { InfiniteScroll as default };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
6
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
7
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
9
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
10
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
import React from 'react';
|
|
16
|
+
import { render } from 'react-dom';
|
|
17
|
+
import InfiniteScroll from "../index";
|
|
18
|
+
var style = {
|
|
19
|
+
height: 30,
|
|
20
|
+
border: '1px solid green',
|
|
21
|
+
margin: 6,
|
|
22
|
+
padding: 8
|
|
23
|
+
};
|
|
24
|
+
var App = /*#__PURE__*/function (_React$Component) {
|
|
25
|
+
_inherits(App, _React$Component);
|
|
26
|
+
var _super = _createSuper(App);
|
|
27
|
+
function App() {
|
|
28
|
+
var _this;
|
|
29
|
+
_classCallCheck(this, App);
|
|
30
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
31
|
+
args[_key] = arguments[_key];
|
|
32
|
+
}
|
|
33
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
35
|
+
items: Array.from({
|
|
36
|
+
length: 20
|
|
37
|
+
}),
|
|
38
|
+
hasMore: true
|
|
39
|
+
});
|
|
40
|
+
_defineProperty(_assertThisInitialized(_this), "fetchMoreData", function () {
|
|
41
|
+
if (_this.state.items.length >= 500) {
|
|
42
|
+
_this.setState({
|
|
43
|
+
hasMore: false
|
|
44
|
+
});
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// a fake async api call like which sends
|
|
48
|
+
// 20 more records in .5 secs
|
|
49
|
+
setTimeout(function () {
|
|
50
|
+
_this.setState({
|
|
51
|
+
items: _this.state.items.concat(Array.from({
|
|
52
|
+
length: 20
|
|
53
|
+
}))
|
|
54
|
+
});
|
|
55
|
+
}, 500);
|
|
56
|
+
});
|
|
57
|
+
return _this;
|
|
58
|
+
}
|
|
59
|
+
_createClass(App, [{
|
|
60
|
+
key: "render",
|
|
61
|
+
value: function render() {
|
|
62
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h1", null, "demo: Infinite Scroll with fixed height"), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement(InfiniteScroll, {
|
|
63
|
+
dataLength: this.state.items.length,
|
|
64
|
+
next: this.fetchMoreData,
|
|
65
|
+
hasMore: this.state.hasMore,
|
|
66
|
+
loader: /*#__PURE__*/React.createElement("h4", null, "Loading..."),
|
|
67
|
+
height: 400,
|
|
68
|
+
endMessage: /*#__PURE__*/React.createElement("p", {
|
|
69
|
+
style: {
|
|
70
|
+
textAlign: 'center'
|
|
71
|
+
}
|
|
72
|
+
}, /*#__PURE__*/React.createElement("b", null, "Yay! You have seen it all"))
|
|
73
|
+
}, this.state.items.map(function (_, index) {
|
|
74
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
style: style,
|
|
76
|
+
key: index
|
|
77
|
+
}, "div - #", index);
|
|
78
|
+
})));
|
|
79
|
+
}
|
|
80
|
+
}]);
|
|
81
|
+
return App;
|
|
82
|
+
}(React.Component);
|
|
83
|
+
export { App as default };
|
|
84
|
+
render( /*#__PURE__*/React.createElement(App, null), document.getElementById('root'));
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
6
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
7
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
9
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
10
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
import React from 'react';
|
|
16
|
+
import { render } from 'react-dom';
|
|
17
|
+
import InfiniteScroll from "../index";
|
|
18
|
+
var style = {
|
|
19
|
+
height: 30,
|
|
20
|
+
border: '1px solid green',
|
|
21
|
+
margin: 6,
|
|
22
|
+
padding: 8
|
|
23
|
+
};
|
|
24
|
+
var App = /*#__PURE__*/function (_React$Component) {
|
|
25
|
+
_inherits(App, _React$Component);
|
|
26
|
+
var _super = _createSuper(App);
|
|
27
|
+
function App() {
|
|
28
|
+
var _this;
|
|
29
|
+
_classCallCheck(this, App);
|
|
30
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
31
|
+
args[_key] = arguments[_key];
|
|
32
|
+
}
|
|
33
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
35
|
+
items: Array.from({
|
|
36
|
+
length: 20
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
_defineProperty(_assertThisInitialized(_this), "fetchMoreData", function () {
|
|
40
|
+
// a fake async api call like which sends
|
|
41
|
+
// 20 more records in 1.5 secs
|
|
42
|
+
setTimeout(function () {
|
|
43
|
+
_this.setState({
|
|
44
|
+
items: _this.state.items.concat(Array.from({
|
|
45
|
+
length: 20
|
|
46
|
+
}))
|
|
47
|
+
});
|
|
48
|
+
}, 1500);
|
|
49
|
+
});
|
|
50
|
+
return _this;
|
|
51
|
+
}
|
|
52
|
+
_createClass(App, [{
|
|
53
|
+
key: "render",
|
|
54
|
+
value: function render() {
|
|
55
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h1", null, "demo: Pull down to refresh"), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement(InfiniteScroll, {
|
|
56
|
+
dataLength: this.state.items.length,
|
|
57
|
+
next: this.fetchMoreData,
|
|
58
|
+
hasMore: true,
|
|
59
|
+
loader: /*#__PURE__*/React.createElement("h4", null, "Loading..."),
|
|
60
|
+
pullDownToRefresh: true,
|
|
61
|
+
pullDownToRefreshContent: /*#__PURE__*/React.createElement("h3", {
|
|
62
|
+
style: {
|
|
63
|
+
textAlign: 'center'
|
|
64
|
+
}
|
|
65
|
+
}, "\u2193 Pull down to refresh"),
|
|
66
|
+
releaseToRefreshContent: /*#__PURE__*/React.createElement("h3", {
|
|
67
|
+
style: {
|
|
68
|
+
textAlign: 'center'
|
|
69
|
+
}
|
|
70
|
+
}, "\u2191 Release to refresh"),
|
|
71
|
+
refreshFunction: this.fetchMoreData
|
|
72
|
+
}, this.state.items.map(function (_, index) {
|
|
73
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
74
|
+
style: style,
|
|
75
|
+
key: index
|
|
76
|
+
}, "div - #", index);
|
|
77
|
+
})));
|
|
78
|
+
}
|
|
79
|
+
}]);
|
|
80
|
+
return App;
|
|
81
|
+
}(React.Component);
|
|
82
|
+
export { App as default };
|
|
83
|
+
render( /*#__PURE__*/React.createElement(App, null), document.getElementById('root'));
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
6
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
7
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
9
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
10
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
import React from 'react';
|
|
16
|
+
import { render } from 'react-dom';
|
|
17
|
+
import InfiniteScroll from "../index";
|
|
18
|
+
var style = {
|
|
19
|
+
height: 30,
|
|
20
|
+
border: '1px solid green',
|
|
21
|
+
margin: 6,
|
|
22
|
+
padding: 8
|
|
23
|
+
};
|
|
24
|
+
var App = /*#__PURE__*/function (_React$Component) {
|
|
25
|
+
_inherits(App, _React$Component);
|
|
26
|
+
var _super = _createSuper(App);
|
|
27
|
+
function App() {
|
|
28
|
+
var _this;
|
|
29
|
+
_classCallCheck(this, App);
|
|
30
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
31
|
+
args[_key] = arguments[_key];
|
|
32
|
+
}
|
|
33
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
35
|
+
items: Array.from({
|
|
36
|
+
length: 20
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
_defineProperty(_assertThisInitialized(_this), "fetchMoreData", function () {
|
|
40
|
+
// a fake async api call like which sends
|
|
41
|
+
// 20 more records in 1.5 secs
|
|
42
|
+
setTimeout(function () {
|
|
43
|
+
_this.setState({
|
|
44
|
+
items: _this.state.items.concat(Array.from({
|
|
45
|
+
length: 20
|
|
46
|
+
}))
|
|
47
|
+
});
|
|
48
|
+
}, 1500);
|
|
49
|
+
});
|
|
50
|
+
return _this;
|
|
51
|
+
}
|
|
52
|
+
_createClass(App, [{
|
|
53
|
+
key: "render",
|
|
54
|
+
value: function render() {
|
|
55
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h1", null, "demo: Infinite Scroll with scrollable target"), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
id: "scrollableDiv",
|
|
57
|
+
style: {
|
|
58
|
+
height: 300,
|
|
59
|
+
overflow: 'auto'
|
|
60
|
+
}
|
|
61
|
+
}, /*#__PURE__*/React.createElement(InfiniteScroll, {
|
|
62
|
+
dataLength: this.state.items.length,
|
|
63
|
+
next: this.fetchMoreData,
|
|
64
|
+
hasMore: true,
|
|
65
|
+
loader: /*#__PURE__*/React.createElement("h4", null, "Loading..."),
|
|
66
|
+
scrollableTarget: "scrollableDiv"
|
|
67
|
+
}, this.state.items.map(function (_, index) {
|
|
68
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
69
|
+
style: style,
|
|
70
|
+
key: index
|
|
71
|
+
}, "div - #", index);
|
|
72
|
+
}))));
|
|
73
|
+
}
|
|
74
|
+
}]);
|
|
75
|
+
return App;
|
|
76
|
+
}(React.Component);
|
|
77
|
+
export { App as default };
|
|
78
|
+
render( /*#__PURE__*/React.createElement(App, null), document.getElementById('root'));
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
6
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
7
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
9
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
10
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
import React from 'react';
|
|
16
|
+
import { render } from 'react-dom';
|
|
17
|
+
import InfiniteScroll from "../index";
|
|
18
|
+
var style = {
|
|
19
|
+
height: 30,
|
|
20
|
+
border: '1px solid green',
|
|
21
|
+
margin: 6,
|
|
22
|
+
padding: 8
|
|
23
|
+
};
|
|
24
|
+
var App = /*#__PURE__*/function (_React$Component) {
|
|
25
|
+
_inherits(App, _React$Component);
|
|
26
|
+
var _super = _createSuper(App);
|
|
27
|
+
function App() {
|
|
28
|
+
var _this;
|
|
29
|
+
_classCallCheck(this, App);
|
|
30
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
31
|
+
args[_key] = arguments[_key];
|
|
32
|
+
}
|
|
33
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
35
|
+
items: Array.from({
|
|
36
|
+
length: 20
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
_defineProperty(_assertThisInitialized(_this), "fetchMoreData", function () {
|
|
40
|
+
// a fake async api call like which sends
|
|
41
|
+
// 20 more records in 1.5 secs
|
|
42
|
+
setTimeout(function () {
|
|
43
|
+
_this.setState({
|
|
44
|
+
items: _this.state.items.concat(Array.from({
|
|
45
|
+
length: 20
|
|
46
|
+
}))
|
|
47
|
+
});
|
|
48
|
+
}, 1500);
|
|
49
|
+
});
|
|
50
|
+
return _this;
|
|
51
|
+
}
|
|
52
|
+
_createClass(App, [{
|
|
53
|
+
key: "render",
|
|
54
|
+
value: function render() {
|
|
55
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h1", null, "demo: Infinite Scroll on top"), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
id: "scrollableDiv",
|
|
57
|
+
style: {
|
|
58
|
+
height: 300,
|
|
59
|
+
overflow: 'auto',
|
|
60
|
+
display: 'flex',
|
|
61
|
+
flexDirection: 'column-reverse'
|
|
62
|
+
}
|
|
63
|
+
}, /*#__PURE__*/React.createElement(InfiniteScroll, {
|
|
64
|
+
dataLength: this.state.items.length,
|
|
65
|
+
next: this.fetchMoreData,
|
|
66
|
+
style: {
|
|
67
|
+
display: 'flex',
|
|
68
|
+
flexDirection: 'column-reverse'
|
|
69
|
+
} //To put endMessage and loader to the top.
|
|
70
|
+
,
|
|
71
|
+
inverse: true,
|
|
72
|
+
hasMore: true,
|
|
73
|
+
loader: /*#__PURE__*/React.createElement("h4", null, "Loading..."),
|
|
74
|
+
scrollableTarget: "scrollableDiv"
|
|
75
|
+
}, this.state.items.map(function (_, index) {
|
|
76
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
77
|
+
style: style,
|
|
78
|
+
key: index
|
|
79
|
+
}, "div - #", index);
|
|
80
|
+
}))));
|
|
81
|
+
}
|
|
82
|
+
}]);
|
|
83
|
+
return App;
|
|
84
|
+
}(React.Component);
|
|
85
|
+
export { App as default };
|
|
86
|
+
render( /*#__PURE__*/React.createElement(App, null), document.getElementById('root'));
|