ns-base-module 1.1.72 → 1.1.73
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 +29 -6
- package/dist/Entry/components/Input.js +8 -5
- package/dist/Entry/components/index.scss +86 -0
- package/dist/FilterPopover/Filter.js +64 -39
- package/dist/FilterPopover/index.js +18 -12
- package/dist/Icon/antdIcon.js +1964 -0
- package/dist/Icon/index.js +564 -1
- package/dist/SubtotalsModal/index.js +0 -1
- package/dist/SubtotalsModal/subtotalTemplate.js +9 -11
- package/dist/TableHeaderConfigPopover/index.js +30 -27
- 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 +6 -2
- package/package.json +1 -1
- package/style/components/ClassFilter.scss +4 -4
- package/style/components/FilterPopover.scss +4 -0
- package/style/components/SubtotalsModal.scss +2 -56
- package/style/components/TableHeaderConfigPopover.scss +7 -56
- package/style/components/popoverBody.scss +54 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
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
|
-
var _excluded = ["menuCode", "formTemplateCode"]
|
|
2
|
+
var _excluded = ["menuCode", "formTemplateCode"],
|
|
3
|
+
_excluded2 = ["children"];
|
|
3
4
|
function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
|
|
4
5
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
5
6
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -30,7 +31,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
30
31
|
*/
|
|
31
32
|
// import { crossContext } from "@/my-context";
|
|
32
33
|
// import { initLang } from "@/utils/language";
|
|
33
|
-
import { CopyOutlined, DeleteOutlined, PlusOutlined, SettingOutlined
|
|
34
|
+
import { CopyOutlined, DeleteOutlined, PlusOutlined, SettingOutlined } from "@ant-design/icons";
|
|
34
35
|
import { Button, Checkbox, Input, message, Popconfirm, Popover, Radio, Tooltip, Tree } from "antd";
|
|
35
36
|
import { cloneDeep, get, isArray, isEmpty } from "lodash";
|
|
36
37
|
import React, { memo, useEffect, useMemo, useState } from "react";
|
|
@@ -38,6 +39,7 @@ import { DndProvider } from "react-dnd";
|
|
|
38
39
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
|
39
40
|
import Dustbin from "./Dustbin";
|
|
40
41
|
import "../../style/components/TableHeaderConfigPopover.scss";
|
|
42
|
+
import IconCreate from "../Icon";
|
|
41
43
|
import { initLang } from "../utils/language";
|
|
42
44
|
import { queryColumnsConfig, setFormTemplates } from "../utils/services/global";
|
|
43
45
|
import { adapterColumns, sortColums } from "./utils";
|
|
@@ -492,9 +494,8 @@ var ColumnsToolbarRender = /*#__PURE__*/memo(function (props) {
|
|
|
492
494
|
title: d.customizable === false ? d.title : /*#__PURE__*/React.createElement(Dustbin, {
|
|
493
495
|
item: d,
|
|
494
496
|
onChange: changeTableHeader,
|
|
495
|
-
onFixed: onFixed
|
|
496
|
-
|
|
497
|
-
,
|
|
497
|
+
onFixed: onFixed,
|
|
498
|
+
showArrows: showArrows,
|
|
498
499
|
onDrop: d.customizable === false ? null : onDrop // 子动态列 不能拖拽
|
|
499
500
|
}),
|
|
500
501
|
children: titleChildren(d.children, showArrows)
|
|
@@ -531,7 +532,7 @@ var ColumnsToolbarRender = /*#__PURE__*/memo(function (props) {
|
|
|
531
532
|
onChange: changeInput
|
|
532
533
|
}), /*#__PURE__*/React.createElement(Radio.Group, {
|
|
533
534
|
style: {
|
|
534
|
-
paddingTop:
|
|
535
|
+
paddingTop: 12
|
|
535
536
|
},
|
|
536
537
|
onChange: function onChange(e) {
|
|
537
538
|
setPermsType(e.target.value);
|
|
@@ -560,11 +561,7 @@ var ColumnsToolbarRender = /*#__PURE__*/memo(function (props) {
|
|
|
560
561
|
indeterminate: indeterminate,
|
|
561
562
|
onChange: selectAllChange,
|
|
562
563
|
className: "tree_selectall"
|
|
563
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
564
|
-
style: {
|
|
565
|
-
color: "#0273b0"
|
|
566
|
-
}
|
|
567
|
-
}, initLang({
|
|
564
|
+
}, /*#__PURE__*/React.createElement("span", null, initLang({
|
|
568
565
|
id: "app.search.modal.selectAll"
|
|
569
566
|
}))), !!leftFixed.length && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
570
567
|
className: "columns-fixed-title"
|
|
@@ -605,7 +602,7 @@ var ColumnsToolbarRender = /*#__PURE__*/memo(function (props) {
|
|
|
605
602
|
showLine: true,
|
|
606
603
|
rootStyle: {
|
|
607
604
|
overflowY: "auto",
|
|
608
|
-
maxHeight: "
|
|
605
|
+
maxHeight: "400px"
|
|
609
606
|
},
|
|
610
607
|
checkedKeys: flatColumns(unFixed, true).filter(function (col) {
|
|
611
608
|
return col.checked;
|
|
@@ -800,11 +797,11 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
800
797
|
}
|
|
801
798
|
if (item.is_default === "Y") {
|
|
802
799
|
hasDefault = true;
|
|
803
|
-
|
|
800
|
+
updateValue(item.value);
|
|
804
801
|
setCurItem(item);
|
|
805
802
|
}
|
|
806
803
|
if (item.is_default_public === "Y" && !hasDefault) {
|
|
807
|
-
|
|
804
|
+
updateValue(item.value);
|
|
808
805
|
setCurItem(item);
|
|
809
806
|
}
|
|
810
807
|
});
|
|
@@ -908,8 +905,13 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
908
905
|
return _ref7.apply(this, arguments);
|
|
909
906
|
};
|
|
910
907
|
}();
|
|
908
|
+
var updateValue = function updateValue(_value) {
|
|
909
|
+
var _props$onChange;
|
|
910
|
+
setValue(_value);
|
|
911
|
+
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, _value);
|
|
912
|
+
};
|
|
911
913
|
var onChange = function onChange(e) {
|
|
912
|
-
|
|
914
|
+
updateValue(e.target.value);
|
|
913
915
|
var arr = [].concat(_toConsumableArray(templateUser), _toConsumableArray(template));
|
|
914
916
|
arr.forEach(function (item) {
|
|
915
917
|
if (item.value === e.target.value) {
|
|
@@ -1001,7 +1003,7 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
1001
1003
|
|
|
1002
1004
|
// 取消选择 恢复默认
|
|
1003
1005
|
var cancelSelect = function cancelSelect() {
|
|
1004
|
-
|
|
1006
|
+
updateValue("");
|
|
1005
1007
|
setCurItem({});
|
|
1006
1008
|
restColumns("cancel");
|
|
1007
1009
|
};
|
|
@@ -1022,12 +1024,9 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
1022
1024
|
props.updateColumns(_columns);
|
|
1023
1025
|
};
|
|
1024
1026
|
return /*#__PURE__*/React.createElement("div", {
|
|
1025
|
-
className: "popover-body"
|
|
1026
|
-
style: {
|
|
1027
|
-
width: "500px"
|
|
1028
|
-
}
|
|
1027
|
+
className: "popover-body ".concat(showConfig ? "config-body" : "")
|
|
1029
1028
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1030
|
-
className: "top-wrap"
|
|
1029
|
+
className: "top-wrap "
|
|
1031
1030
|
}, /*#__PURE__*/React.createElement("span", {
|
|
1032
1031
|
className: "title"
|
|
1033
1032
|
}, initLang({
|
|
@@ -1067,7 +1066,8 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
1067
1066
|
}
|
|
1068
1067
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1069
1068
|
className: "list-title"
|
|
1070
|
-
}, /*#__PURE__*/React.createElement(
|
|
1069
|
+
}, /*#__PURE__*/React.createElement(IconCreate, {
|
|
1070
|
+
type: "icon-ns-gerenmoban",
|
|
1071
1071
|
className: "list-title-icon"
|
|
1072
1072
|
}), initLang({
|
|
1073
1073
|
id: "prompt.personalTemplate"
|
|
@@ -1117,7 +1117,8 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
1117
1117
|
}))));
|
|
1118
1118
|
})), /*#__PURE__*/React.createElement("div", {
|
|
1119
1119
|
className: "list-title"
|
|
1120
|
-
}, /*#__PURE__*/React.createElement(
|
|
1120
|
+
}, /*#__PURE__*/React.createElement(IconCreate, {
|
|
1121
|
+
type: "icon-ns-gonggongmoban",
|
|
1121
1122
|
className: "list-title-icon"
|
|
1122
1123
|
}), initLang({
|
|
1123
1124
|
id: "prompt.publicTemplate"
|
|
@@ -1178,10 +1179,10 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
1178
1179
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
1179
1180
|
style: {
|
|
1180
1181
|
position: "absolute",
|
|
1181
|
-
|
|
1182
|
+
left: 12,
|
|
1182
1183
|
bottom: 16
|
|
1183
1184
|
}
|
|
1184
|
-
}, (curItem === null || curItem === void 0 ? void 0 : curItem.perms_type)
|
|
1185
|
+
}, (curItem === null || curItem === void 0 ? void 0 : curItem.perms_type) !== "public" && /*#__PURE__*/React.createElement(React.Fragment, null, (curItem === null || curItem === void 0 ? void 0 : curItem.is_default) === "Y" ? /*#__PURE__*/React.createElement(Button, {
|
|
1185
1186
|
onClick: function onClick() {
|
|
1186
1187
|
return handleSaveDefault("N");
|
|
1187
1188
|
},
|
|
@@ -1228,6 +1229,8 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
1228
1229
|
};
|
|
1229
1230
|
var Index = function Index(_ref9) {
|
|
1230
1231
|
var props = Object.assign({}, (_objectDestructuringEmpty(_ref9), _ref9));
|
|
1232
|
+
var children = props.children,
|
|
1233
|
+
arg = _objectWithoutProperties(props, _excluded2);
|
|
1231
1234
|
useEffect(function () {
|
|
1232
1235
|
if (props.init) {
|
|
1233
1236
|
getColumnsFilter();
|
|
@@ -1289,8 +1292,8 @@ var Index = function Index(_ref9) {
|
|
|
1289
1292
|
placement: "bottomLeft",
|
|
1290
1293
|
trigger: "click",
|
|
1291
1294
|
title: "",
|
|
1292
|
-
content: /*#__PURE__*/React.createElement(ColumnsToolbar,
|
|
1293
|
-
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
1295
|
+
content: /*#__PURE__*/React.createElement(ColumnsToolbar, arg)
|
|
1296
|
+
}, children ? children : /*#__PURE__*/React.createElement(Tooltip, {
|
|
1294
1297
|
placement: "left",
|
|
1295
1298
|
title: initLang({
|
|
1296
1299
|
id: "prompt.setTemplate"
|
|
@@ -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'));
|