@ringcentral/juno 2.40.1 → 2.41.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/components/Downshift/SuggestionList/SuggestionList.d.ts +3 -3
- package/components/Downshift/utils/useDownshift.d.ts +1 -1
- package/components/Virtuoso/index.d.ts +1 -1
- package/components/Virtuoso/index.js +1 -1
- package/components/Virtuoso/react-virtuoso/AATree.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/AATree.js +60 -48
- package/components/Virtuoso/react-virtuoso/TableVirtuoso.d.ts +5 -0
- package/components/Virtuoso/react-virtuoso/TableVirtuoso.js +217 -0
- package/components/Virtuoso/react-virtuoso/Virtuoso.d.ts +7696 -0
- package/components/Virtuoso/react-virtuoso/Virtuoso.js +317 -0
- package/components/Virtuoso/react-virtuoso/{Grid.d.ts → VirtuosoGrid.d.ts} +170 -72
- package/components/Virtuoso/react-virtuoso/VirtuosoGrid.js +199 -0
- package/components/Virtuoso/react-virtuoso/alignToBottomSystem.d.ts +119 -65
- package/components/Virtuoso/react-virtuoso/alignToBottomSystem.js +3 -3
- package/components/Virtuoso/react-virtuoso/comparators.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/comparators.js +1 -3
- package/components/Virtuoso/react-virtuoso/component-interfaces/TableVirtuoso.d.ts +194 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/TableVirtuoso.js +2 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/Virtuoso.d.ts +274 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/Virtuoso.js +2 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/VirtuosoGrid.d.ts +125 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/VirtuosoGrid.js +2 -0
- package/components/Virtuoso/react-virtuoso/domIOSystem.d.ts +3 -2
- package/components/Virtuoso/react-virtuoso/domIOSystem.js +5 -3
- package/components/Virtuoso/react-virtuoso/followOutputSystem.d.ts +80 -43
- package/components/Virtuoso/react-virtuoso/followOutputSystem.js +21 -19
- package/components/Virtuoso/react-virtuoso/gridSystem.d.ts +57 -31
- package/components/Virtuoso/react-virtuoso/gridSystem.js +173 -86
- package/components/Virtuoso/react-virtuoso/groupedListSystem.d.ts +76 -67
- package/components/Virtuoso/react-virtuoso/groupedListSystem.js +12 -12
- package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.d.ts +6 -3
- package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +36 -17
- package/components/Virtuoso/react-virtuoso/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/components/Virtuoso/react-virtuoso/hooks/useIsomorphicLayoutEffect.js +3 -2
- package/components/Virtuoso/react-virtuoso/hooks/useRcPortalWindowContext.d.ts +2 -0
- package/components/Virtuoso/react-virtuoso/hooks/useRcPortalWindowContext.js +5 -0
- package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.d.ts +2 -3
- package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +36 -51
- package/components/Virtuoso/react-virtuoso/hooks/useSize.d.ts +2 -3
- package/components/Virtuoso/react-virtuoso/hooks/useSize.js +13 -13
- package/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +17 -15
- package/components/Virtuoso/react-virtuoso/index.d.ts +7 -1
- package/components/Virtuoso/react-virtuoso/index.js +8 -1
- package/components/Virtuoso/react-virtuoso/initialItemCountSystem.d.ts +304 -68
- package/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +9 -31
- package/components/Virtuoso/react-virtuoso/initialScrollTopSystem.d.ts +127 -109
- package/components/Virtuoso/react-virtuoso/initialScrollTopSystem.js +7 -7
- package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.d.ts +38 -22
- package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +13 -20
- package/components/Virtuoso/react-virtuoso/interfaces.d.ts +150 -51
- package/components/Virtuoso/react-virtuoso/listStateSystem.d.ts +109 -59
- package/components/Virtuoso/react-virtuoso/listStateSystem.js +100 -52
- package/components/Virtuoso/react-virtuoso/listSystem.d.ts +1691 -693
- package/components/Virtuoso/react-virtuoso/listSystem.js +15 -16
- package/components/Virtuoso/react-virtuoso/loggerSystem.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/loggerSystem.js +2 -4
- package/components/Virtuoso/react-virtuoso/propsReadySystem.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/propsReadySystem.js +3 -4
- package/components/Virtuoso/react-virtuoso/react-urx/index.d.ts +110 -0
- package/components/Virtuoso/react-virtuoso/react-urx/index.js +200 -0
- package/components/Virtuoso/react-virtuoso/react-urx/package.json +5 -0
- package/components/Virtuoso/react-virtuoso/recalcSystem.d.ts +4 -0
- package/components/Virtuoso/react-virtuoso/recalcSystem.js +8 -0
- package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.d.ts +144 -78
- package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +33 -21
- package/components/Virtuoso/react-virtuoso/scrollSeekSystem.d.ts +12 -7
- package/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +7 -10
- package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.d.ts +19 -11
- package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +11 -23
- package/components/Virtuoso/react-virtuoso/sizeRangeSystem.d.ts +7 -6
- package/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +15 -27
- package/components/Virtuoso/react-virtuoso/sizeSystem.d.ts +20 -11
- package/components/Virtuoso/react-virtuoso/sizeSystem.js +182 -52
- package/components/Virtuoso/react-virtuoso/stateFlagsSystem.d.ts +8 -5
- package/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +32 -23
- package/components/Virtuoso/react-virtuoso/stateLoadSystem.d.ts +318 -0
- package/components/Virtuoso/react-virtuoso/stateLoadSystem.js +41 -0
- package/components/Virtuoso/react-virtuoso/topItemCountSystem.d.ts +518 -467
- package/components/Virtuoso/react-virtuoso/topItemCountSystem.js +5 -5
- package/components/Virtuoso/react-virtuoso/totalListHeightSystem.d.ts +115 -63
- package/components/Virtuoso/react-virtuoso/totalListHeightSystem.js +6 -13
- package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.d.ts +139 -73
- package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +74 -31
- package/components/Virtuoso/react-virtuoso/urx/actions.d.ts +127 -0
- package/components/Virtuoso/react-virtuoso/urx/actions.js +98 -0
- package/components/Virtuoso/react-virtuoso/urx/constants.d.ts +8 -0
- package/components/Virtuoso/react-virtuoso/urx/constants.js +6 -0
- package/components/Virtuoso/react-virtuoso/urx/index.d.ts +6 -0
- package/components/Virtuoso/react-virtuoso/urx/index.js +9 -0
- package/components/Virtuoso/react-virtuoso/urx/package.json +5 -0
- package/components/Virtuoso/react-virtuoso/urx/pipe.d.ts +220 -0
- package/components/Virtuoso/react-virtuoso/urx/pipe.js +279 -0
- package/components/Virtuoso/react-virtuoso/urx/streams.d.ts +143 -0
- package/components/Virtuoso/react-virtuoso/urx/streams.js +227 -0
- package/components/Virtuoso/react-virtuoso/urx/system.d.ts +148 -0
- package/components/Virtuoso/react-virtuoso/urx/system.js +106 -0
- package/components/Virtuoso/react-virtuoso/urx/transformers.d.ts +71 -0
- package/components/Virtuoso/react-virtuoso/urx/transformers.js +106 -0
- package/components/Virtuoso/react-virtuoso/urx/utils.d.ts +57 -0
- package/components/Virtuoso/react-virtuoso/urx/utils.js +102 -0
- package/components/Virtuoso/react-virtuoso/utils/approximatelyEqual.d.ts +1 -0
- package/components/Virtuoso/react-virtuoso/utils/approximatelyEqual.js +6 -0
- package/components/Virtuoso/react-virtuoso/utils/context.d.ts +13 -0
- package/components/Virtuoso/react-virtuoso/utils/context.js +6 -0
- package/components/Virtuoso/react-virtuoso/utils/skipFrames.d.ts +1 -0
- package/components/Virtuoso/react-virtuoso/utils/skipFrames.js +11 -0
- package/components/Virtuoso/react-virtuoso/windowScrollerSystem.d.ts +6 -4
- package/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +1 -1
- package/components/Virtuoso/utils/isOutOfRange.d.ts +1 -1
- package/components/Virtuoso/utils/useHighlightScroll.d.ts +2 -2
- package/es6/components/Virtuoso/index.js +1 -1
- package/es6/components/Virtuoso/react-virtuoso/AATree.js +60 -48
- package/es6/components/Virtuoso/react-virtuoso/{Table.js → TableVirtuoso.js} +73 -52
- package/es6/components/Virtuoso/react-virtuoso/{List.js → Virtuoso.js} +85 -161
- package/es6/components/Virtuoso/react-virtuoso/VirtuosoGrid.js +198 -0
- package/es6/components/Virtuoso/react-virtuoso/alignToBottomSystem.js +3 -3
- package/es6/components/Virtuoso/react-virtuoso/comparators.js +1 -3
- package/es6/components/Virtuoso/react-virtuoso/component-interfaces/TableVirtuoso.js +0 -0
- package/es6/components/Virtuoso/react-virtuoso/component-interfaces/Virtuoso.js +0 -0
- package/es6/components/Virtuoso/react-virtuoso/component-interfaces/VirtuosoGrid.js +0 -0
- package/es6/components/Virtuoso/react-virtuoso/domIOSystem.js +5 -3
- package/es6/components/Virtuoso/react-virtuoso/followOutputSystem.js +21 -19
- package/es6/components/Virtuoso/react-virtuoso/gridSystem.js +173 -87
- package/es6/components/Virtuoso/react-virtuoso/groupedListSystem.js +13 -13
- package/es6/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +35 -16
- package/es6/components/Virtuoso/react-virtuoso/hooks/useIsomorphicLayoutEffect.js +2 -2
- package/es6/components/Virtuoso/react-virtuoso/hooks/useRcPortalWindowContext.js +2 -0
- package/es6/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +35 -50
- package/es6/components/Virtuoso/react-virtuoso/hooks/useSize.js +11 -12
- package/es6/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +15 -14
- package/es6/components/Virtuoso/react-virtuoso/index.js +4 -1
- package/es6/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +11 -33
- package/es6/components/Virtuoso/react-virtuoso/initialScrollTopSystem.js +7 -7
- package/es6/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +13 -20
- package/es6/components/Virtuoso/react-virtuoso/listStateSystem.js +101 -54
- package/es6/components/Virtuoso/react-virtuoso/listSystem.js +15 -16
- package/es6/components/Virtuoso/react-virtuoso/loggerSystem.js +2 -4
- package/es6/components/Virtuoso/react-virtuoso/propsReadySystem.js +3 -4
- package/es6/components/Virtuoso/react-virtuoso/react-urx/index.js +197 -0
- package/es6/components/Virtuoso/react-virtuoso/recalcSystem.js +5 -0
- package/es6/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +34 -22
- package/es6/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +7 -10
- package/es6/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +11 -23
- package/es6/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +16 -28
- package/es6/components/Virtuoso/react-virtuoso/sizeSystem.js +180 -53
- package/es6/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +32 -23
- package/es6/components/Virtuoso/react-virtuoso/stateLoadSystem.js +39 -0
- package/es6/components/Virtuoso/react-virtuoso/topItemCountSystem.js +5 -5
- package/es6/components/Virtuoso/react-virtuoso/totalListHeightSystem.js +6 -13
- package/es6/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +75 -32
- package/es6/components/Virtuoso/react-virtuoso/urx/actions.js +90 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/constants.js +4 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/index.js +6 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/pipe.js +266 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/streams.js +220 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/system.js +102 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/transformers.js +101 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/utils.js +88 -0
- package/es6/components/Virtuoso/react-virtuoso/utils/approximatelyEqual.js +3 -0
- package/es6/components/Virtuoso/react-virtuoso/utils/context.js +3 -0
- package/es6/components/Virtuoso/react-virtuoso/utils/skipFrames.js +8 -0
- package/es6/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +1 -1
- package/package.json +2 -2
- package/components/Virtuoso/Virtuoso.d.ts +0 -1
- package/components/Virtuoso/Virtuoso.js +0 -4
- package/components/Virtuoso/react-virtuoso/Grid.js +0 -168
- package/components/Virtuoso/react-virtuoso/List.d.ts +0 -6749
- package/components/Virtuoso/react-virtuoso/List.js +0 -393
- package/components/Virtuoso/react-virtuoso/Table.d.ts +0 -6515
- package/components/Virtuoso/react-virtuoso/Table.js +0 -196
- package/components/Virtuoso/react-virtuoso/components.d.ts +0 -505
- package/components/Virtuoso/react-virtuoso/components.js +0 -9
- package/components/Virtuoso/react-virtuoso/utils/conditionalFlushSync.d.ts +0 -1
- package/components/Virtuoso/react-virtuoso/utils/conditionalFlushSync.js +0 -11
- package/es6/components/Virtuoso/Virtuoso.js +0 -1
- package/es6/components/Virtuoso/react-virtuoso/Grid.js +0 -166
- package/es6/components/Virtuoso/react-virtuoso/components.js +0 -7
- package/es6/components/Virtuoso/react-virtuoso/utils/conditionalFlushSync.js +0 -8
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as u from '
|
|
3
|
-
import { useRcPortalWindowContext } from '../../../../foundation';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as u from '../urx';
|
|
4
3
|
import { correctItemSize } from '../utils/correctItemSize';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
4
|
+
import ReactDOM from 'react-dom';
|
|
5
|
+
import { approximatelyEqual } from '../utils/approximatelyEqual';
|
|
6
|
+
import { useRcPortalWindowContext } from './useRcPortalWindowContext';
|
|
8
7
|
export default function useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, scrollerElement, scrollerRefCallback, customScrollParent) {
|
|
9
8
|
if (scrollerRefCallback === void 0) { scrollerRefCallback = u.noop; }
|
|
10
|
-
var scrollerRef = useRef(null);
|
|
11
|
-
var scrollTopTarget = useRef(null);
|
|
12
|
-
var timeoutRef = useRef(null);
|
|
9
|
+
var scrollerRef = React.useRef(null);
|
|
10
|
+
var scrollTopTarget = React.useRef(null);
|
|
11
|
+
var timeoutRef = React.useRef(null);
|
|
13
12
|
var _a = useRcPortalWindowContext().externalWindow, externalWindow = _a === void 0 ? window : _a;
|
|
14
|
-
var handler = useCallback(function (ev) {
|
|
13
|
+
var handler = React.useCallback(function (ev) {
|
|
15
14
|
var el = ev.target;
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
var windowScroll = el === externalWindow || el === externalWindow.document;
|
|
16
|
+
var scrollTop = windowScroll ? externalWindow.pageYOffset || externalWindow.document.documentElement.scrollTop : el.scrollTop;
|
|
17
|
+
var scrollHeight = windowScroll ? externalWindow.document.documentElement.scrollHeight : el.scrollHeight;
|
|
18
|
+
var viewportHeight = windowScroll ? externalWindow.innerHeight : el.offsetHeight;
|
|
19
|
+
var call = function () {
|
|
20
|
+
scrollContainerStateCallback({
|
|
21
|
+
scrollTop: Math.max(scrollTop, 0),
|
|
22
|
+
scrollHeight: scrollHeight,
|
|
23
|
+
viewportHeight: viewportHeight,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
27
|
+
if (ev.suppressFlushSync) {
|
|
28
|
+
call();
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
ReactDOM.flushSync(call);
|
|
32
|
+
}
|
|
32
33
|
if (scrollTopTarget.current !== null) {
|
|
33
|
-
if (scrollTop === scrollTopTarget.current ||
|
|
34
|
-
scrollTop <= 0 ||
|
|
35
|
-
scrollTop === el.scrollHeight - correctItemSize(el, 'height')) {
|
|
34
|
+
if (scrollTop === scrollTopTarget.current || scrollTop <= 0 || scrollTop === scrollHeight - viewportHeight) {
|
|
36
35
|
scrollTopTarget.current = null;
|
|
37
36
|
smoothScrollTargetReached(true);
|
|
38
37
|
if (timeoutRef.current) {
|
|
@@ -42,28 +41,19 @@ export default function useScrollTop(scrollContainerStateCallback, smoothScrollT
|
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
}, [externalWindow, scrollContainerStateCallback, smoothScrollTargetReached]);
|
|
45
|
-
useEffect(function () {
|
|
46
|
-
var localRef = customScrollParent
|
|
47
|
-
? customScrollParent
|
|
48
|
-
: scrollerRef.current;
|
|
44
|
+
React.useEffect(function () {
|
|
45
|
+
var localRef = customScrollParent ? customScrollParent : scrollerRef.current;
|
|
49
46
|
scrollerRefCallback(customScrollParent ? customScrollParent : scrollerRef.current);
|
|
50
|
-
handler({ target: localRef });
|
|
47
|
+
handler({ target: localRef, suppressFlushSync: true });
|
|
51
48
|
localRef.addEventListener('scroll', handler, { passive: true });
|
|
52
49
|
return function () {
|
|
53
50
|
scrollerRefCallback(null);
|
|
54
51
|
localRef.removeEventListener('scroll', handler);
|
|
55
52
|
};
|
|
56
|
-
}, [
|
|
57
|
-
scrollerRef,
|
|
58
|
-
handler,
|
|
59
|
-
scrollerElement,
|
|
60
|
-
scrollerRefCallback,
|
|
61
|
-
customScrollParent,
|
|
62
|
-
]);
|
|
53
|
+
}, [scrollerRef, handler, scrollerElement, scrollerRefCallback, customScrollParent]);
|
|
63
54
|
function scrollToCallback(location) {
|
|
64
55
|
var scrollerElement = scrollerRef.current;
|
|
65
|
-
if (!scrollerElement ||
|
|
66
|
-
('offsetHeight' in scrollerElement && scrollerElement.offsetHeight === 0)) {
|
|
56
|
+
if (!scrollerElement || ('offsetHeight' in scrollerElement && scrollerElement.offsetHeight === 0)) {
|
|
67
57
|
return;
|
|
68
58
|
}
|
|
69
59
|
var isSmooth = location.behavior === 'smooth';
|
|
@@ -86,13 +76,8 @@ export default function useScrollTop(scrollContainerStateCallback, smoothScrollT
|
|
|
86
76
|
// avoid system hanging because the DOM never called back
|
|
87
77
|
// with the scrollTop
|
|
88
78
|
// scroller is already at this location
|
|
89
|
-
if (approximatelyEqual(offsetHeight, scrollHeight) ||
|
|
90
|
-
|
|
91
|
-
scrollContainerStateCallback({
|
|
92
|
-
scrollTop: scrollTop,
|
|
93
|
-
scrollHeight: scrollHeight,
|
|
94
|
-
viewportHeight: offsetHeight,
|
|
95
|
-
});
|
|
79
|
+
if (approximatelyEqual(offsetHeight, scrollHeight) || location.top === scrollTop) {
|
|
80
|
+
scrollContainerStateCallback({ scrollTop: scrollTop, scrollHeight: scrollHeight, viewportHeight: offsetHeight });
|
|
96
81
|
if (isSmooth) {
|
|
97
82
|
smoothScrollTargetReached(true);
|
|
98
83
|
}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useRcPortalWindowContext } from '
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useRcPortalWindowContext } from './useRcPortalWindowContext';
|
|
3
3
|
export function useSizeWithElRef(callback, enabled) {
|
|
4
4
|
if (enabled === void 0) { enabled = true; }
|
|
5
|
-
var ref = useRef(null);
|
|
5
|
+
var ref = React.useRef(null);
|
|
6
6
|
var _a = useRcPortalWindowContext().externalWindow, externalWindow = _a === void 0 ? window : _a;
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8
7
|
var callbackRef = function (_el) {
|
|
9
|
-
// eslint-disable-next-line no-void
|
|
10
8
|
void 0;
|
|
11
9
|
};
|
|
12
|
-
// TODO: fix after upgrade ts
|
|
13
10
|
if (typeof externalWindow['ResizeObserver'] !== 'undefined') {
|
|
14
|
-
var observer_1 =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
var observer_1 = React.useMemo(function () {
|
|
12
|
+
return new externalWindow['ResizeObserver'](function (entries) {
|
|
13
|
+
var element = entries[0].target;
|
|
14
|
+
if (element.offsetParent !== null) {
|
|
15
|
+
callback(element);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}, [callback]);
|
|
20
19
|
callbackRef = function (elRef) {
|
|
21
20
|
if (elRef && enabled) {
|
|
22
21
|
observer_1.observe(elRef);
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useRcPortalWindowContext } from '../../../../foundation';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
import { useSizeWithElRef } from './useSize';
|
|
3
|
+
import { useRcPortalWindowContext } from './useRcPortalWindowContext';
|
|
4
4
|
export default function useWindowViewportRectRef(callback, customScrollParent) {
|
|
5
|
-
var viewportInfo = useRef(null);
|
|
5
|
+
var viewportInfo = React.useRef(null);
|
|
6
6
|
var _a = useRcPortalWindowContext().externalWindow, externalWindow = _a === void 0 ? window : _a;
|
|
7
|
-
var calculateInfo = useCallback(function (element) {
|
|
8
|
-
if (element === null) {
|
|
7
|
+
var calculateInfo = React.useCallback(function (element) {
|
|
8
|
+
if (element === null || !element.offsetParent) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
var rect = element.getBoundingClientRect();
|
|
12
12
|
var visibleWidth = rect.width;
|
|
13
|
-
// eslint-disable-next-line one-var
|
|
14
13
|
var visibleHeight, offsetTop;
|
|
15
14
|
if (customScrollParent) {
|
|
16
15
|
var customScrollParentRect = customScrollParent.getBoundingClientRect();
|
|
@@ -30,10 +29,10 @@ export default function useWindowViewportRectRef(callback, customScrollParent) {
|
|
|
30
29
|
callback(viewportInfo.current);
|
|
31
30
|
}, [callback, customScrollParent, externalWindow]);
|
|
32
31
|
var _b = useSizeWithElRef(calculateInfo), callbackRef = _b.callbackRef, ref = _b.ref;
|
|
33
|
-
var scrollAndResizeEventHandler = useCallback(function () {
|
|
32
|
+
var scrollAndResizeEventHandler = React.useCallback(function () {
|
|
34
33
|
calculateInfo(ref.current);
|
|
35
34
|
}, [calculateInfo, ref]);
|
|
36
|
-
useEffect(function () {
|
|
35
|
+
React.useEffect(function () {
|
|
37
36
|
if (customScrollParent) {
|
|
38
37
|
customScrollParent.addEventListener('scroll', scrollAndResizeEventHandler);
|
|
39
38
|
var observer_1 = new externalWindow['ResizeObserver'](scrollAndResizeEventHandler);
|
|
@@ -43,12 +42,14 @@ export default function useWindowViewportRectRef(callback, customScrollParent) {
|
|
|
43
42
|
observer_1.unobserve(customScrollParent);
|
|
44
43
|
};
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
else {
|
|
46
|
+
externalWindow.addEventListener('scroll', scrollAndResizeEventHandler);
|
|
47
|
+
externalWindow.addEventListener('resize', scrollAndResizeEventHandler);
|
|
48
|
+
return function () {
|
|
49
|
+
externalWindow.removeEventListener('scroll', scrollAndResizeEventHandler);
|
|
50
|
+
externalWindow.removeEventListener('resize', scrollAndResizeEventHandler);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
52
53
|
}, [scrollAndResizeEventHandler, customScrollParent, externalWindow]);
|
|
53
54
|
return callbackRef;
|
|
54
55
|
}
|
|
@@ -1,39 +1,17 @@
|
|
|
1
|
-
import { __read
|
|
2
|
-
import * as u from '
|
|
3
|
-
import {
|
|
4
|
-
import { propsReadySystem } from './propsReadySystem';
|
|
1
|
+
import { __read } from "tslib";
|
|
2
|
+
import * as u from './urx';
|
|
3
|
+
import { listStateSystem, buildListStateFromItemCount } from './listStateSystem';
|
|
5
4
|
import { sizeSystem } from './sizeSystem';
|
|
5
|
+
import { propsReadySystem } from './propsReadySystem';
|
|
6
|
+
import { initialTopMostItemIndexSystem } from './initialTopMostItemIndexSystem';
|
|
6
7
|
export var initialItemCountSystem = u.system(function (_a) {
|
|
7
|
-
var _b = __read(_a,
|
|
8
|
-
var initialItemCount = u.statefulStream(0);
|
|
8
|
+
var _b = __read(_a, 4), _c = _b[0], sizes = _c.sizes, firstItemIndex = _c.firstItemIndex, data = _c.data, gap = _c.gap, initialTopMostItemIndex = _b[1].initialTopMostItemIndex, _d = _b[2], initialItemCount = _d.initialItemCount, listState = _d.listState, didMount = _b[3].didMount;
|
|
9
9
|
u.connect(u.pipe(didMount, u.withLatestFrom(initialItemCount), u.filter(function (_a) {
|
|
10
10
|
var _b = __read(_a, 2), count = _b[1];
|
|
11
11
|
return count !== 0;
|
|
12
|
-
}), u.withLatestFrom(sizes, firstItemIndex, data), u.map(function (_a) {
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
var includedGroupsCount = 0;
|
|
16
|
-
if (sizes.groupIndices.length > 0) {
|
|
17
|
-
try {
|
|
18
|
-
for (var _f = __values(sizes.groupIndices), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
19
|
-
var index = _g.value;
|
|
20
|
-
if (index - includedGroupsCount >= count) {
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
includedGroupsCount++;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
27
|
-
finally {
|
|
28
|
-
try {
|
|
29
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
30
|
-
}
|
|
31
|
-
finally { if (e_1) throw e_1.error; }
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
var adjustedCount = count + includedGroupsCount;
|
|
35
|
-
var items = Array.from({ length: adjustedCount }).map(function (_, index) { return ({ index: index, size: 0, offset: 0, data: data[index] }); });
|
|
36
|
-
return buildListState(items, [], adjustedCount, sizes, firstItemIndex);
|
|
12
|
+
}), u.withLatestFrom(initialTopMostItemIndex, sizes, firstItemIndex, gap, data), u.map(function (_a) {
|
|
13
|
+
var _b = __read(_a, 6), _c = __read(_b[0], 2), count = _c[1], initialTopMostItemIndexValue = _b[1], sizes = _b[2], firstItemIndex = _b[3], gap = _b[4], _d = _b[5], data = _d === void 0 ? [] : _d;
|
|
14
|
+
return buildListStateFromItemCount(count, initialTopMostItemIndexValue, sizes, firstItemIndex, gap, data);
|
|
37
15
|
})), listState);
|
|
38
|
-
return {
|
|
39
|
-
}, u.tup(sizeSystem, listStateSystem, propsReadySystem), { singleton: true });
|
|
16
|
+
return {};
|
|
17
|
+
}, u.tup(sizeSystem, initialTopMostItemIndexSystem, listStateSystem, propsReadySystem), { singleton: true });
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __read } from "tslib";
|
|
2
|
-
import * as u from '
|
|
3
|
-
import { domIOSystem } from './domIOSystem';
|
|
2
|
+
import * as u from './urx';
|
|
4
3
|
import { propsReadySystem } from './propsReadySystem';
|
|
5
|
-
import {
|
|
4
|
+
import { domIOSystem } from './domIOSystem';
|
|
5
|
+
import { listStateSystem } from './listStateSystem';
|
|
6
6
|
export var initialScrollTopSystem = u.system(function (_a) {
|
|
7
|
-
var _b = __read(_a, 3),
|
|
7
|
+
var _b = __read(_a, 3), didMount = _b[0].didMount, scrollTo = _b[1].scrollTo, listState = _b[2].listState;
|
|
8
8
|
var initialScrollTop = u.statefulStream(0);
|
|
9
9
|
u.subscribe(u.pipe(didMount, u.withLatestFrom(initialScrollTop), u.filter(function (_a) {
|
|
10
10
|
var _b = __read(_a, 2), offset = _b[1];
|
|
@@ -13,8 +13,8 @@ export var initialScrollTopSystem = u.system(function (_a) {
|
|
|
13
13
|
var _b = __read(_a, 2), offset = _b[1];
|
|
14
14
|
return ({ top: offset });
|
|
15
15
|
})), function (location) {
|
|
16
|
-
u.handleNext(u.pipe(
|
|
17
|
-
|
|
16
|
+
u.handleNext(u.pipe(listState, u.skip(1), u.filter(function (state) { return state.items.length > 1; })), function () {
|
|
17
|
+
requestAnimationFrame(function () {
|
|
18
18
|
u.publish(scrollTo, location);
|
|
19
19
|
});
|
|
20
20
|
});
|
|
@@ -22,4 +22,4 @@ export var initialScrollTopSystem = u.system(function (_a) {
|
|
|
22
22
|
return {
|
|
23
23
|
initialScrollTop: initialScrollTop,
|
|
24
24
|
};
|
|
25
|
-
}, u.tup(
|
|
25
|
+
}, u.tup(propsReadySystem, domIOSystem, listStateSystem), { singleton: true });
|
|
@@ -1,40 +1,33 @@
|
|
|
1
1
|
import { __read } from "tslib";
|
|
2
|
-
import * as u from '
|
|
2
|
+
import * as u from './urx';
|
|
3
3
|
import { empty } from './AATree';
|
|
4
|
+
import { sizeSystem } from './sizeSystem';
|
|
4
5
|
import { domIOSystem } from './domIOSystem';
|
|
5
|
-
import { propsReadySystem } from './propsReadySystem';
|
|
6
6
|
import { scrollToIndexSystem } from './scrollToIndexSystem';
|
|
7
|
-
import {
|
|
7
|
+
import { propsReadySystem } from './propsReadySystem';
|
|
8
|
+
import { skipFrames } from './utils/skipFrames';
|
|
8
9
|
export function getInitialTopMostItemIndexNumber(location, totalCount) {
|
|
9
10
|
var lastIndex = totalCount - 1;
|
|
10
|
-
var index = typeof location === 'number'
|
|
11
|
-
? location
|
|
12
|
-
: location.index === 'LAST'
|
|
13
|
-
? lastIndex
|
|
14
|
-
: location.index;
|
|
11
|
+
var index = typeof location === 'number' ? location : location.index === 'LAST' ? lastIndex : location.index;
|
|
15
12
|
return index;
|
|
16
13
|
}
|
|
17
14
|
export var initialTopMostItemIndexSystem = u.system(function (_a) {
|
|
18
15
|
var _b = __read(_a, 4), _c = _b[0], sizes = _c.sizes, listRefresh = _c.listRefresh, defaultItemSize = _c.defaultItemSize, scrollTop = _b[1].scrollTop, scrollToIndex = _b[2].scrollToIndex, didMount = _b[3].didMount;
|
|
19
16
|
var scrolledToInitialItem = u.statefulStream(true);
|
|
20
17
|
var initialTopMostItemIndex = u.statefulStream(0);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
u.filter(function (_a) {
|
|
18
|
+
var scrollScheduled = u.statefulStream(false);
|
|
19
|
+
u.connect(u.pipe(didMount, u.withLatestFrom(initialTopMostItemIndex), u.filter(function (_a) {
|
|
24
20
|
var _b = __read(_a, 2), _ = _b[0], location = _b[1];
|
|
25
21
|
return !!location;
|
|
26
22
|
}), u.mapTo(false)), scrolledToInitialItem);
|
|
27
|
-
u.subscribe(u.pipe(u.combineLatest(listRefresh, didMount), u.withLatestFrom(scrolledToInitialItem, sizes, defaultItemSize), u.filter(function (_a) {
|
|
28
|
-
var _b = __read(_a,
|
|
29
|
-
return
|
|
30
|
-
(!empty(sizeTree) || defaultItemSize !== undefined) &&
|
|
31
|
-
!scrolledToInitialItem);
|
|
23
|
+
u.subscribe(u.pipe(u.combineLatest(listRefresh, didMount), u.withLatestFrom(scrolledToInitialItem, sizes, defaultItemSize, scrollScheduled), u.filter(function (_a) {
|
|
24
|
+
var _b = __read(_a, 5), _c = __read(_b[0], 2), didMount = _c[1], scrolledToInitialItem = _b[1], sizeTree = _b[2].sizeTree, defaultItemSize = _b[3], scrollScheduled = _b[4];
|
|
25
|
+
return didMount && (!empty(sizeTree) || u.isDefined(defaultItemSize)) && !scrolledToInitialItem && !scrollScheduled;
|
|
32
26
|
}), u.withLatestFrom(initialTopMostItemIndex)), function (_a) {
|
|
33
27
|
var _b = __read(_a, 2), initialTopMostItemIndex = _b[1];
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
28
|
+
u.publish(scrollScheduled, true);
|
|
29
|
+
skipFrames(3, function () {
|
|
30
|
+
u.handleNext(scrollTop, function () { return u.publish(scrolledToInitialItem, true); });
|
|
38
31
|
u.publish(scrollToIndex, initialTopMostItemIndex);
|
|
39
32
|
});
|
|
40
33
|
});
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { __assign, __read, __values } from "tslib";
|
|
2
|
-
import * as u from '
|
|
2
|
+
import * as u from './urx';
|
|
3
3
|
import { empty, findMaxKeyValue, rangesWithin } from './AATree';
|
|
4
|
-
import { rangeComparator, tupleComparator } from './comparators';
|
|
5
4
|
import { groupedListSystem } from './groupedListSystem';
|
|
6
|
-
import { getInitialTopMostItemIndexNumber, initialTopMostItemIndexSystem
|
|
5
|
+
import { getInitialTopMostItemIndexNumber, initialTopMostItemIndexSystem } from './initialTopMostItemIndexSystem';
|
|
7
6
|
import { propsReadySystem } from './propsReadySystem';
|
|
8
7
|
import { scrollToIndexSystem } from './scrollToIndexSystem';
|
|
9
8
|
import { sizeRangeSystem } from './sizeRangeSystem';
|
|
10
|
-
import {
|
|
9
|
+
import { originalIndexFromItemIndex, sizeSystem, hasGroups, rangesWithinOffsets } from './sizeSystem';
|
|
11
10
|
import { stateFlagsSystem } from './stateFlagsSystem';
|
|
11
|
+
import { rangeComparator, tupleComparator } from './comparators';
|
|
12
|
+
import { recalcSystem } from './recalcSystem';
|
|
12
13
|
function probeItemSet(index, sizes, data) {
|
|
13
14
|
if (hasGroups(sizes)) {
|
|
14
15
|
var itemIndex = originalIndexFromItemIndex(index, sizes);
|
|
@@ -29,6 +30,7 @@ var EMPTY_LIST_STATE = {
|
|
|
29
30
|
bottom: 0,
|
|
30
31
|
topListHeight: 0,
|
|
31
32
|
totalCount: 0,
|
|
33
|
+
firstItemIndex: 0,
|
|
32
34
|
};
|
|
33
35
|
function transposeItems(items, sizes, firstItemIndex) {
|
|
34
36
|
var e_1, _a;
|
|
@@ -42,7 +44,7 @@ function transposeItems(items, sizes, firstItemIndex) {
|
|
|
42
44
|
var endIndex = items[items.length - 1].index;
|
|
43
45
|
var transposedItems = [];
|
|
44
46
|
var groupRanges = rangesWithin(sizes.groupOffsetTree, startIndex, endIndex);
|
|
45
|
-
var currentRange;
|
|
47
|
+
var currentRange = undefined;
|
|
46
48
|
var currentGroupIndex = 0;
|
|
47
49
|
try {
|
|
48
50
|
for (var items_1 = __values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) {
|
|
@@ -76,7 +78,7 @@ function transposeItems(items, sizes, firstItemIndex) {
|
|
|
76
78
|
}
|
|
77
79
|
return transposedItems;
|
|
78
80
|
}
|
|
79
|
-
export function buildListState(items, topItems, totalCount, sizes, firstItemIndex) {
|
|
81
|
+
export function buildListState(items, topItems, totalCount, gap, sizes, firstItemIndex) {
|
|
80
82
|
var lastSize = sizes.lastSize, lastOffset = sizes.lastOffset, lastIndex = sizes.lastIndex;
|
|
81
83
|
var offsetTop = 0;
|
|
82
84
|
var bottom = 0;
|
|
@@ -85,7 +87,8 @@ export function buildListState(items, topItems, totalCount, sizes, firstItemInde
|
|
|
85
87
|
var lastItem = items[items.length - 1];
|
|
86
88
|
bottom = lastItem.offset + lastItem.size;
|
|
87
89
|
}
|
|
88
|
-
var
|
|
90
|
+
var itemCount = totalCount - lastIndex;
|
|
91
|
+
var total = lastOffset + itemCount * lastSize + (itemCount - 1) * gap;
|
|
89
92
|
var top = offsetTop;
|
|
90
93
|
var offsetBottom = total - bottom;
|
|
91
94
|
return {
|
|
@@ -97,26 +100,76 @@ export function buildListState(items, topItems, totalCount, sizes, firstItemInde
|
|
|
97
100
|
top: top,
|
|
98
101
|
bottom: bottom,
|
|
99
102
|
totalCount: totalCount,
|
|
103
|
+
firstItemIndex: firstItemIndex,
|
|
100
104
|
};
|
|
101
105
|
}
|
|
106
|
+
export function buildListStateFromItemCount(itemCount, initialTopMostItemIndex, sizes, firstItemIndex, gap, data) {
|
|
107
|
+
var e_2, _a;
|
|
108
|
+
var includedGroupsCount = 0;
|
|
109
|
+
if (sizes.groupIndices.length > 0) {
|
|
110
|
+
try {
|
|
111
|
+
for (var _b = __values(sizes.groupIndices), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
112
|
+
var index = _c.value;
|
|
113
|
+
if (index - includedGroupsCount >= itemCount) {
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
includedGroupsCount++;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
120
|
+
finally {
|
|
121
|
+
try {
|
|
122
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
123
|
+
}
|
|
124
|
+
finally { if (e_2) throw e_2.error; }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
var adjustedCount = itemCount + includedGroupsCount;
|
|
128
|
+
var initialTopMostItemIndexNumber = getInitialTopMostItemIndexNumber(initialTopMostItemIndex, adjustedCount);
|
|
129
|
+
var items = Array.from({ length: adjustedCount }).map(function (_, index) { return ({
|
|
130
|
+
index: index + initialTopMostItemIndexNumber,
|
|
131
|
+
size: 0,
|
|
132
|
+
offset: 0,
|
|
133
|
+
data: data[index + initialTopMostItemIndexNumber],
|
|
134
|
+
}); });
|
|
135
|
+
return buildListState(items, [], adjustedCount, gap, sizes, firstItemIndex);
|
|
136
|
+
}
|
|
102
137
|
export var listStateSystem = u.system(function (_a) {
|
|
103
|
-
var _b = __read(_a,
|
|
138
|
+
var _b = __read(_a, 8), _c = _b[0], sizes = _c.sizes, totalCount = _c.totalCount, data = _c.data, firstItemIndex = _c.firstItemIndex, gap = _c.gap, groupedListSystem = _b[1], _d = _b[2], visibleRange = _d.visibleRange, listBoundary = _d.listBoundary, rangeTopListHeight = _d.topListHeight, _e = _b[3], scrolledToInitialItem = _e.scrolledToInitialItem, initialTopMostItemIndex = _e.initialTopMostItemIndex, topListHeight = _b[4].topListHeight, stateFlags = _b[5], didMount = _b[6].didMount, recalcInProgress = _b[7].recalcInProgress;
|
|
104
139
|
var topItemsIndexes = u.statefulStream([]);
|
|
140
|
+
var initialItemCount = u.statefulStream(0);
|
|
105
141
|
var itemsRendered = u.stream();
|
|
106
142
|
u.connect(groupedListSystem.topItemsIndexes, topItemsIndexes);
|
|
107
|
-
var listState = u.statefulStreamFromEmitter(u.pipe(u.combineLatest(didMount, u.duc(visibleRange), u.duc(totalCount), u.duc(sizes), u.duc(initialTopMostItemIndex), scrolledToInitialItem, u.duc(topItemsIndexes), u.duc(firstItemIndex), data), u.filter(function (_a) {
|
|
108
|
-
var _b = __read(_a,
|
|
109
|
-
|
|
143
|
+
var listState = u.statefulStreamFromEmitter(u.pipe(u.combineLatest(didMount, recalcInProgress, u.duc(visibleRange, tupleComparator), u.duc(totalCount), u.duc(sizes), u.duc(initialTopMostItemIndex), scrolledToInitialItem, u.duc(topItemsIndexes), u.duc(firstItemIndex), u.duc(gap), data), u.filter(function (_a) {
|
|
144
|
+
var _b = __read(_a, 11), mount = _b[0], recalcInProgress = _b[1], totalCount = _b[3], data = _b[10];
|
|
145
|
+
// When data length changes, it is synced to totalCount, both of which trigger a recalc separately.
|
|
146
|
+
// Recalc should be skipped then, as the calculation expects both data and totalCount to be in sync.
|
|
147
|
+
var dataChangeInProgress = data && data.length !== totalCount;
|
|
148
|
+
return mount && !recalcInProgress && !dataChangeInProgress;
|
|
110
149
|
}), u.map(function (_a) {
|
|
111
|
-
var
|
|
112
|
-
var _c = __read(_a,
|
|
150
|
+
var e_3, _b;
|
|
151
|
+
var _c = __read(_a, 11), _d = __read(_c[2], 2), startOffset = _d[0], endOffset = _d[1], totalCount = _c[3], sizes = _c[4], initialTopMostItemIndex = _c[5], scrolledToInitialItem = _c[6], topItemsIndexes = _c[7], firstItemIndex = _c[8], gap = _c[9], data = _c[10];
|
|
113
152
|
var sizesValue = sizes;
|
|
114
153
|
var sizeTree = sizesValue.sizeTree, offsetTree = sizesValue.offsetTree;
|
|
115
|
-
|
|
116
|
-
|
|
154
|
+
var initialItemCountValue = u.getValue(initialItemCount);
|
|
155
|
+
if (totalCount === 0) {
|
|
156
|
+
return __assign(__assign({}, EMPTY_LIST_STATE), { totalCount: totalCount });
|
|
157
|
+
}
|
|
158
|
+
// no container measruements yet
|
|
159
|
+
if (startOffset === 0 && endOffset === 0) {
|
|
160
|
+
if (initialItemCountValue === 0) {
|
|
161
|
+
return __assign(__assign({}, EMPTY_LIST_STATE), { totalCount: totalCount });
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
return buildListStateFromItemCount(initialItemCountValue, initialTopMostItemIndex, sizes, firstItemIndex, gap, data || []);
|
|
165
|
+
}
|
|
117
166
|
}
|
|
118
167
|
if (empty(sizeTree)) {
|
|
119
|
-
|
|
168
|
+
if (initialItemCountValue > 0) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
var state = buildListState(probeItemSet(getInitialTopMostItemIndexNumber(initialTopMostItemIndex, totalCount), sizesValue, data), [], totalCount, gap, sizesValue, firstItemIndex);
|
|
172
|
+
return state;
|
|
120
173
|
}
|
|
121
174
|
var topItems = [];
|
|
122
175
|
if (topItemsIndexes.length > 0) {
|
|
@@ -130,42 +183,35 @@ export var listStateSystem = u.system(function (_a) {
|
|
|
130
183
|
var rangeStartIndex = Math.max(range.start, startIndex);
|
|
131
184
|
var rangeEndIndex = Math.min(range.end, endIndex);
|
|
132
185
|
for (var i = rangeStartIndex; i <= rangeEndIndex; i++) {
|
|
133
|
-
topItems.push({
|
|
134
|
-
index: i,
|
|
135
|
-
size: size,
|
|
136
|
-
offset: offset,
|
|
137
|
-
data: data && data[i],
|
|
138
|
-
});
|
|
186
|
+
topItems.push({ index: i, size: size, offset: offset, data: data && data[i] });
|
|
139
187
|
offset += size;
|
|
140
188
|
}
|
|
141
189
|
}
|
|
142
190
|
}
|
|
143
|
-
catch (
|
|
191
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
144
192
|
finally {
|
|
145
193
|
try {
|
|
146
194
|
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
147
195
|
}
|
|
148
|
-
finally { if (
|
|
196
|
+
finally { if (e_3) throw e_3.error; }
|
|
149
197
|
}
|
|
150
198
|
}
|
|
151
199
|
// If the list hasn't scrolled to the initial item because the initial item was set,
|
|
152
200
|
// render empty list.
|
|
153
201
|
//
|
|
154
|
-
// This is a condition to be evaluated
|
|
202
|
+
// This is a condition to be evaluated after the probe check cycle, do not merge
|
|
155
203
|
// with the totalCount check above
|
|
156
204
|
if (!scrolledToInitialItem) {
|
|
157
|
-
return buildListState([], topItems, totalCount, sizesValue, firstItemIndex);
|
|
205
|
+
return buildListState([], topItems, totalCount, gap, sizesValue, firstItemIndex);
|
|
158
206
|
}
|
|
159
|
-
var minStartIndex = topItemsIndexes.length > 0
|
|
160
|
-
? topItemsIndexes[topItemsIndexes.length - 1] + 1
|
|
161
|
-
: 0;
|
|
207
|
+
var minStartIndex = topItemsIndexes.length > 0 ? topItemsIndexes[topItemsIndexes.length - 1] + 1 : 0;
|
|
162
208
|
var offsetPointRanges = rangesWithinOffsets(offsetTree, startOffset, endOffset, minStartIndex);
|
|
163
209
|
if (offsetPointRanges.length === 0) {
|
|
164
210
|
return null;
|
|
165
211
|
}
|
|
166
212
|
var maxIndex = totalCount - 1;
|
|
167
213
|
var items = u.tap([], function (result) {
|
|
168
|
-
var
|
|
214
|
+
var e_4, _a;
|
|
169
215
|
try {
|
|
170
216
|
for (var offsetPointRanges_1 = __values(offsetPointRanges), offsetPointRanges_1_1 = offsetPointRanges_1.next(); !offsetPointRanges_1_1.done; offsetPointRanges_1_1 = offsetPointRanges_1.next()) {
|
|
171
217
|
var range = offsetPointRanges_1_1.value;
|
|
@@ -174,8 +220,9 @@ export var listStateSystem = u.system(function (_a) {
|
|
|
174
220
|
var rangeStartIndex = range.start;
|
|
175
221
|
var size = point.size;
|
|
176
222
|
if (point.offset < startOffset) {
|
|
177
|
-
rangeStartIndex += Math.floor((startOffset - point.offset) / size);
|
|
178
|
-
|
|
223
|
+
rangeStartIndex += Math.floor((startOffset - point.offset + gap) / (size + gap));
|
|
224
|
+
var itemCount = rangeStartIndex - range.start;
|
|
225
|
+
offset += itemCount * size + itemCount * gap;
|
|
179
226
|
}
|
|
180
227
|
if (rangeStartIndex < minStartIndex) {
|
|
181
228
|
offset += (minStartIndex - rangeStartIndex) * size;
|
|
@@ -186,28 +233,25 @@ export var listStateSystem = u.system(function (_a) {
|
|
|
186
233
|
if (offset >= endOffset) {
|
|
187
234
|
break;
|
|
188
235
|
}
|
|
189
|
-
result.push({
|
|
190
|
-
|
|
191
|
-
size: size,
|
|
192
|
-
offset: offset,
|
|
193
|
-
data: data && data[i],
|
|
194
|
-
});
|
|
195
|
-
offset += size;
|
|
236
|
+
result.push({ index: i, size: size, offset: offset, data: data && data[i] });
|
|
237
|
+
offset += size + gap;
|
|
196
238
|
}
|
|
197
239
|
}
|
|
198
240
|
}
|
|
199
|
-
catch (
|
|
241
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
200
242
|
finally {
|
|
201
243
|
try {
|
|
202
244
|
if (offsetPointRanges_1_1 && !offsetPointRanges_1_1.done && (_a = offsetPointRanges_1.return)) _a.call(offsetPointRanges_1);
|
|
203
245
|
}
|
|
204
|
-
finally { if (
|
|
246
|
+
finally { if (e_4) throw e_4.error; }
|
|
205
247
|
}
|
|
206
248
|
});
|
|
207
|
-
return buildListState(items, topItems, totalCount, sizesValue, firstItemIndex);
|
|
208
|
-
}),
|
|
209
|
-
|
|
210
|
-
u.
|
|
249
|
+
return buildListState(items, topItems, totalCount, gap, sizesValue, firstItemIndex);
|
|
250
|
+
}),
|
|
251
|
+
//@ts-expect-error filter needs to be fixed
|
|
252
|
+
u.filter(function (value) { return value !== null; }), u.distinctUntilChanged()), EMPTY_LIST_STATE);
|
|
253
|
+
u.connect(u.pipe(data, u.filter(u.isDefined), u.map(function (data) { return data === null || data === void 0 ? void 0 : data.length; })), totalCount);
|
|
254
|
+
u.connect(u.pipe(listState, u.map(function (value) { return value.topListHeight; })), topListHeight);
|
|
211
255
|
u.connect(topListHeight, rangeTopListHeight);
|
|
212
256
|
u.connect(u.pipe(listState, u.map(function (state) { return [state.top, state.bottom]; })), listBoundary);
|
|
213
257
|
u.connect(u.pipe(listState, u.map(function (state) { return state.items; })), itemsRendered);
|
|
@@ -236,15 +280,18 @@ export var listStateSystem = u.system(function (_a) {
|
|
|
236
280
|
return items.length > 0;
|
|
237
281
|
}), u.map(function (_a) {
|
|
238
282
|
var items = _a.items;
|
|
283
|
+
var startIndex = 0;
|
|
284
|
+
var endIndex = items.length - 1;
|
|
285
|
+
while (items[startIndex].type === 'group' && startIndex < endIndex) {
|
|
286
|
+
startIndex++;
|
|
287
|
+
}
|
|
288
|
+
while (items[endIndex].type === 'group' && endIndex > startIndex) {
|
|
289
|
+
endIndex--;
|
|
290
|
+
}
|
|
239
291
|
return {
|
|
240
|
-
startIndex: items[
|
|
241
|
-
endIndex: items[
|
|
292
|
+
startIndex: items[startIndex].index,
|
|
293
|
+
endIndex: items[endIndex].index,
|
|
242
294
|
};
|
|
243
295
|
}), u.distinctUntilChanged(rangeComparator)));
|
|
244
|
-
return __assign({ listState: listState,
|
|
245
|
-
|
|
246
|
-
endReached: endReached,
|
|
247
|
-
startReached: startReached,
|
|
248
|
-
rangeChanged: rangeChanged,
|
|
249
|
-
itemsRendered: itemsRendered }, stateFlags);
|
|
250
|
-
}, u.tup(sizeSystem, groupedListSystem, sizeRangeSystem, initialTopMostItemIndexSystem, scrollToIndexSystem, stateFlagsSystem, propsReadySystem), { singleton: true });
|
|
296
|
+
return __assign({ listState: listState, topItemsIndexes: topItemsIndexes, endReached: endReached, startReached: startReached, rangeChanged: rangeChanged, itemsRendered: itemsRendered, initialItemCount: initialItemCount }, stateFlags);
|
|
297
|
+
}, u.tup(sizeSystem, groupedListSystem, sizeRangeSystem, initialTopMostItemIndexSystem, scrollToIndexSystem, stateFlagsSystem, propsReadySystem, recalcSystem), { singleton: true });
|