@alxgrn/telefrag-ui 0.0.47 → 0.0.51

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.
@@ -1,176 +0,0 @@
1
- import h, { Component as T } from "react";
2
- /*! *****************************************************************************
3
- Copyright (c) Microsoft Corporation. All rights reserved.
4
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
5
- this file except in compliance with the License. You may obtain a copy of the
6
- License at http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
10
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
11
- MERCHANTABLITY OR NON-INFRINGEMENT.
12
-
13
- See the Apache Version 2.0 License for specific language governing permissions
14
- and limitations under the License.
15
- ***************************************************************************** */
16
- var u = function(o, r) {
17
- return u = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, e) {
18
- t.__proto__ = e;
19
- } || function(t, e) {
20
- for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
21
- }, u(o, r);
22
- };
23
- function S(o, r) {
24
- u(o, r);
25
- function t() {
26
- this.constructor = o;
27
- }
28
- o.prototype = r === null ? Object.create(r) : (t.prototype = r.prototype, new t());
29
- }
30
- var a = function() {
31
- return a = Object.assign || function(r) {
32
- for (var t, e = 1, n = arguments.length; e < n; e++) {
33
- t = arguments[e];
34
- for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && (r[i] = t[i]);
35
- }
36
- return r;
37
- }, a.apply(this, arguments);
38
- };
39
- function _(o, r, t, e) {
40
- var n, i = !1, s = 0;
41
- function p() {
42
- n && clearTimeout(n);
43
- }
44
- function g() {
45
- p(), i = !0;
46
- }
47
- typeof r != "boolean" && (e = t, t = r, r = void 0);
48
- function f() {
49
- var w = this, d = Date.now() - s, E = arguments;
50
- if (i)
51
- return;
52
- function c() {
53
- s = Date.now(), t.apply(w, E);
54
- }
55
- function y() {
56
- n = void 0;
57
- }
58
- e && !n && c(), p(), e === void 0 && d > o ? c() : r !== !0 && (n = setTimeout(e ? y : c, e === void 0 ? o - d : o));
59
- }
60
- return f.cancel = g, f;
61
- }
62
- var l = {
63
- Pixel: "Pixel",
64
- Percent: "Percent"
65
- }, m = {
66
- unit: l.Percent,
67
- value: 0.8
68
- };
69
- function v(o) {
70
- return typeof o == "number" ? {
71
- unit: l.Percent,
72
- value: o * 100
73
- } : typeof o == "string" ? o.match(/^(\d*(\.\d+)?)px$/) ? {
74
- unit: l.Pixel,
75
- value: parseFloat(o)
76
- } : o.match(/^(\d*(\.\d+)?)%$/) ? {
77
- unit: l.Percent,
78
- value: parseFloat(o)
79
- } : (console.warn('scrollThreshold format is invalid. Valid formats: "120px", "50%"...'), m) : (console.warn("scrollThreshold should be string or number"), m);
80
- }
81
- var D = (
82
- /** @class */
83
- function(o) {
84
- S(r, o);
85
- function r(t) {
86
- var e = o.call(this, t) || this;
87
- return e.lastScrollTop = 0, e.actionTriggered = !1, e.startY = 0, e.currentY = 0, e.dragging = !1, e.maxPullDownDistance = 0, e.getScrollableTarget = function() {
88
- return e.props.scrollableTarget instanceof HTMLElement ? e.props.scrollableTarget : typeof e.props.scrollableTarget == "string" ? document.getElementById(e.props.scrollableTarget) : (e.props.scrollableTarget === null && console.warn(`You are trying to pass scrollableTarget but it is null. This might
89
- happen because the element may not have been added to DOM yet.
90
- See https://github.com/ankeetmaini/react-infinite-scroll-component/issues/59 for more info.
91
- `), null);
92
- }, e.onStart = function(n) {
93
- e.lastScrollTop || (e.dragging = !0, n instanceof MouseEvent ? e.startY = n.pageY : n instanceof TouchEvent && (e.startY = n.touches[0].pageY), e.currentY = e.startY, e._infScroll && (e._infScroll.style.willChange = "transform", e._infScroll.style.transition = "transform 0.2s cubic-bezier(0,0,0.31,1)"));
94
- }, e.onMove = function(n) {
95
- e.dragging && (n instanceof MouseEvent ? e.currentY = n.pageY : n instanceof TouchEvent && (e.currentY = n.touches[0].pageY), !(e.currentY < e.startY) && (e.currentY - e.startY >= Number(e.props.pullDownToRefreshThreshold) && e.setState({
96
- pullToRefreshThresholdBreached: !0
97
- }), !(e.currentY - e.startY > e.maxPullDownDistance * 1.5) && e._infScroll && (e._infScroll.style.overflow = "visible", e._infScroll.style.transform = "translate3d(0px, " + (e.currentY - e.startY) + "px, 0px)")));
98
- }, e.onEnd = function() {
99
- e.startY = 0, e.currentY = 0, e.dragging = !1, e.state.pullToRefreshThresholdBreached && (e.props.refreshFunction && e.props.refreshFunction(), e.setState({
100
- pullToRefreshThresholdBreached: !1
101
- })), requestAnimationFrame(function() {
102
- e._infScroll && (e._infScroll.style.overflow = "auto", e._infScroll.style.transform = "none", e._infScroll.style.willChange = "unset");
103
- });
104
- }, e.onScrollListener = function(n) {
105
- typeof e.props.onScroll == "function" && setTimeout(function() {
106
- return e.props.onScroll && e.props.onScroll(n);
107
- }, 0);
108
- var i = e.props.height || e._scrollableNode ? n.target : document.documentElement.scrollTop ? document.documentElement : document.body;
109
- if (!e.actionTriggered) {
110
- var s = e.props.inverse ? e.isElementAtTop(i, e.props.scrollThreshold) : e.isElementAtBottom(i, e.props.scrollThreshold);
111
- s && e.props.hasMore && (e.actionTriggered = !0, e.setState({ showLoader: !0 }), e.props.next && e.props.next()), e.lastScrollTop = i.scrollTop;
112
- }
113
- }, e.state = {
114
- showLoader: !1,
115
- pullToRefreshThresholdBreached: !1,
116
- prevDataLength: t.dataLength
117
- }, e.throttledOnScrollListener = _(150, e.onScrollListener).bind(e), e.onStart = e.onStart.bind(e), e.onMove = e.onMove.bind(e), e.onEnd = e.onEnd.bind(e), e;
118
- }
119
- return r.prototype.componentDidMount = function() {
120
- if (typeof this.props.dataLength > "u")
121
- throw new Error('mandatory prop "dataLength" is missing. The prop is needed when loading more content. Check README.md for usage');
122
- if (this._scrollableNode = this.getScrollableTarget(), this.el = this.props.height ? this._infScroll : this._scrollableNode || window, this.el && this.el.addEventListener("scroll", this.throttledOnScrollListener), typeof this.props.initialScrollY == "number" && this.el && this.el instanceof HTMLElement && this.el.scrollHeight > this.props.initialScrollY && this.el.scrollTo(0, this.props.initialScrollY), this.props.pullDownToRefresh && this.el && (this.el.addEventListener("touchstart", this.onStart), this.el.addEventListener("touchmove", this.onMove), this.el.addEventListener("touchend", this.onEnd), this.el.addEventListener("mousedown", this.onStart), this.el.addEventListener("mousemove", this.onMove), this.el.addEventListener("mouseup", this.onEnd), this.maxPullDownDistance = this._pullDown && this._pullDown.firstChild && this._pullDown.firstChild.getBoundingClientRect().height || 0, this.forceUpdate(), typeof this.props.refreshFunction != "function"))
123
- throw new Error(`Mandatory prop "refreshFunction" missing.
124
- Pull Down To Refresh functionality will not work
125
- as expected. Check README.md for usage'`);
126
- }, r.prototype.componentWillUnmount = function() {
127
- this.el && (this.el.removeEventListener("scroll", this.throttledOnScrollListener), this.props.pullDownToRefresh && (this.el.removeEventListener("touchstart", this.onStart), this.el.removeEventListener("touchmove", this.onMove), this.el.removeEventListener("touchend", this.onEnd), this.el.removeEventListener("mousedown", this.onStart), this.el.removeEventListener("mousemove", this.onMove), this.el.removeEventListener("mouseup", this.onEnd)));
128
- }, r.prototype.componentDidUpdate = function(t) {
129
- this.props.dataLength !== t.dataLength && (this.actionTriggered = !1, this.setState({
130
- showLoader: !1
131
- }));
132
- }, r.getDerivedStateFromProps = function(t, e) {
133
- var n = t.dataLength !== e.prevDataLength;
134
- return n ? a(a({}, e), { prevDataLength: t.dataLength }) : null;
135
- }, r.prototype.isElementAtTop = function(t, e) {
136
- e === void 0 && (e = 0.8);
137
- var n = t === document.body || t === document.documentElement ? window.screen.availHeight : t.clientHeight, i = v(e);
138
- return i.unit === l.Pixel ? t.scrollTop <= i.value + n - t.scrollHeight + 1 : t.scrollTop <= i.value / 100 + n - t.scrollHeight + 1;
139
- }, r.prototype.isElementAtBottom = function(t, e) {
140
- e === void 0 && (e = 0.8);
141
- var n = t === document.body || t === document.documentElement ? window.screen.availHeight : t.clientHeight, i = v(e);
142
- return i.unit === l.Pixel ? t.scrollTop + n >= t.scrollHeight - i.value : t.scrollTop + n >= i.value / 100 * t.scrollHeight;
143
- }, r.prototype.render = function() {
144
- var t = this, e = a({ height: this.props.height || "auto", overflow: "auto", WebkitOverflowScrolling: "touch" }, this.props.style), n = this.props.hasChildren || !!(this.props.children && this.props.children instanceof Array && this.props.children.length), i = this.props.pullDownToRefresh && this.props.height ? { overflow: "auto" } : {};
145
- return h.createElement(
146
- "div",
147
- { style: i, className: "infinite-scroll-component__outerdiv" },
148
- h.createElement(
149
- "div",
150
- { className: "infinite-scroll-component " + (this.props.className || ""), ref: function(s) {
151
- return t._infScroll = s;
152
- }, style: e },
153
- this.props.pullDownToRefresh && h.createElement(
154
- "div",
155
- { style: { position: "relative" }, ref: function(s) {
156
- return t._pullDown = s;
157
- } },
158
- h.createElement("div", { style: {
159
- position: "absolute",
160
- left: 0,
161
- right: 0,
162
- top: -1 * this.maxPullDownDistance
163
- } }, this.state.pullToRefreshThresholdBreached ? this.props.releaseToRefreshContent : this.props.pullDownToRefreshContent)
164
- ),
165
- this.props.children,
166
- !this.state.showLoader && !n && this.props.hasMore && this.props.loader,
167
- this.state.showLoader && this.props.hasMore && this.props.loader,
168
- !this.props.hasMore && this.props.endMessage
169
- )
170
- );
171
- }, r;
172
- }(T)
173
- );
174
- export {
175
- D as I
176
- };