@deskpro/deskpro-ui 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Infinite/Infinite.js +116 -61
- package/dist/cjs/components/Infinite/Infinite.js.map +1 -1
- package/dist/cjs/components/Infinite/ObservedDiv.js +2 -2
- package/dist/cjs/components/Infinite/ObservedDiv.js.map +1 -1
- package/dist/cjs/components/Infinite/styles.js.map +1 -1
- package/dist/cjs/utils/useInView.js +27 -0
- package/dist/cjs/utils/useInView.js.map +1 -0
- package/dist/deskpro-ui.d.ts +6 -2
- package/dist/esm/components/Infinite/Infinite.js +117 -62
- package/dist/esm/components/Infinite/Infinite.js.map +1 -1
- package/dist/esm/components/Infinite/ObservedDiv.js +2 -2
- package/dist/esm/components/Infinite/ObservedDiv.js.map +1 -1
- package/dist/esm/components/Infinite/styles.js.map +1 -1
- package/dist/esm/utils/useInView.js +25 -0
- package/dist/esm/utils/useInView.js.map +1 -0
- package/package.json +2 -1
|
@@ -5,7 +5,7 @@ const React = require("react");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const use_debounce_1 = require("use-debounce");
|
|
7
7
|
const layout_1 = require("../../layout");
|
|
8
|
-
const
|
|
8
|
+
const styles_1 = require("./styles");
|
|
9
9
|
const Spinner_1 = require("../Spinner");
|
|
10
10
|
const Button_1 = require("../Button");
|
|
11
11
|
const ts_pattern_1 = require("ts-pattern");
|
|
@@ -13,10 +13,10 @@ const Scrollbar_1 = require("../Scrollbar");
|
|
|
13
13
|
const free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
|
|
14
14
|
const styled_components_1 = require("styled-components");
|
|
15
15
|
const dpName_1 = require("../../utils/dpName");
|
|
16
|
+
const useInView_1 = require("../../utils/useInView");
|
|
17
|
+
const react_resize_observer_1 = require("react-resize-observer");
|
|
16
18
|
// Controls the scroll when the data changes and for user wheel events
|
|
17
|
-
function useScrollControl(
|
|
18
|
-
const innerRef = (0, react_1.useRef)(null);
|
|
19
|
-
const ref = outerRef !== null && outerRef !== void 0 ? outerRef : innerRef;
|
|
19
|
+
function useScrollControl(lastFetchDirection, scrollRef, reverse, anchor, scrollSideEffect, topStatus) {
|
|
20
20
|
const firstMount = (0, react_1.useRef)(true);
|
|
21
21
|
// Used to check if the scroll should be forced to the edges on data updates
|
|
22
22
|
const shouldAttachScroll = (0, react_1.useRef)(true);
|
|
@@ -24,59 +24,74 @@ function useScrollControl(children, reverse, anchor, scrollSideEffect, outerRef)
|
|
|
24
24
|
const lastKnownScrollOffset = (0, react_1.useRef)();
|
|
25
25
|
// Forces the scrollbar to the top or bottom on first render
|
|
26
26
|
(0, react_1.useEffect)(() => {
|
|
27
|
-
if (
|
|
27
|
+
if ((scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) && shouldAttachScroll.current) {
|
|
28
28
|
if (reverse) {
|
|
29
|
-
|
|
29
|
+
scrollRef.current.scrollTo({
|
|
30
|
+
top: scrollRef.current.scrollHeight - scrollRef.current.clientHeight - 4,
|
|
31
|
+
});
|
|
30
32
|
}
|
|
31
33
|
else {
|
|
32
|
-
|
|
34
|
+
scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.scrollTo({ top: 4 });
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
|
-
}, [
|
|
37
|
+
}, [reverse, scrollRef]);
|
|
38
|
+
// this will update the scroll position when a fetch has been made while scrolling up
|
|
39
|
+
// this is to stop the page jumping once a request has been made
|
|
40
|
+
const setScrollTo = (0, react_1.useCallback)(() => {
|
|
41
|
+
var _a, _b, _c;
|
|
42
|
+
if (!shouldAttachScroll.current &&
|
|
43
|
+
typeof lastKnownScrollOffset.current === "number" &&
|
|
44
|
+
lastFetchDirection === "top" &&
|
|
45
|
+
topStatus !== "end" &&
|
|
46
|
+
topStatus !== "end-with-force") {
|
|
47
|
+
// set position using saved offset
|
|
48
|
+
(_a = scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
|
|
49
|
+
top: Math.abs(lastKnownScrollOffset.current -
|
|
50
|
+
(((_b = scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) === null || _b === void 0 ? void 0 : _b.scrollHeight) - ((_c = scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight))),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// save current position offset
|
|
54
|
+
if (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) {
|
|
55
|
+
lastKnownScrollOffset.current = Math.abs((scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.scrollTop) -
|
|
56
|
+
((scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.scrollHeight) - (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.clientHeight)));
|
|
57
|
+
}
|
|
58
|
+
}, [lastFetchDirection, scrollRef, topStatus]);
|
|
36
59
|
// On render will force the scroll bar to the top or bottom, unless detached
|
|
37
60
|
(0, react_1.useLayoutEffect)(() => {
|
|
38
61
|
if (firstMount.current || !anchor) {
|
|
39
62
|
firstMount.current = false;
|
|
40
63
|
return;
|
|
41
64
|
}
|
|
42
|
-
if (!
|
|
65
|
+
if (!(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current))
|
|
43
66
|
return;
|
|
44
|
-
|
|
45
|
-
if (reverse) {
|
|
46
|
-
ref.current.scrollTo({ top: ref.current.scrollHeight });
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
ref.current.scrollTo({ top: 0 });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else if (typeof lastKnownScrollOffset.current === "number" && reverse) {
|
|
53
|
-
ref.current.scrollTo({
|
|
54
|
-
top: Math.abs(lastKnownScrollOffset.current - (ref.current.scrollHeight - ref.current.clientHeight)),
|
|
55
|
-
});
|
|
56
|
-
}
|
|
67
|
+
setScrollTo();
|
|
57
68
|
});
|
|
58
69
|
const debouncedSetIsAttached = (0, use_debounce_1.useDebouncedCallback)(() => {
|
|
59
|
-
if (typeof lastKnownScrollOffset.current === "number" &&
|
|
70
|
+
if (typeof lastKnownScrollOffset.current === "number" && (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
|
|
60
71
|
if (shouldAttachScroll.current !== isAttached && lastKnownScrollOffset.current > 300) {
|
|
61
72
|
setIsAttached(shouldAttachScroll.current);
|
|
62
73
|
}
|
|
63
74
|
else if (shouldAttachScroll.current !== isAttached &&
|
|
64
|
-
lastKnownScrollOffset.current
|
|
75
|
+
lastKnownScrollOffset.current <= 10) {
|
|
65
76
|
setIsAttached(shouldAttachScroll.current);
|
|
66
77
|
}
|
|
67
78
|
}
|
|
68
79
|
}, 100, { trailing: true, leading: true });
|
|
69
80
|
// On scroll events will attach or detach the scroll position from the top or bottom
|
|
70
|
-
const handleScroll = (0, react_1.useCallback)(() => {
|
|
71
|
-
if (
|
|
81
|
+
const handleScroll = (0, react_1.useCallback)((event) => {
|
|
82
|
+
if ((scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) &&
|
|
72
83
|
!isAttached &&
|
|
73
|
-
|
|
84
|
+
scrollRef.current.scrollTop + scrollRef.current.offsetHeight >
|
|
85
|
+
scrollRef.current.scrollHeight - 2) {
|
|
74
86
|
setIsAttached(true);
|
|
75
87
|
}
|
|
76
|
-
if (!
|
|
88
|
+
if (!(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
|
|
89
|
+
scrollSideEffect === null || scrollSideEffect === void 0 ? void 0 : scrollSideEffect(event);
|
|
77
90
|
return;
|
|
91
|
+
}
|
|
78
92
|
if (reverse) {
|
|
79
|
-
if (
|
|
93
|
+
if (scrollRef.current.scrollTop <
|
|
94
|
+
scrollRef.current.scrollHeight - scrollRef.current.clientHeight) {
|
|
80
95
|
shouldAttachScroll.current = false;
|
|
81
96
|
}
|
|
82
97
|
else {
|
|
@@ -84,71 +99,111 @@ function useScrollControl(children, reverse, anchor, scrollSideEffect, outerRef)
|
|
|
84
99
|
}
|
|
85
100
|
}
|
|
86
101
|
else {
|
|
87
|
-
if (
|
|
102
|
+
if (scrollRef.current.scrollTop > 0) {
|
|
88
103
|
shouldAttachScroll.current = false;
|
|
89
104
|
}
|
|
90
105
|
else {
|
|
91
106
|
shouldAttachScroll.current = true;
|
|
92
107
|
}
|
|
93
108
|
}
|
|
94
|
-
|
|
95
|
-
|
|
109
|
+
setScrollTo();
|
|
110
|
+
scrollSideEffect === null || scrollSideEffect === void 0 ? void 0 : scrollSideEffect(event);
|
|
96
111
|
debouncedSetIsAttached();
|
|
97
|
-
}, [
|
|
112
|
+
}, [scrollRef, isAttached, reverse, setScrollTo, scrollSideEffect, debouncedSetIsAttached]);
|
|
98
113
|
const reAttach = (0, react_1.useCallback)(() => {
|
|
99
114
|
shouldAttachScroll.current = true;
|
|
100
115
|
setIsAttached(true);
|
|
101
|
-
if (
|
|
116
|
+
if (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) {
|
|
102
117
|
if (reverse) {
|
|
103
|
-
|
|
118
|
+
scrollRef.current.scrollTo({ top: scrollRef.current.scrollHeight });
|
|
104
119
|
}
|
|
105
120
|
else {
|
|
106
|
-
|
|
121
|
+
scrollRef.current.scrollTo(0, 0);
|
|
107
122
|
}
|
|
108
123
|
}
|
|
109
|
-
}, [
|
|
124
|
+
}, [scrollRef, reverse]);
|
|
125
|
+
// if scrolled to top or bottom move so not to trigger another fetch
|
|
126
|
+
if ((scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) &&
|
|
127
|
+
scrollRef.current.scrollTop > scrollRef.current.scrollHeight - scrollRef.current.clientHeight) {
|
|
128
|
+
scrollRef.current.scrollTo({
|
|
129
|
+
top: scrollRef.current.scrollHeight - scrollRef.current.clientHeight - 4,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
else if ((scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) && scrollRef.current.scrollTop === 0) {
|
|
133
|
+
scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.scrollTo({ top: 4 });
|
|
134
|
+
}
|
|
110
135
|
return {
|
|
111
|
-
ref:
|
|
112
|
-
|
|
136
|
+
ref: scrollRef,
|
|
137
|
+
handleScroll,
|
|
113
138
|
isAttached,
|
|
114
139
|
reAttach,
|
|
115
140
|
};
|
|
116
141
|
}
|
|
142
|
+
const EndOfScroll = ({ status, fetchMoreText, fetchMore }) => (0, ts_pattern_1.match)({ status, hasFetchMore: !!fetchMore })
|
|
143
|
+
.with({ hasFetchMore: false }, () => null)
|
|
144
|
+
.with({ status: "loading" }, { status: "hasNextPage" }, () => (React.createElement(layout_1.Stack, { justify: "center", align: "center", padding: 5, style: { minHeight: 60, margin: "-1px 0" } },
|
|
145
|
+
React.createElement(Spinner_1.Spinner, null))))
|
|
146
|
+
.with({ status: "end-with-force", hasFetchMore: true }, () => (React.createElement(layout_1.Stack, { justify: "center", align: "center", padding: 5 },
|
|
147
|
+
React.createElement(Button_1.Button, { intent: "tertiary", onClick: fetchMore, text: fetchMoreText }))))
|
|
148
|
+
.otherwise(() => null);
|
|
117
149
|
/**
|
|
118
150
|
* Will render a scrollbar container that uses an intersection observer to watch for when
|
|
119
151
|
* the container has scrolled to the top or bottom.
|
|
120
152
|
* @public
|
|
121
153
|
*/
|
|
122
|
-
function Infinite({ children, reverse = false, anchor = false, onFetchMore, status, maxHeight = "100%", scrollSideEffect, width, fetchMoreText, autoscrollText, scrollRef, justify, }) {
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
154
|
+
function Infinite({ children, reverse = false, anchor = false, onFetchMore, onFetchMoreStart, status, startStatus, maxHeight = "100%", scrollSideEffect, width, fetchMoreText, autoscrollText, scrollRef, justify, onResize, onJumpToStart, }) {
|
|
155
|
+
const dualDirection = !!onFetchMoreStart;
|
|
156
|
+
const [lastFetchDirection, setLastFetchDirection] = (0, react_1.useState)(null);
|
|
157
|
+
const topFetch = (0, react_1.useMemo)(() => (reverse ? onFetchMore : onFetchMoreStart), [onFetchMore, onFetchMoreStart, reverse]);
|
|
158
|
+
const bottomFetch = (0, react_1.useMemo)(() => (reverse ? onFetchMoreStart : onFetchMore), [onFetchMore, onFetchMoreStart, reverse]);
|
|
159
|
+
const topStatus = (0, react_1.useMemo)(() => (reverse ? status : startStatus), [reverse, startStatus, status]);
|
|
160
|
+
const bottomStatus = (0, react_1.useMemo)(() => (reverse ? startStatus : status), [reverse, startStatus, status]);
|
|
161
|
+
const { ref, isAttached, handleScroll, reAttach } = useScrollControl(lastFetchDirection, scrollRef, reverse, anchor, scrollSideEffect, topStatus);
|
|
162
|
+
const { inView: topInView, ref: topRef } = (0, useInView_1.default)();
|
|
163
|
+
const { inView: bottomInView, ref: bottomRef } = (0, useInView_1.default)();
|
|
164
|
+
(0, react_1.useEffect)(() => {
|
|
165
|
+
setLastFetchDirection("top");
|
|
166
|
+
if (topInView && topStatus !== "loading") {
|
|
167
|
+
if (topFetch && (!topStatus || topStatus !== "end")) {
|
|
168
|
+
topFetch();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}, [onFetchMore, onFetchMoreStart, reverse, startStatus, status, topFetch, topInView, topStatus]);
|
|
172
|
+
(0, react_1.useEffect)(() => {
|
|
173
|
+
setLastFetchDirection("bottom");
|
|
174
|
+
if (bottomInView && bottomStatus !== "loading") {
|
|
175
|
+
if (bottomFetch && (!bottomStatus || bottomStatus !== "end")) {
|
|
176
|
+
bottomFetch();
|
|
177
|
+
}
|
|
127
178
|
}
|
|
128
|
-
}, [
|
|
129
|
-
|
|
179
|
+
}, [
|
|
180
|
+
bottomFetch,
|
|
181
|
+
bottomInView,
|
|
182
|
+
bottomStatus,
|
|
183
|
+
onFetchMore,
|
|
184
|
+
onFetchMoreStart,
|
|
185
|
+
reverse,
|
|
186
|
+
topStatus,
|
|
187
|
+
status,
|
|
188
|
+
]);
|
|
189
|
+
const { colors } = (0, styled_components_1.useTheme)();
|
|
130
190
|
return (React.createElement(layout_1.Stack, { ...(0, dpName_1.dpNameProp)("Infinite"), maxHeight: "100%", style: {
|
|
131
191
|
position: "relative",
|
|
132
192
|
overflow: "hidden",
|
|
133
193
|
height: "100%",
|
|
134
194
|
width,
|
|
135
195
|
}, justify: justify, align: "stretch", vertical: true },
|
|
136
|
-
React.createElement(Scrollbar_1.Scrollbar, { autoHide: true, style: { maxHeight: maxHeight }, scrollableNodeProps: { ref: ref, onScroll:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
.with("loading", "hasNextPage", () => (React.createElement(layout_1.Stack, { justify: "center", align: "center", padding: 5, style: { minHeight: 60 } },
|
|
141
|
-
React.createElement(Spinner_1.Spinner, null))))
|
|
142
|
-
.with("end", () => null)
|
|
143
|
-
.with("end-with-force", () => (React.createElement(layout_1.Stack, { justify: "center", align: "center", padding: 5 },
|
|
144
|
-
React.createElement(Button_1.Button, { intent: "tertiary", onClick: onFetchMore, text: fetchMoreText }))))
|
|
145
|
-
.exhaustive(),
|
|
146
|
-
reverse && React.createElement(ObservedDiv_1.ObservedDiv, { onIntersect: handleIntersect }),
|
|
196
|
+
React.createElement(Scrollbar_1.Scrollbar, { autoHide: true, style: { maxHeight: maxHeight }, scrollableNodeProps: { ref: ref, onScroll: handleScroll } },
|
|
197
|
+
React.createElement(react_resize_observer_1.default, { onResize: onResize }),
|
|
198
|
+
React.createElement(styles_1.Observed, { ref: reverse || dualDirection ? topRef : undefined }),
|
|
199
|
+
React.createElement(EndOfScroll, { status: reverse ? status : startStatus, fetchMoreText: fetchMoreText, fetchMore: reverse ? onFetchMore : onFetchMoreStart }),
|
|
147
200
|
children,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
201
|
+
React.createElement(EndOfScroll, { status: reverse ? startStatus : status, fetchMoreText: fetchMoreText, fetchMore: reverse ? onFetchMoreStart : onFetchMore }),
|
|
202
|
+
React.createElement(styles_1.Observed, { ref: !reverse || dualDirection ? bottomRef : undefined })),
|
|
203
|
+
anchor && !isAttached && (React.createElement(Button_1.OverlayButton, { placement: reverse ? "middle-bottom" : "middle-top", text: autoscrollText, onClick: () => {
|
|
204
|
+
reAttach();
|
|
205
|
+
onJumpToStart === null || onJumpToStart === void 0 ? void 0 : onJumpToStart();
|
|
206
|
+
}, icon: { icon: reverse ? free_solid_svg_icons_1.faAngleDoubleDown : free_solid_svg_icons_1.faAngleDoubleUp, size: 14 }, rightIcon: { icon: reverse ? free_solid_svg_icons_1.faAngleDoubleDown : free_solid_svg_icons_1.faAngleDoubleUp, size: 14 }, style: { color: colors.brandShade100 } }))));
|
|
152
207
|
}
|
|
153
208
|
exports.Infinite = Infinite;
|
|
154
209
|
//# sourceMappingURL=Infinite.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Infinite.js","sourceRoot":"","sources":["../../../../src/components/Infinite/Infinite.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"Infinite.js","sourceRoot":"","sources":["../../../../src/components/Infinite/Infinite.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,iCASe;AACf,+CAAoD;AACpD,yCAAiD;AACjD,qCAAoC;AACpC,wCAAqC;AACrC,sCAAkD;AAClD,2CAAmC;AACnC,4CAAyC;AAEzC,4EAAuF;AACvF,yDAA6C;AAC7C,+CAAgD;AAChD,qDAA8C;AAC9C,iEAAmD;AA6BnD,sEAAsE;AACtE,SAAS,gBAAgB,CACvB,kBAA2C,EAC3C,SAAqC,EACrC,OAAiB,EACjB,MAAgB,EAChB,gBAAuE,EACvE,SAAgE;IAEhE,MAAM,UAAU,GAAG,IAAA,cAAM,EAAC,IAAI,CAAC,CAAC;IAEhC,4EAA4E;IAC5E,MAAM,kBAAkB,GAAG,IAAA,cAAM,EAAC,IAAI,CAAC,CAAC;IACxC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,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4BAwHC"}
|
|
@@ -9,7 +9,7 @@ const dpName_1 = require("../../utils/dpName");
|
|
|
9
9
|
* Component that positions absolutely to the top or bottom of the container
|
|
10
10
|
* and emits an event if it intersects with the view port using `IntersectionObserver`
|
|
11
11
|
*/
|
|
12
|
-
function ObservedDiv({ onIntersect
|
|
12
|
+
function ObservedDiv({ onIntersect }) {
|
|
13
13
|
const ref = (0, react_1.useRef)(null);
|
|
14
14
|
const callback = (0, react_1.useRef)(onIntersect);
|
|
15
15
|
(0, react_1.useLayoutEffect)(() => {
|
|
@@ -26,7 +26,7 @@ function ObservedDiv({ onIntersect, reverse = false }) {
|
|
|
26
26
|
observer.observe(ref.current);
|
|
27
27
|
return () => observer.disconnect();
|
|
28
28
|
}, []);
|
|
29
|
-
return
|
|
29
|
+
return React.createElement(S.Observed, { ...(0, dpName_1.dpNameProp)("ObservedDiv"), "data-testid": "observer", ref: ref });
|
|
30
30
|
}
|
|
31
31
|
exports.ObservedDiv = ObservedDiv;
|
|
32
32
|
//# sourceMappingURL=ObservedDiv.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservedDiv.js","sourceRoot":"","sources":["../../../../src/components/Infinite/ObservedDiv.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,iCAAgD;AAChD,8BAA8B;AAC9B,+CAAgD;
|
|
1
|
+
{"version":3,"file":"ObservedDiv.js","sourceRoot":"","sources":["../../../../src/components/Infinite/ObservedDiv.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,iCAAgD;AAChD,8BAA8B;AAC9B,+CAAgD;AAOhD;;;GAGG;AACH,SAAgB,WAAW,CAAC,EAAE,WAAW,EAAiB;IACxD,MAAM,GAAG,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAC,WAAW,CAAC,CAAC;IAErC,IAAA,uBAAe,EAAC,GAAG,EAAE;QACnB,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC;IACjC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,IAAA,uBAAe,EAAC,GAAG,EAAE;QACnB,IAAI,CAAC,GAAG,CAAC,OAAO;YAAE,OAAO;QAEzB,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CAAC,CAAC,OAAO,EAAE,EAAE;YACpD,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE;gBACjD,QAAQ,CAAC,OAAO,EAAE,CAAC;aACpB;QACH,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE9B,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,oBAAC,CAAC,CAAC,QAAQ,OAAK,IAAA,mBAAU,EAAC,aAAa,CAAC,iBAAc,UAAU,EAAC,GAAG,EAAE,GAAG,GAAI,CAAC;AACxF,CAAC;AAvBD,kCAuBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../src/components/Infinite/styles.tsx"],"names":[],"mappings":";;;AAAA,yDAAuC;AAE1B,QAAA,QAAQ,GAAG,2BAAM,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../src/components/Infinite/styles.tsx"],"names":[],"mappings":";;;AAAA,yDAAuC;AAE1B,QAAA,QAAQ,GAAG,2BAAM,CAAC,GAAG,CAAA;;;CAGjC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("react");
|
|
4
|
+
// hook that detects when the provided element is within the viewport
|
|
5
|
+
const useInView = () => {
|
|
6
|
+
const [ref, setRef] = (0, react_1.useState)(null);
|
|
7
|
+
const [inView, setInView] = (0, react_1.useState)(false);
|
|
8
|
+
const visibilityOptions = (0, react_1.useMemo)(() => ({
|
|
9
|
+
root: null,
|
|
10
|
+
threshold: [0, 1],
|
|
11
|
+
}), []);
|
|
12
|
+
(0, react_1.useEffect)(() => {
|
|
13
|
+
if (!ref)
|
|
14
|
+
return;
|
|
15
|
+
const observer = new IntersectionObserver((entries) => entries.forEach((entry) => {
|
|
16
|
+
setInView(entry.isIntersecting);
|
|
17
|
+
}), visibilityOptions);
|
|
18
|
+
observer.observe(ref);
|
|
19
|
+
return () => {
|
|
20
|
+
setInView(false);
|
|
21
|
+
observer.disconnect();
|
|
22
|
+
};
|
|
23
|
+
}, [ref, visibilityOptions]);
|
|
24
|
+
return (0, react_1.useMemo)(() => ({ ref: setRef, inView }), [inView]);
|
|
25
|
+
};
|
|
26
|
+
exports.default = useInView;
|
|
27
|
+
//# sourceMappingURL=useInView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInView.js","sourceRoot":"","sources":["../../../src/utils/useInView.ts"],"names":[],"mappings":";;AAAA,iCAAqD;AAErD,qEAAqE;AACrE,MAAM,SAAS,GAAG,GAA0B,EAAE;IAC5C,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAA,gBAAQ,EAAW,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,iBAAiB,GAA6B,IAAA,eAAO,EACzD,GAAG,EAAE,CAAC,CAAC;QACL,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KAClB,CAAC,EACF,EAAE,CACH,CAAC;IAEF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,GAAG;YAAE,OAAO;QACjB,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CACvC,CAAC,OAAO,EAAE,EAAE,CACV,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACxB,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAClC,CAAC,CAAC,EACJ,iBAAiB,CAClB,CAAC;QACF,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACtB,OAAO,GAAG,EAAE;YACV,SAAS,CAAC,KAAK,CAAC,CAAC;YACjB,QAAQ,CAAC,UAAU,EAAE,CAAC;QACxB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAE7B,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5D,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC"}
|
package/dist/deskpro-ui.d.ts
CHANGED
|
@@ -3461,7 +3461,7 @@ export declare interface ImageAvatarProps {
|
|
|
3461
3461
|
* the container has scrolled to the top or bottom.
|
|
3462
3462
|
* @public
|
|
3463
3463
|
*/
|
|
3464
|
-
export declare function Infinite({ children, reverse, anchor, onFetchMore, status, maxHeight, scrollSideEffect, width, fetchMoreText, autoscrollText, scrollRef, justify, }: InfiniteProps): JSX.Element;
|
|
3464
|
+
export declare function Infinite({ children, reverse, anchor, onFetchMore, onFetchMoreStart, status, startStatus, maxHeight, scrollSideEffect, width, fetchMoreText, autoscrollText, scrollRef, justify, onResize, onJumpToStart, }: InfiniteProps): JSX.Element;
|
|
3465
3465
|
|
|
3466
3466
|
/**
|
|
3467
3467
|
* @public
|
|
@@ -3473,16 +3473,20 @@ export declare interface InfiniteProps {
|
|
|
3473
3473
|
/** Whether to render the Scroll To Start button */
|
|
3474
3474
|
anchor?: boolean;
|
|
3475
3475
|
onFetchMore?: () => void;
|
|
3476
|
+
onFetchMoreStart?: () => void;
|
|
3476
3477
|
status?: "loading" | "hasNextPage" | "end" | "end-with-force";
|
|
3478
|
+
startStatus?: "loading" | "hasNextPage" | "end" | "end-with-force";
|
|
3477
3479
|
maxHeight?: Property.MaxHeight;
|
|
3478
3480
|
/** Used in <Dropdown /> to hide suboptions on scroll */
|
|
3479
|
-
scrollSideEffect?: () => void;
|
|
3481
|
+
scrollSideEffect?: (event: React_2.UIEvent<HTMLElement, UIEvent>) => void;
|
|
3480
3482
|
width?: string;
|
|
3481
3483
|
/** Align the list, you probably want flex-end if the list is reversed so it aligns to the bottom of the viewport */
|
|
3482
3484
|
justify?: StackProps["justify"];
|
|
3483
3485
|
fetchMoreText: ReactNode;
|
|
3484
3486
|
autoscrollText: ReactNode;
|
|
3485
3487
|
scrollRef?: RefObject<HTMLDivElement>;
|
|
3488
|
+
onResize?: () => void;
|
|
3489
|
+
onJumpToStart?: () => void;
|
|
3486
3490
|
}
|
|
3487
3491
|
|
|
3488
3492
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { useCallback, useEffect, useLayoutEffect, useRef, useState, } from "react";
|
|
2
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
3
3
|
import { useDebouncedCallback } from "use-debounce";
|
|
4
4
|
import { Stack } from "../../layout";
|
|
5
|
-
import {
|
|
5
|
+
import { Observed } from "./styles";
|
|
6
6
|
import { Spinner } from "../Spinner";
|
|
7
7
|
import { Button, OverlayButton } from "../Button";
|
|
8
8
|
import { match } from "ts-pattern";
|
|
@@ -10,10 +10,10 @@ import { Scrollbar } from "../Scrollbar";
|
|
|
10
10
|
import { faAngleDoubleDown, faAngleDoubleUp } from "@fortawesome/free-solid-svg-icons";
|
|
11
11
|
import { useTheme } from "styled-components";
|
|
12
12
|
import { dpNameProp } from "../../utils/dpName";
|
|
13
|
+
import useInView from "../../utils/useInView";
|
|
14
|
+
import ResizeObserver from "react-resize-observer";
|
|
13
15
|
// Controls the scroll when the data changes and for user wheel events
|
|
14
|
-
function useScrollControl(
|
|
15
|
-
const innerRef = useRef(null);
|
|
16
|
-
const ref = outerRef !== null && outerRef !== void 0 ? outerRef : innerRef;
|
|
16
|
+
function useScrollControl(lastFetchDirection, scrollRef, reverse, anchor, scrollSideEffect, topStatus) {
|
|
17
17
|
const firstMount = useRef(true);
|
|
18
18
|
// Used to check if the scroll should be forced to the edges on data updates
|
|
19
19
|
const shouldAttachScroll = useRef(true);
|
|
@@ -21,59 +21,74 @@ function useScrollControl(children, reverse, anchor, scrollSideEffect, outerRef)
|
|
|
21
21
|
const lastKnownScrollOffset = useRef();
|
|
22
22
|
// Forces the scrollbar to the top or bottom on first render
|
|
23
23
|
useEffect(() => {
|
|
24
|
-
if (
|
|
24
|
+
if ((scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) && shouldAttachScroll.current) {
|
|
25
25
|
if (reverse) {
|
|
26
|
-
|
|
26
|
+
scrollRef.current.scrollTo({
|
|
27
|
+
top: scrollRef.current.scrollHeight - scrollRef.current.clientHeight - 4,
|
|
28
|
+
});
|
|
27
29
|
}
|
|
28
30
|
else {
|
|
29
|
-
|
|
31
|
+
scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.scrollTo({ top: 4 });
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
|
-
}, [
|
|
34
|
+
}, [reverse, scrollRef]);
|
|
35
|
+
// this will update the scroll position when a fetch has been made while scrolling up
|
|
36
|
+
// this is to stop the page jumping once a request has been made
|
|
37
|
+
const setScrollTo = useCallback(() => {
|
|
38
|
+
var _a, _b, _c;
|
|
39
|
+
if (!shouldAttachScroll.current &&
|
|
40
|
+
typeof lastKnownScrollOffset.current === "number" &&
|
|
41
|
+
lastFetchDirection === "top" &&
|
|
42
|
+
topStatus !== "end" &&
|
|
43
|
+
topStatus !== "end-with-force") {
|
|
44
|
+
// set position using saved offset
|
|
45
|
+
(_a = scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
|
|
46
|
+
top: Math.abs(lastKnownScrollOffset.current -
|
|
47
|
+
(((_b = scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) === null || _b === void 0 ? void 0 : _b.scrollHeight) - ((_c = scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight))),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
// save current position offset
|
|
51
|
+
if (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) {
|
|
52
|
+
lastKnownScrollOffset.current = Math.abs((scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.scrollTop) -
|
|
53
|
+
((scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.scrollHeight) - (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.clientHeight)));
|
|
54
|
+
}
|
|
55
|
+
}, [lastFetchDirection, scrollRef, topStatus]);
|
|
33
56
|
// On render will force the scroll bar to the top or bottom, unless detached
|
|
34
57
|
useLayoutEffect(() => {
|
|
35
58
|
if (firstMount.current || !anchor) {
|
|
36
59
|
firstMount.current = false;
|
|
37
60
|
return;
|
|
38
61
|
}
|
|
39
|
-
if (!
|
|
62
|
+
if (!(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current))
|
|
40
63
|
return;
|
|
41
|
-
|
|
42
|
-
if (reverse) {
|
|
43
|
-
ref.current.scrollTo({ top: ref.current.scrollHeight });
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
ref.current.scrollTo({ top: 0 });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else if (typeof lastKnownScrollOffset.current === "number" && reverse) {
|
|
50
|
-
ref.current.scrollTo({
|
|
51
|
-
top: Math.abs(lastKnownScrollOffset.current - (ref.current.scrollHeight - ref.current.clientHeight)),
|
|
52
|
-
});
|
|
53
|
-
}
|
|
64
|
+
setScrollTo();
|
|
54
65
|
});
|
|
55
66
|
const debouncedSetIsAttached = useDebouncedCallback(() => {
|
|
56
|
-
if (typeof lastKnownScrollOffset.current === "number" &&
|
|
67
|
+
if (typeof lastKnownScrollOffset.current === "number" && (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
|
|
57
68
|
if (shouldAttachScroll.current !== isAttached && lastKnownScrollOffset.current > 300) {
|
|
58
69
|
setIsAttached(shouldAttachScroll.current);
|
|
59
70
|
}
|
|
60
71
|
else if (shouldAttachScroll.current !== isAttached &&
|
|
61
|
-
lastKnownScrollOffset.current
|
|
72
|
+
lastKnownScrollOffset.current <= 10) {
|
|
62
73
|
setIsAttached(shouldAttachScroll.current);
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
76
|
}, 100, { trailing: true, leading: true });
|
|
66
77
|
// On scroll events will attach or detach the scroll position from the top or bottom
|
|
67
|
-
const handleScroll = useCallback(() => {
|
|
68
|
-
if (
|
|
78
|
+
const handleScroll = useCallback((event) => {
|
|
79
|
+
if ((scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) &&
|
|
69
80
|
!isAttached &&
|
|
70
|
-
|
|
81
|
+
scrollRef.current.scrollTop + scrollRef.current.offsetHeight >
|
|
82
|
+
scrollRef.current.scrollHeight - 2) {
|
|
71
83
|
setIsAttached(true);
|
|
72
84
|
}
|
|
73
|
-
if (!
|
|
85
|
+
if (!(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
|
|
86
|
+
scrollSideEffect === null || scrollSideEffect === void 0 ? void 0 : scrollSideEffect(event);
|
|
74
87
|
return;
|
|
88
|
+
}
|
|
75
89
|
if (reverse) {
|
|
76
|
-
if (
|
|
90
|
+
if (scrollRef.current.scrollTop <
|
|
91
|
+
scrollRef.current.scrollHeight - scrollRef.current.clientHeight) {
|
|
77
92
|
shouldAttachScroll.current = false;
|
|
78
93
|
}
|
|
79
94
|
else {
|
|
@@ -81,70 +96,110 @@ function useScrollControl(children, reverse, anchor, scrollSideEffect, outerRef)
|
|
|
81
96
|
}
|
|
82
97
|
}
|
|
83
98
|
else {
|
|
84
|
-
if (
|
|
99
|
+
if (scrollRef.current.scrollTop > 0) {
|
|
85
100
|
shouldAttachScroll.current = false;
|
|
86
101
|
}
|
|
87
102
|
else {
|
|
88
103
|
shouldAttachScroll.current = true;
|
|
89
104
|
}
|
|
90
105
|
}
|
|
91
|
-
|
|
92
|
-
|
|
106
|
+
setScrollTo();
|
|
107
|
+
scrollSideEffect === null || scrollSideEffect === void 0 ? void 0 : scrollSideEffect(event);
|
|
93
108
|
debouncedSetIsAttached();
|
|
94
|
-
}, [
|
|
109
|
+
}, [scrollRef, isAttached, reverse, setScrollTo, scrollSideEffect, debouncedSetIsAttached]);
|
|
95
110
|
const reAttach = useCallback(() => {
|
|
96
111
|
shouldAttachScroll.current = true;
|
|
97
112
|
setIsAttached(true);
|
|
98
|
-
if (
|
|
113
|
+
if (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) {
|
|
99
114
|
if (reverse) {
|
|
100
|
-
|
|
115
|
+
scrollRef.current.scrollTo({ top: scrollRef.current.scrollHeight });
|
|
101
116
|
}
|
|
102
117
|
else {
|
|
103
|
-
|
|
118
|
+
scrollRef.current.scrollTo(0, 0);
|
|
104
119
|
}
|
|
105
120
|
}
|
|
106
|
-
}, [
|
|
121
|
+
}, [scrollRef, reverse]);
|
|
122
|
+
// if scrolled to top or bottom move so not to trigger another fetch
|
|
123
|
+
if ((scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) &&
|
|
124
|
+
scrollRef.current.scrollTop > scrollRef.current.scrollHeight - scrollRef.current.clientHeight) {
|
|
125
|
+
scrollRef.current.scrollTo({
|
|
126
|
+
top: scrollRef.current.scrollHeight - scrollRef.current.clientHeight - 4,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
else if ((scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) && scrollRef.current.scrollTop === 0) {
|
|
130
|
+
scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.scrollTo({ top: 4 });
|
|
131
|
+
}
|
|
107
132
|
return {
|
|
108
|
-
ref:
|
|
109
|
-
|
|
133
|
+
ref: scrollRef,
|
|
134
|
+
handleScroll,
|
|
110
135
|
isAttached,
|
|
111
136
|
reAttach,
|
|
112
137
|
};
|
|
113
138
|
}
|
|
139
|
+
const EndOfScroll = ({ status, fetchMoreText, fetchMore }) => match({ status, hasFetchMore: !!fetchMore })
|
|
140
|
+
.with({ hasFetchMore: false }, () => null)
|
|
141
|
+
.with({ status: "loading" }, { status: "hasNextPage" }, () => (React.createElement(Stack, { justify: "center", align: "center", padding: 5, style: { minHeight: 60, margin: "-1px 0" } },
|
|
142
|
+
React.createElement(Spinner, null))))
|
|
143
|
+
.with({ status: "end-with-force", hasFetchMore: true }, () => (React.createElement(Stack, { justify: "center", align: "center", padding: 5 },
|
|
144
|
+
React.createElement(Button, { intent: "tertiary", onClick: fetchMore, text: fetchMoreText }))))
|
|
145
|
+
.otherwise(() => null);
|
|
114
146
|
/**
|
|
115
147
|
* Will render a scrollbar container that uses an intersection observer to watch for when
|
|
116
148
|
* the container has scrolled to the top or bottom.
|
|
117
149
|
* @public
|
|
118
150
|
*/
|
|
119
|
-
export function Infinite({ children, reverse = false, anchor = false, onFetchMore, status, maxHeight = "100%", scrollSideEffect, width, fetchMoreText, autoscrollText, scrollRef, justify, }) {
|
|
120
|
-
const
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
151
|
+
export function Infinite({ children, reverse = false, anchor = false, onFetchMore, onFetchMoreStart, status, startStatus, maxHeight = "100%", scrollSideEffect, width, fetchMoreText, autoscrollText, scrollRef, justify, onResize, onJumpToStart, }) {
|
|
152
|
+
const dualDirection = !!onFetchMoreStart;
|
|
153
|
+
const [lastFetchDirection, setLastFetchDirection] = useState(null);
|
|
154
|
+
const topFetch = useMemo(() => (reverse ? onFetchMore : onFetchMoreStart), [onFetchMore, onFetchMoreStart, reverse]);
|
|
155
|
+
const bottomFetch = useMemo(() => (reverse ? onFetchMoreStart : onFetchMore), [onFetchMore, onFetchMoreStart, reverse]);
|
|
156
|
+
const topStatus = useMemo(() => (reverse ? status : startStatus), [reverse, startStatus, status]);
|
|
157
|
+
const bottomStatus = useMemo(() => (reverse ? startStatus : status), [reverse, startStatus, status]);
|
|
158
|
+
const { ref, isAttached, handleScroll, reAttach } = useScrollControl(lastFetchDirection, scrollRef, reverse, anchor, scrollSideEffect, topStatus);
|
|
159
|
+
const { inView: topInView, ref: topRef } = useInView();
|
|
160
|
+
const { inView: bottomInView, ref: bottomRef } = useInView();
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
setLastFetchDirection("top");
|
|
163
|
+
if (topInView && topStatus !== "loading") {
|
|
164
|
+
if (topFetch && (!topStatus || topStatus !== "end")) {
|
|
165
|
+
topFetch();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}, [onFetchMore, onFetchMoreStart, reverse, startStatus, status, topFetch, topInView, topStatus]);
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
setLastFetchDirection("bottom");
|
|
171
|
+
if (bottomInView && bottomStatus !== "loading") {
|
|
172
|
+
if (bottomFetch && (!bottomStatus || bottomStatus !== "end")) {
|
|
173
|
+
bottomFetch();
|
|
174
|
+
}
|
|
124
175
|
}
|
|
125
|
-
}, [
|
|
126
|
-
|
|
176
|
+
}, [
|
|
177
|
+
bottomFetch,
|
|
178
|
+
bottomInView,
|
|
179
|
+
bottomStatus,
|
|
180
|
+
onFetchMore,
|
|
181
|
+
onFetchMoreStart,
|
|
182
|
+
reverse,
|
|
183
|
+
topStatus,
|
|
184
|
+
status,
|
|
185
|
+
]);
|
|
186
|
+
const { colors } = useTheme();
|
|
127
187
|
return (React.createElement(Stack, { ...dpNameProp("Infinite"), maxHeight: "100%", style: {
|
|
128
188
|
position: "relative",
|
|
129
189
|
overflow: "hidden",
|
|
130
190
|
height: "100%",
|
|
131
191
|
width,
|
|
132
192
|
}, justify: justify, align: "stretch", vertical: true },
|
|
133
|
-
React.createElement(Scrollbar, { autoHide: true, style: { maxHeight: maxHeight }, scrollableNodeProps: { ref: ref, onScroll:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
.with("loading", "hasNextPage", () => (React.createElement(Stack, { justify: "center", align: "center", padding: 5, style: { minHeight: 60 } },
|
|
138
|
-
React.createElement(Spinner, null))))
|
|
139
|
-
.with("end", () => null)
|
|
140
|
-
.with("end-with-force", () => (React.createElement(Stack, { justify: "center", align: "center", padding: 5 },
|
|
141
|
-
React.createElement(Button, { intent: "tertiary", onClick: onFetchMore, text: fetchMoreText }))))
|
|
142
|
-
.exhaustive(),
|
|
143
|
-
reverse && React.createElement(ObservedDiv, { onIntersect: handleIntersect }),
|
|
193
|
+
React.createElement(Scrollbar, { autoHide: true, style: { maxHeight: maxHeight }, scrollableNodeProps: { ref: ref, onScroll: handleScroll } },
|
|
194
|
+
React.createElement(ResizeObserver, { onResize: onResize }),
|
|
195
|
+
React.createElement(Observed, { ref: reverse || dualDirection ? topRef : undefined }),
|
|
196
|
+
React.createElement(EndOfScroll, { status: reverse ? status : startStatus, fetchMoreText: fetchMoreText, fetchMore: reverse ? onFetchMore : onFetchMoreStart }),
|
|
144
197
|
children,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
198
|
+
React.createElement(EndOfScroll, { status: reverse ? startStatus : status, fetchMoreText: fetchMoreText, fetchMore: reverse ? onFetchMoreStart : onFetchMore }),
|
|
199
|
+
React.createElement(Observed, { ref: !reverse || dualDirection ? bottomRef : undefined })),
|
|
200
|
+
anchor && !isAttached && (React.createElement(OverlayButton, { placement: reverse ? "middle-bottom" : "middle-top", text: autoscrollText, onClick: () => {
|
|
201
|
+
reAttach();
|
|
202
|
+
onJumpToStart === null || onJumpToStart === void 0 ? void 0 : onJumpToStart();
|
|
203
|
+
}, icon: { icon: reverse ? faAngleDoubleDown : faAngleDoubleUp, size: 14 }, rightIcon: { icon: reverse ? faAngleDoubleDown : faAngleDoubleUp, size: 14 }, style: { color: colors.brandShade100 } }))));
|
|
149
204
|
}
|
|
150
205
|
//# sourceMappingURL=Infinite.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Infinite.js","sourceRoot":"","sources":["../../../../src/components/Infinite/Infinite.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAGL,WAAW,EACX,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,KAAK,EAAc,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Infinite.js","sourceRoot":"","sources":["../../../../src/components/Infinite/Infinite.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAGL,WAAW,EACX,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,KAAK,EAAc,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,SAAS,MAA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IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,eAAe,EAAE,IAAI,EAAE,EAAE,EAAE,EAC5E,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,aAAa,EAAE,GACtC,CACH,CACK,CACT,CAAC;AACJ,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { dpNameProp } from "../../utils/dpName";
|
|
|
6
6
|
* Component that positions absolutely to the top or bottom of the container
|
|
7
7
|
* and emits an event if it intersects with the view port using `IntersectionObserver`
|
|
8
8
|
*/
|
|
9
|
-
export function ObservedDiv({ onIntersect
|
|
9
|
+
export function ObservedDiv({ onIntersect }) {
|
|
10
10
|
const ref = useRef(null);
|
|
11
11
|
const callback = useRef(onIntersect);
|
|
12
12
|
useLayoutEffect(() => {
|
|
@@ -23,6 +23,6 @@ export function ObservedDiv({ onIntersect, reverse = false }) {
|
|
|
23
23
|
observer.observe(ref.current);
|
|
24
24
|
return () => observer.disconnect();
|
|
25
25
|
}, []);
|
|
26
|
-
return
|
|
26
|
+
return React.createElement(S.Observed, { ...dpNameProp("ObservedDiv"), "data-testid": "observer", ref: ref });
|
|
27
27
|
}
|
|
28
28
|
//# sourceMappingURL=ObservedDiv.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservedDiv.js","sourceRoot":"","sources":["../../../../src/components/Infinite/ObservedDiv.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ObservedDiv.js","sourceRoot":"","sources":["../../../../src/components/Infinite/ObservedDiv.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,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MAAM,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../src/components/Infinite/styles.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAGjC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
// hook that detects when the provided element is within the viewport
|
|
3
|
+
const useInView = () => {
|
|
4
|
+
const [ref, setRef] = useState(null);
|
|
5
|
+
const [inView, setInView] = useState(false);
|
|
6
|
+
const visibilityOptions = useMemo(() => ({
|
|
7
|
+
root: null,
|
|
8
|
+
threshold: [0, 1],
|
|
9
|
+
}), []);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (!ref)
|
|
12
|
+
return;
|
|
13
|
+
const observer = new IntersectionObserver((entries) => entries.forEach((entry) => {
|
|
14
|
+
setInView(entry.isIntersecting);
|
|
15
|
+
}), visibilityOptions);
|
|
16
|
+
observer.observe(ref);
|
|
17
|
+
return () => {
|
|
18
|
+
setInView(false);
|
|
19
|
+
observer.disconnect();
|
|
20
|
+
};
|
|
21
|
+
}, [ref, visibilityOptions]);
|
|
22
|
+
return useMemo(() => ({ ref: setRef, inView }), [inView]);
|
|
23
|
+
};
|
|
24
|
+
export default useInView;
|
|
25
|
+
//# sourceMappingURL=useInView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInView.js","sourceRoot":"","sources":["../../../src/utils/useInView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,qEAAqE;AACrE,MAAM,SAAS,GAAG,GAA0B,EAAE;IAC5C,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAW,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,iBAAiB,GAA6B,OAAO,CACzD,GAAG,EAAE,CAAC,CAAC;QACL,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KAClB,CAAC,EACF,EAAE,CACH,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,GAAG;YAAE,OAAO;QACjB,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CACvC,CAAC,OAAO,EAAE,EAAE,CACV,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACxB,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAClC,CAAC,CAAC,EACJ,iBAAiB,CAClB,CAAC;QACF,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACtB,OAAO,GAAG,EAAE;YACV,SAAS,CAAC,KAAK,CAAC,CAAC;YACjB,QAAQ,CAAC,UAAU,EAAE,CAAC;QACxB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAE7B,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5D,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deskpro/deskpro-ui",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "Deskpro UI components",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/deskpro/deskpro-ui/issues"
|
|
@@ -110,6 +110,7 @@
|
|
|
110
110
|
"prop-types": "^15.8.1",
|
|
111
111
|
"react": "^18.2.0",
|
|
112
112
|
"react-dom": "^18.2.0",
|
|
113
|
+
"react-resize-observer": "^1.1.1",
|
|
113
114
|
"rimraf": "3.0.2",
|
|
114
115
|
"storybook-addon-pseudo-states": "^1.15.1",
|
|
115
116
|
"styled-components": "^5.3.5",
|