@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,4 +1,4 @@
|
|
|
1
|
-
import * as u from '
|
|
1
|
+
import * as u from './urx';
|
|
2
2
|
export var domIOSystem = u.system(function () {
|
|
3
3
|
var scrollContainerState = u.stream();
|
|
4
4
|
var scrollTop = u.stream();
|
|
@@ -8,11 +8,12 @@ export var domIOSystem = u.system(function () {
|
|
|
8
8
|
var viewportHeight = u.stream();
|
|
9
9
|
var scrollHeight = u.stream();
|
|
10
10
|
var headerHeight = u.statefulStream(0);
|
|
11
|
+
var fixedHeaderHeight = u.statefulStream(0);
|
|
12
|
+
var fixedFooterHeight = u.statefulStream(0);
|
|
11
13
|
var footerHeight = u.statefulStream(0);
|
|
12
14
|
var scrollTo = u.stream();
|
|
13
15
|
var scrollBy = u.stream();
|
|
14
16
|
var scrollingInProgress = u.statefulStream(false);
|
|
15
|
-
var react18ConcurrentRendering = u.statefulStream(false);
|
|
16
17
|
u.connect(u.pipe(scrollContainerState, u.map(function (_a) {
|
|
17
18
|
var scrollTop = _a.scrollTop;
|
|
18
19
|
return scrollTop;
|
|
@@ -28,10 +29,11 @@ export var domIOSystem = u.system(function () {
|
|
|
28
29
|
scrollTop: scrollTop,
|
|
29
30
|
viewportHeight: viewportHeight,
|
|
30
31
|
headerHeight: headerHeight,
|
|
32
|
+
fixedHeaderHeight: fixedHeaderHeight,
|
|
33
|
+
fixedFooterHeight: fixedFooterHeight,
|
|
31
34
|
footerHeight: footerHeight,
|
|
32
35
|
scrollHeight: scrollHeight,
|
|
33
36
|
smoothScrollTargetReached: smoothScrollTargetReached,
|
|
34
|
-
react18ConcurrentRendering: react18ConcurrentRendering,
|
|
35
37
|
// signals
|
|
36
38
|
scrollTo: scrollTo,
|
|
37
39
|
scrollBy: scrollBy,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { __read } from "tslib";
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
3
|
-
import * as u from '
|
|
4
|
-
import { domIOSystem } from './domIOSystem';
|
|
5
|
-
import { initialTopMostItemIndexSystem } from './initialTopMostItemIndexSystem';
|
|
6
|
-
import { loggerSystem, LogLevel } from './loggerSystem';
|
|
7
|
-
import { propsReadySystem } from './propsReadySystem';
|
|
3
|
+
import * as u from './urx';
|
|
8
4
|
import { scrollToIndexSystem } from './scrollToIndexSystem';
|
|
9
5
|
import { sizeSystem } from './sizeSystem';
|
|
10
6
|
import { stateFlagsSystem } from './stateFlagsSystem';
|
|
7
|
+
import { initialTopMostItemIndexSystem } from './initialTopMostItemIndexSystem';
|
|
8
|
+
import { propsReadySystem } from './propsReadySystem';
|
|
9
|
+
import { loggerSystem, LogLevel } from './loggerSystem';
|
|
10
|
+
import { domIOSystem } from './domIOSystem';
|
|
11
11
|
function normalizeFollowOutput(follow) {
|
|
12
12
|
if (!follow) {
|
|
13
13
|
return false;
|
|
@@ -23,6 +23,7 @@ var behaviorFromFollowOutput = function (follow, isAtBottom) {
|
|
|
23
23
|
export var followOutputSystem = u.system(function (_a) {
|
|
24
24
|
var _b = __read(_a, 7), _c = _b[0], totalCount = _c.totalCount, listRefresh = _c.listRefresh, _d = _b[1], isAtBottom = _d.isAtBottom, atBottomState = _d.atBottomState, scrollToIndex = _b[2].scrollToIndex, scrolledToInitialItem = _b[3].scrolledToInitialItem, _e = _b[4], propsReady = _e.propsReady, didMount = _e.didMount, log = _b[5].log, scrollingInProgress = _b[6].scrollingInProgress;
|
|
25
25
|
var followOutput = u.statefulStream(false);
|
|
26
|
+
var autoscrollToBottom = u.stream();
|
|
26
27
|
var pendingScrollHandle = null;
|
|
27
28
|
function scrollToBottom(followOutputBehavior) {
|
|
28
29
|
u.publish(scrollToIndex, {
|
|
@@ -57,6 +58,15 @@ export var followOutputSystem = u.system(function (_a) {
|
|
|
57
58
|
pendingScrollHandle = null;
|
|
58
59
|
});
|
|
59
60
|
});
|
|
61
|
+
function trapNextSizeIncrease(followOutput) {
|
|
62
|
+
var cancel = u.handleNext(atBottomState, function (state) {
|
|
63
|
+
if (followOutput && !state.atBottom && state.notAtBottomBecause === 'SIZE_INCREASED' && !pendingScrollHandle) {
|
|
64
|
+
u.getValue(log)('scrolling to bottom due to increased size', {}, LogLevel.DEBUG);
|
|
65
|
+
scrollToBottom('auto');
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
setTimeout(cancel, 100);
|
|
69
|
+
}
|
|
60
70
|
u.subscribe(u.pipe(u.combineLatest(u.duc(followOutput), totalCount, propsReady), u.filter(function (_a) {
|
|
61
71
|
var _b = __read(_a, 3), follow = _b[0], ready = _b[2];
|
|
62
72
|
return follow && ready;
|
|
@@ -69,24 +79,16 @@ export var followOutputSystem = u.system(function (_a) {
|
|
|
69
79
|
return refreshed;
|
|
70
80
|
}), u.withLatestFrom(followOutput, totalCount)), function (_a) {
|
|
71
81
|
var _b = __read(_a, 2), followOutput = _b[1];
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
!pendingScrollHandle) {
|
|
77
|
-
u.getValue(log)('scrolling to bottom due to increased size', {}, LogLevel.DEBUG);
|
|
78
|
-
scrollToBottom('auto');
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
setTimeout(cancel, 100);
|
|
82
|
+
trapNextSizeIncrease(followOutput !== false);
|
|
83
|
+
});
|
|
84
|
+
u.subscribe(autoscrollToBottom, function () {
|
|
85
|
+
trapNextSizeIncrease(u.getValue(followOutput) !== false);
|
|
82
86
|
});
|
|
83
87
|
u.subscribe(u.combineLatest(u.duc(followOutput), atBottomState), function (_a) {
|
|
84
88
|
var _b = __read(_a, 2), followOutput = _b[0], state = _b[1];
|
|
85
|
-
if (followOutput &&
|
|
86
|
-
!state.atBottom &&
|
|
87
|
-
state.notAtBottomBecause === 'VIEWPORT_HEIGHT_DECREASING') {
|
|
89
|
+
if (followOutput && !state.atBottom && state.notAtBottomBecause === 'VIEWPORT_HEIGHT_DECREASING') {
|
|
88
90
|
scrollToBottom('auto');
|
|
89
91
|
}
|
|
90
92
|
});
|
|
91
|
-
return { followOutput: followOutput };
|
|
93
|
+
return { followOutput: followOutput, autoscrollToBottom: autoscrollToBottom };
|
|
92
94
|
}, u.tup(sizeSystem, stateFlagsSystem, scrollToIndexSystem, initialTopMostItemIndexSystem, propsReadySystem, loggerSystem, domIOSystem));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign, __read } from "tslib";
|
|
2
|
-
import * as u from '
|
|
2
|
+
import * as u from './urx';
|
|
3
3
|
import { rangeComparator, tupleComparator } from './comparators';
|
|
4
4
|
import { domIOSystem } from './domIOSystem';
|
|
5
5
|
import { propsReadySystem } from './propsReadySystem';
|
|
@@ -7,7 +7,10 @@ import { scrollSeekSystem } from './scrollSeekSystem';
|
|
|
7
7
|
import { normalizeIndexLocation } from './scrollToIndexSystem';
|
|
8
8
|
import { sizeRangeSystem } from './sizeRangeSystem';
|
|
9
9
|
import { stateFlagsSystem } from './stateFlagsSystem';
|
|
10
|
+
import { loggerSystem } from './loggerSystem';
|
|
10
11
|
import { windowScrollerSystem } from './windowScrollerSystem';
|
|
12
|
+
import { getInitialTopMostItemIndexNumber } from './initialTopMostItemIndexSystem';
|
|
13
|
+
import { skipFrames } from './utils/skipFrames';
|
|
11
14
|
var INITIAL_GRID_STATE = {
|
|
12
15
|
items: [],
|
|
13
16
|
offsetBottom: 0,
|
|
@@ -27,86 +30,161 @@ var PROBE_GRID_STATE = {
|
|
|
27
30
|
itemWidth: 0,
|
|
28
31
|
};
|
|
29
32
|
var round = Math.round, ceil = Math.ceil, floor = Math.floor, min = Math.min, max = Math.max;
|
|
30
|
-
function
|
|
31
|
-
return
|
|
33
|
+
function buildProbeGridState(items) {
|
|
34
|
+
return __assign(__assign({}, PROBE_GRID_STATE), { items: items });
|
|
32
35
|
}
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
function buildItems(startIndex, endIndex, data) {
|
|
37
|
+
return Array.from({ length: endIndex - startIndex + 1 }).map(function (_, i) {
|
|
38
|
+
var dataItem = data === null ? null : data[i + startIndex];
|
|
39
|
+
return { index: i + startIndex, data: dataItem };
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function gapComparator(prev, next) {
|
|
43
|
+
return prev && prev.column === next.column && prev.row === next.row;
|
|
44
|
+
}
|
|
45
|
+
function dimensionComparator(prev, next) {
|
|
46
|
+
return prev && prev.width === next.width && prev.height === next.height;
|
|
47
|
+
}
|
|
48
|
+
export var gridSystem = /*#__PURE__*/ u.system(function (_a) {
|
|
49
|
+
var _b = __read(_a, 7), _c = _b[0], overscan = _c.overscan, visibleRange = _c.visibleRange, listBoundary = _c.listBoundary, _d = _b[1], scrollTop = _d.scrollTop, viewportHeight = _d.viewportHeight, scrollBy = _d.scrollBy, scrollTo = _d.scrollTo, smoothScrollTargetReached = _d.smoothScrollTargetReached, scrollContainerState = _d.scrollContainerState, footerHeight = _d.footerHeight, headerHeight = _d.headerHeight, stateFlags = _b[2], scrollSeek = _b[3], _e = _b[4], propsReady = _e.propsReady, didMount = _e.didMount, _f = _b[5], windowViewportRect = _f.windowViewportRect, useWindowScroll = _f.useWindowScroll, customScrollParent = _f.customScrollParent, windowScrollContainerState = _f.windowScrollContainerState, windowScrollTo = _f.windowScrollTo, log = _b[6];
|
|
35
50
|
var totalCount = u.statefulStream(0);
|
|
36
51
|
var initialItemCount = u.statefulStream(0);
|
|
37
52
|
var gridState = u.statefulStream(INITIAL_GRID_STATE);
|
|
38
|
-
var viewportDimensions = u.statefulStream({
|
|
39
|
-
|
|
40
|
-
width: 0,
|
|
41
|
-
});
|
|
42
|
-
var itemDimensions = u.statefulStream({
|
|
43
|
-
height: 0,
|
|
44
|
-
width: 0,
|
|
45
|
-
});
|
|
53
|
+
var viewportDimensions = u.statefulStream({ height: 0, width: 0 });
|
|
54
|
+
var itemDimensions = u.statefulStream({ height: 0, width: 0 });
|
|
46
55
|
var scrollToIndex = u.stream();
|
|
47
56
|
var scrollHeight = u.stream();
|
|
48
57
|
var deviation = u.statefulStream(0);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
var data = u.statefulStream(null);
|
|
59
|
+
var gap = u.statefulStream({ row: 0, column: 0 });
|
|
60
|
+
var stateChanged = u.stream();
|
|
61
|
+
var restoreStateFrom = u.stream();
|
|
62
|
+
var stateRestoreInProgress = u.statefulStream(false);
|
|
63
|
+
var initialTopMostItemIndex = u.statefulStream(0);
|
|
64
|
+
var scrolledToInitialItem = u.statefulStream(true);
|
|
65
|
+
var scrollScheduled = u.statefulStream(false);
|
|
66
|
+
u.subscribe(u.pipe(didMount, u.withLatestFrom(initialTopMostItemIndex), u.filter(function (_a) {
|
|
67
|
+
var _b = __read(_a, 2), _ = _b[0], location = _b[1];
|
|
68
|
+
return !!location;
|
|
69
|
+
})), function () {
|
|
70
|
+
// console.log('block rendering')
|
|
71
|
+
u.publish(scrolledToInitialItem, false);
|
|
72
|
+
// topmost item index takes precedence over initial item count
|
|
73
|
+
u.publish(initialItemCount, 0);
|
|
74
|
+
});
|
|
75
|
+
u.subscribe(u.pipe(u.combineLatest(didMount, scrolledToInitialItem, itemDimensions, viewportDimensions, initialTopMostItemIndex, scrollScheduled), u.filter(function (_a) {
|
|
76
|
+
var _b = __read(_a, 6), didMount = _b[0], scrolledToInitialItem = _b[1], itemDimensions = _b[2], viewportDimensions = _b[3], scrollScheduled = _b[5];
|
|
77
|
+
return didMount && !scrolledToInitialItem && itemDimensions.height !== 0 && viewportDimensions.height !== 0 && !scrollScheduled;
|
|
78
|
+
})), function (_a) {
|
|
79
|
+
var _b = __read(_a, 5), initialTopMostItemIndex = _b[4];
|
|
80
|
+
u.publish(scrollScheduled, true);
|
|
81
|
+
skipFrames(1, function () {
|
|
82
|
+
u.publish(scrollToIndex, initialTopMostItemIndex);
|
|
83
|
+
});
|
|
84
|
+
u.handleNext(u.pipe(scrollTop), function () {
|
|
85
|
+
// this refreshes the sizeRangeSystem start/endOffset
|
|
86
|
+
u.publish(listBoundary, [0, 0]);
|
|
87
|
+
// console.log('resume rendering')
|
|
88
|
+
u.publish(scrolledToInitialItem, true);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
// state snapshot takes precedence over initial item count
|
|
92
|
+
u.connect(u.pipe(restoreStateFrom, u.filter(function (value) { return value !== undefined && value !== null && value.scrollTop > 0; }), u.mapTo(0)), initialItemCount);
|
|
93
|
+
u.subscribe(u.pipe(didMount, u.withLatestFrom(restoreStateFrom), u.filter(function (_a) {
|
|
94
|
+
var _b = __read(_a, 2), snapshot = _b[1];
|
|
95
|
+
return snapshot !== undefined && snapshot !== null;
|
|
96
|
+
})), function (_a) {
|
|
97
|
+
var _b = __read(_a, 2), snapshot = _b[1];
|
|
98
|
+
if (!snapshot) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
u.publish(viewportDimensions, snapshot.viewport), u.publish(itemDimensions, snapshot === null || snapshot === void 0 ? void 0 : snapshot.item);
|
|
102
|
+
u.publish(gap, snapshot.gap);
|
|
103
|
+
if (snapshot.scrollTop > 0) {
|
|
104
|
+
u.publish(stateRestoreInProgress, true);
|
|
105
|
+
u.handleNext(u.pipe(scrollTop, u.skip(1)), function (_value) {
|
|
106
|
+
u.publish(stateRestoreInProgress, false);
|
|
107
|
+
});
|
|
108
|
+
u.publish(scrollTo, { top: snapshot.scrollTop });
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
u.connect(u.pipe(viewportDimensions, u.map(function (_a) {
|
|
112
|
+
var height = _a.height;
|
|
113
|
+
return height;
|
|
114
|
+
})), viewportHeight);
|
|
115
|
+
u.connect(u.pipe(u.combineLatest(u.duc(viewportDimensions, dimensionComparator), u.duc(itemDimensions, dimensionComparator), u.duc(gap, function (prev, next) { return prev && prev.column === next.column && prev.row === next.row; }), u.duc(scrollTop)), u.map(function (_a) {
|
|
116
|
+
var _b = __read(_a, 4), viewport = _b[0], item = _b[1], gap = _b[2], scrollTop = _b[3];
|
|
117
|
+
return ({
|
|
118
|
+
viewport: viewport,
|
|
119
|
+
item: item,
|
|
120
|
+
gap: gap,
|
|
121
|
+
scrollTop: scrollTop,
|
|
122
|
+
});
|
|
123
|
+
})), stateChanged);
|
|
124
|
+
u.connect(u.pipe(u.combineLatest(u.duc(totalCount), visibleRange, u.duc(gap, gapComparator), u.duc(itemDimensions, dimensionComparator), u.duc(viewportDimensions, dimensionComparator), u.duc(data), u.duc(initialItemCount), u.duc(stateRestoreInProgress), u.duc(scrolledToInitialItem), u.duc(initialTopMostItemIndex)), u.filter(function (_a) {
|
|
125
|
+
var _b = __read(_a, 8), stateRestoreInProgress = _b[7];
|
|
126
|
+
return !stateRestoreInProgress;
|
|
52
127
|
}), u.map(function (_a) {
|
|
53
|
-
var _b = __read(_a,
|
|
54
|
-
|
|
55
|
-
items: buildItems(0, count - 1),
|
|
56
|
-
top: 0,
|
|
57
|
-
bottom: 0,
|
|
58
|
-
offsetBottom: 0,
|
|
59
|
-
offsetTop: 0,
|
|
60
|
-
itemHeight: 0,
|
|
61
|
-
itemWidth: 0,
|
|
62
|
-
};
|
|
63
|
-
})), gridState);
|
|
64
|
-
u.connect(u.pipe(u.combineLatest(u.duc(totalCount), visibleRange, u.duc(itemDimensions, function (prev, next) {
|
|
65
|
-
return prev && prev.width === next.width && prev.height === next.height;
|
|
66
|
-
})), u.withLatestFrom(viewportDimensions), u.map(function (_a) {
|
|
67
|
-
var _b = __read(_a, 2), _c = __read(_b[0], 3), totalCount = _c[0], _d = __read(_c[1], 2), startOffset = _d[0], endOffset = _d[1], item = _c[2], viewport = _b[1];
|
|
128
|
+
var _b = __read(_a, 10), totalCount = _b[0], _c = __read(_b[1], 2), startOffset = _c[0], endOffset = _c[1], gap = _b[2], item = _b[3], viewport = _b[4], data = _b[5], initialItemCount = _b[6], scrolledToInitialItem = _b[8], initialTopMostItemIndex = _b[9];
|
|
129
|
+
var rowGap = gap.row, columnGap = gap.column;
|
|
68
130
|
var itemHeight = item.height, itemWidth = item.width;
|
|
69
131
|
var viewportWidth = viewport.width;
|
|
70
|
-
|
|
132
|
+
// don't wipeout the already rendered state if there's an initial item count
|
|
133
|
+
if (initialItemCount === 0 && (totalCount === 0 || viewportWidth === 0)) {
|
|
71
134
|
return INITIAL_GRID_STATE;
|
|
72
135
|
}
|
|
73
136
|
if (itemWidth === 0) {
|
|
74
|
-
|
|
137
|
+
var startIndex_1 = getInitialTopMostItemIndexNumber(initialTopMostItemIndex, totalCount);
|
|
138
|
+
// if the initial item count is set, we don't render the items from the initial item count.
|
|
139
|
+
var endIndex_1 = startIndex_1 === 0 ? Math.max(initialItemCount - 1, 0) : startIndex_1;
|
|
140
|
+
return buildProbeGridState(buildItems(startIndex_1, endIndex_1, data));
|
|
141
|
+
}
|
|
142
|
+
var perRow = itemsPerRow(viewportWidth, itemWidth, columnGap);
|
|
143
|
+
var startIndex;
|
|
144
|
+
var endIndex;
|
|
145
|
+
// render empty items until the scroller reaches the initial item
|
|
146
|
+
if (!scrolledToInitialItem) {
|
|
147
|
+
startIndex = 0;
|
|
148
|
+
endIndex = -1;
|
|
149
|
+
}
|
|
150
|
+
// we know the dimensions from a restored state, but the offsets are not calculated yet
|
|
151
|
+
else if (startOffset === 0 && endOffset === 0 && initialItemCount > 0) {
|
|
152
|
+
startIndex = 0;
|
|
153
|
+
endIndex = initialItemCount - 1;
|
|
75
154
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
var
|
|
83
|
-
var
|
|
155
|
+
else {
|
|
156
|
+
startIndex = perRow * floor((startOffset + rowGap) / (itemHeight + rowGap));
|
|
157
|
+
endIndex = perRow * ceil((endOffset + rowGap) / (itemHeight + rowGap)) - 1;
|
|
158
|
+
endIndex = min(totalCount - 1, max(endIndex, perRow - 1));
|
|
159
|
+
startIndex = min(endIndex, max(0, startIndex));
|
|
160
|
+
}
|
|
161
|
+
var items = buildItems(startIndex, endIndex, data);
|
|
162
|
+
var _d = gridLayout(viewport, gap, item, items), top = _d.top, bottom = _d.bottom;
|
|
163
|
+
var rowCount = ceil(totalCount / perRow);
|
|
164
|
+
var totalHeight = rowCount * itemHeight + (rowCount - 1) * rowGap;
|
|
84
165
|
var offsetBottom = totalHeight - bottom;
|
|
85
|
-
return {
|
|
86
|
-
items: items,
|
|
87
|
-
offsetTop: top,
|
|
88
|
-
offsetBottom: offsetBottom,
|
|
89
|
-
top: top,
|
|
90
|
-
bottom: bottom,
|
|
91
|
-
itemHeight: itemHeight,
|
|
92
|
-
itemWidth: itemWidth,
|
|
93
|
-
};
|
|
166
|
+
return { items: items, offsetTop: top, offsetBottom: offsetBottom, top: top, bottom: bottom, itemHeight: itemHeight, itemWidth: itemWidth };
|
|
94
167
|
})), gridState);
|
|
95
|
-
u.connect(u.pipe(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
var _b = __read(_a,
|
|
101
|
-
var _c = gridLayout(viewportDimensions,
|
|
168
|
+
u.connect(u.pipe(data, u.filter(function (data) { return data !== null; }), u.map(function (data) { return data.length; })), totalCount);
|
|
169
|
+
u.connect(u.pipe(u.combineLatest(viewportDimensions, itemDimensions, gridState, gap), u.filter(function (_a) {
|
|
170
|
+
var _b = __read(_a, 3), viewportDimensions = _b[0], itemDimensions = _b[1], items = _b[2].items;
|
|
171
|
+
return items.length > 0 && itemDimensions.height !== 0 && viewportDimensions.height !== 0;
|
|
172
|
+
}), u.map(function (_a) {
|
|
173
|
+
var _b = __read(_a, 4), viewportDimensions = _b[0], itemDimensions = _b[1], items = _b[2].items, gap = _b[3];
|
|
174
|
+
var _c = gridLayout(viewportDimensions, gap, itemDimensions, items), top = _c.top, bottom = _c.bottom;
|
|
102
175
|
return [top, bottom];
|
|
103
176
|
}), u.distinctUntilChanged(tupleComparator)), listBoundary);
|
|
177
|
+
var hasScrolled = u.statefulStream(false);
|
|
178
|
+
u.connect(u.pipe(scrollTop, u.withLatestFrom(hasScrolled), u.map(function (_a) {
|
|
179
|
+
var _b = __read(_a, 2), scrollTop = _b[0], hasScrolled = _b[1];
|
|
180
|
+
return hasScrolled || scrollTop !== 0;
|
|
181
|
+
})), hasScrolled);
|
|
104
182
|
var endReached = u.streamFromEmitter(u.pipe(u.duc(gridState), u.filter(function (_a) {
|
|
105
183
|
var items = _a.items;
|
|
106
184
|
return items.length > 0;
|
|
107
|
-
}), u.withLatestFrom(totalCount), u.filter(function (_a) {
|
|
108
|
-
var _b = __read(_a,
|
|
109
|
-
return items[items.length - 1].index === totalCount - 1;
|
|
185
|
+
}), u.withLatestFrom(totalCount, hasScrolled), u.filter(function (_a) {
|
|
186
|
+
var _b = __read(_a, 3), items = _b[0].items, totalCount = _b[1], hasScrolled = _b[2];
|
|
187
|
+
return hasScrolled && items[items.length - 1].index === totalCount - 1;
|
|
110
188
|
}), u.map(function (_a) {
|
|
111
189
|
var _b = __read(_a, 2), totalCount = _b[1];
|
|
112
190
|
return totalCount - 1;
|
|
@@ -114,20 +192,22 @@ export var gridSystem = u.system(function (_a) {
|
|
|
114
192
|
var startReached = u.streamFromEmitter(u.pipe(u.duc(gridState), u.filter(function (_a) {
|
|
115
193
|
var items = _a.items;
|
|
116
194
|
return items.length > 0 && items[0].index === 0;
|
|
117
|
-
}),
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
195
|
+
}),
|
|
196
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
197
|
+
u.mapTo(0), u.distinctUntilChanged()));
|
|
198
|
+
var rangeChanged = u.streamFromEmitter(u.pipe(u.duc(gridState), u.withLatestFrom(stateRestoreInProgress), u.filter(function (_a) {
|
|
199
|
+
var _b = __read(_a, 2), items = _b[0].items, stateRestoreInProgress = _b[1];
|
|
200
|
+
return items.length > 0 && !stateRestoreInProgress;
|
|
121
201
|
}), u.map(function (_a) {
|
|
122
|
-
var items =
|
|
202
|
+
var _b = __read(_a, 1), items = _b[0].items;
|
|
123
203
|
return {
|
|
124
204
|
startIndex: items[0].index,
|
|
125
205
|
endIndex: items[items.length - 1].index,
|
|
126
206
|
};
|
|
127
|
-
}), u.distinctUntilChanged(rangeComparator)));
|
|
207
|
+
}), u.distinctUntilChanged(rangeComparator), u.throttleTime(0)));
|
|
128
208
|
u.connect(rangeChanged, scrollSeek.scrollSeekRangeChanged);
|
|
129
|
-
u.connect(u.pipe(scrollToIndex, u.withLatestFrom(viewportDimensions, itemDimensions, totalCount), u.map(function (_a) {
|
|
130
|
-
var _b = __read(_a,
|
|
209
|
+
u.connect(u.pipe(scrollToIndex, u.withLatestFrom(viewportDimensions, itemDimensions, totalCount, gap), u.map(function (_a) {
|
|
210
|
+
var _b = __read(_a, 5), location = _b[0], viewportDimensions = _b[1], itemDimensions = _b[2], totalCount = _b[3], gap = _b[4];
|
|
131
211
|
var normalLocation = normalizeIndexLocation(location);
|
|
132
212
|
var align = normalLocation.align, behavior = normalLocation.behavior, offset = normalLocation.offset;
|
|
133
213
|
var index = normalLocation.index;
|
|
@@ -135,12 +215,12 @@ export var gridSystem = u.system(function (_a) {
|
|
|
135
215
|
index = totalCount - 1;
|
|
136
216
|
}
|
|
137
217
|
index = max(0, index, min(totalCount - 1, index));
|
|
138
|
-
var top = itemTop(
|
|
218
|
+
var top = itemTop(viewportDimensions, gap, itemDimensions, index);
|
|
139
219
|
if (align === 'end') {
|
|
140
|
-
top = round(top -
|
|
220
|
+
top = round(top - viewportDimensions.height + itemDimensions.height);
|
|
141
221
|
}
|
|
142
222
|
else if (align === 'center') {
|
|
143
|
-
top = round(top -
|
|
223
|
+
top = round(top - viewportDimensions.height / 2 + itemDimensions.height / 2);
|
|
144
224
|
}
|
|
145
225
|
if (offset) {
|
|
146
226
|
top += offset;
|
|
@@ -150,12 +230,10 @@ export var gridSystem = u.system(function (_a) {
|
|
|
150
230
|
var totalListHeight = u.statefulStreamFromEmitter(u.pipe(gridState, u.map(function (gridState) {
|
|
151
231
|
return gridState.offsetBottom + gridState.bottom;
|
|
152
232
|
})), 0);
|
|
153
|
-
u.connect(u.pipe(windowViewportRect, u.map(function (viewportInfo) { return ({
|
|
154
|
-
|
|
155
|
-
height: viewportInfo.visibleHeight,
|
|
156
|
-
}); })), viewportDimensions);
|
|
157
|
-
return __assign(__assign(__assign(__assign({
|
|
233
|
+
u.connect(u.pipe(windowViewportRect, u.map(function (viewportInfo) { return ({ width: viewportInfo.visibleWidth, height: viewportInfo.visibleHeight }); })), viewportDimensions);
|
|
234
|
+
return __assign(__assign(__assign(__assign(__assign({
|
|
158
235
|
// input
|
|
236
|
+
data: data,
|
|
159
237
|
totalCount: totalCount,
|
|
160
238
|
viewportDimensions: viewportDimensions,
|
|
161
239
|
itemDimensions: itemDimensions,
|
|
@@ -173,27 +251,35 @@ export var gridSystem = u.system(function (_a) {
|
|
|
173
251
|
windowScrollContainerState: windowScrollContainerState,
|
|
174
252
|
deviation: deviation,
|
|
175
253
|
scrollContainerState: scrollContainerState,
|
|
176
|
-
|
|
254
|
+
footerHeight: footerHeight,
|
|
255
|
+
headerHeight: headerHeight,
|
|
256
|
+
initialItemCount: initialItemCount,
|
|
257
|
+
gap: gap,
|
|
258
|
+
restoreStateFrom: restoreStateFrom }, scrollSeek), { initialTopMostItemIndex: initialTopMostItemIndex,
|
|
177
259
|
// output
|
|
178
260
|
gridState: gridState,
|
|
179
261
|
totalListHeight: totalListHeight }), stateFlags), { startReached: startReached,
|
|
180
262
|
endReached: endReached,
|
|
181
263
|
rangeChanged: rangeChanged,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
264
|
+
stateChanged: stateChanged,
|
|
265
|
+
propsReady: propsReady,
|
|
266
|
+
stateRestoreInProgress: stateRestoreInProgress }), log);
|
|
267
|
+
}, u.tup(sizeRangeSystem, domIOSystem, stateFlagsSystem, scrollSeekSystem, propsReadySystem, windowScrollerSystem, loggerSystem));
|
|
268
|
+
function gridLayout(viewport, gap, item, items) {
|
|
185
269
|
var itemHeight = item.height;
|
|
186
270
|
if (itemHeight === undefined || items.length === 0) {
|
|
187
271
|
return { top: 0, bottom: 0 };
|
|
188
272
|
}
|
|
189
|
-
var top = itemTop(viewport, item, items[0].index);
|
|
190
|
-
var bottom = itemTop(viewport, item, items[items.length - 1].index) + itemHeight;
|
|
273
|
+
var top = itemTop(viewport, gap, item, items[0].index);
|
|
274
|
+
var bottom = itemTop(viewport, gap, item, items[items.length - 1].index) + itemHeight;
|
|
191
275
|
return { top: top, bottom: bottom };
|
|
192
276
|
}
|
|
193
|
-
function itemTop(viewport, item, index) {
|
|
194
|
-
var perRow = itemsPerRow(viewport.width, item.width);
|
|
195
|
-
|
|
277
|
+
function itemTop(viewport, gap, item, index) {
|
|
278
|
+
var perRow = itemsPerRow(viewport.width, item.width, gap.column);
|
|
279
|
+
var rowCount = floor(index / perRow);
|
|
280
|
+
var top = rowCount * item.height + max(0, rowCount - 1) * gap.row;
|
|
281
|
+
return top > 0 ? top + gap.row : top;
|
|
196
282
|
}
|
|
197
|
-
function itemsPerRow(viewportWidth, itemWidth) {
|
|
198
|
-
return max(1, floor(viewportWidth / itemWidth));
|
|
283
|
+
export function itemsPerRow(viewportWidth, itemWidth, gap) {
|
|
284
|
+
return max(1, floor((viewportWidth + gap) / (floor(itemWidth) + gap)));
|
|
199
285
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __read } from "tslib";
|
|
2
|
-
import
|
|
2
|
+
import * as u from './urx';
|
|
3
3
|
import { findMaxKeyValue } from './AATree';
|
|
4
4
|
import { domIOSystem } from './domIOSystem';
|
|
5
|
-
import {
|
|
5
|
+
import { sizeSystem, hasGroups } from './sizeSystem';
|
|
6
6
|
export function groupCountsToIndicesAndCount(counts) {
|
|
7
7
|
return counts.reduce(function (acc, groupCount) {
|
|
8
8
|
acc.groupIndices.push(acc.totalCount);
|
|
@@ -13,19 +13,19 @@ export function groupCountsToIndicesAndCount(counts) {
|
|
|
13
13
|
groupIndices: [],
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
export var groupedListSystem = system(function (_a) {
|
|
16
|
+
export var groupedListSystem = u.system(function (_a) {
|
|
17
17
|
var _b = __read(_a, 2), _c = _b[0], totalCount = _c.totalCount, groupIndices = _c.groupIndices, sizes = _c.sizes, _d = _b[1], scrollTop = _d.scrollTop, headerHeight = _d.headerHeight;
|
|
18
|
-
var groupCounts = stream();
|
|
19
|
-
var topItemsIndexes = stream();
|
|
20
|
-
var groupIndicesAndCount = streamFromEmitter(pipe(groupCounts, map(groupCountsToIndicesAndCount)));
|
|
21
|
-
connect(pipe(groupIndicesAndCount, map(
|
|
22
|
-
connect(pipe(groupIndicesAndCount, map(
|
|
23
|
-
connect(pipe(combineLatest(scrollTop, sizes, headerHeight), filter(function (_a) {
|
|
24
|
-
var _b = __read(_a, 2), sizes = _b[1];
|
|
18
|
+
var groupCounts = u.stream();
|
|
19
|
+
var topItemsIndexes = u.stream();
|
|
20
|
+
var groupIndicesAndCount = u.streamFromEmitter(u.pipe(groupCounts, u.map(groupCountsToIndicesAndCount)));
|
|
21
|
+
u.connect(u.pipe(groupIndicesAndCount, u.map(function (value) { return value.totalCount; })), totalCount);
|
|
22
|
+
u.connect(u.pipe(groupIndicesAndCount, u.map(function (value) { return value.groupIndices; })), groupIndices);
|
|
23
|
+
u.connect(u.pipe(u.combineLatest(scrollTop, sizes, headerHeight), u.filter(function (_a) {
|
|
24
|
+
var _b = __read(_a, 2), _ = _b[0], sizes = _b[1];
|
|
25
25
|
return hasGroups(sizes);
|
|
26
|
-
}), map(function (_a) {
|
|
26
|
+
}), u.map(function (_a) {
|
|
27
27
|
var _b = __read(_a, 3), scrollTop = _b[0], state = _b[1], headerHeight = _b[2];
|
|
28
28
|
return findMaxKeyValue(state.groupOffsetTree, Math.max(scrollTop - headerHeight, 0), 'v')[0];
|
|
29
|
-
}), distinctUntilChanged(), map(function (index) { return [index]; })), topItemsIndexes);
|
|
29
|
+
}), u.distinctUntilChanged(), u.map(function (index) { return [index]; })), topItemsIndexes);
|
|
30
30
|
return { groupCounts: groupCounts, topItemsIndexes: topItemsIndexes };
|
|
31
|
-
}, tup(sizeSystem, domIOSystem));
|
|
31
|
+
}, u.tup(sizeSystem, domIOSystem));
|
|
@@ -1,30 +1,43 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { LogLevel } from '../loggerSystem';
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import { useSizeWithElRef } from './useSize';
|
|
4
|
+
import { useRcPortalWindowContext } from './useRcPortalWindowContext';
|
|
5
|
+
export default function useChangedListContentsSizes(callback, itemSize, enabled, scrollContainerStateCallback, log, gap, customScrollParent) {
|
|
5
6
|
var _a = useRcPortalWindowContext().externalWindow, externalWindow = _a === void 0 ? window : _a;
|
|
6
|
-
|
|
7
|
+
var memoedCallback = React.useCallback(function (el) {
|
|
7
8
|
var ranges = getChangedChildSizes(el.children, itemSize, 'offsetHeight', log);
|
|
8
9
|
var scrollableElement = el.parentElement;
|
|
9
10
|
while (!scrollableElement.dataset['virtuosoScroller']) {
|
|
10
11
|
scrollableElement = scrollableElement.parentElement;
|
|
11
12
|
}
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
14
|
+
var windowScrolling = scrollableElement.lastElementChild.dataset['viewportType'] === 'window';
|
|
12
15
|
var scrollTop = customScrollParent
|
|
13
16
|
? customScrollParent.scrollTop
|
|
14
|
-
:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
: windowScrolling
|
|
18
|
+
? externalWindow.pageYOffset || externalWindow.document.documentElement.scrollTop
|
|
19
|
+
: scrollableElement.scrollTop;
|
|
20
|
+
var scrollHeight = customScrollParent
|
|
21
|
+
? customScrollParent.scrollHeight
|
|
22
|
+
: windowScrolling
|
|
23
|
+
? externalWindow.document.documentElement.scrollHeight
|
|
24
|
+
: scrollableElement.scrollHeight;
|
|
25
|
+
var viewportHeight = customScrollParent
|
|
26
|
+
? customScrollParent.offsetHeight
|
|
27
|
+
: windowScrolling
|
|
28
|
+
? externalWindow.innerHeight
|
|
29
|
+
: scrollableElement.offsetHeight;
|
|
19
30
|
scrollContainerStateCallback({
|
|
20
31
|
scrollTop: Math.max(scrollTop, 0),
|
|
21
|
-
scrollHeight:
|
|
22
|
-
viewportHeight:
|
|
32
|
+
scrollHeight: scrollHeight,
|
|
33
|
+
viewportHeight: viewportHeight,
|
|
23
34
|
});
|
|
35
|
+
gap === null || gap === void 0 ? void 0 : gap(resolveGapValue('row-gap', getComputedStyle(el).rowGap, log));
|
|
24
36
|
if (ranges !== null) {
|
|
25
37
|
callback(ranges);
|
|
26
38
|
}
|
|
27
|
-
},
|
|
39
|
+
}, [callback, itemSize, log, gap, customScrollParent, scrollContainerStateCallback, externalWindow]);
|
|
40
|
+
return useSizeWithElRef(memoedCallback, enabled);
|
|
28
41
|
}
|
|
29
42
|
function getChangedChildSizes(children, itemSize, field, log) {
|
|
30
43
|
var length = children.length;
|
|
@@ -37,7 +50,6 @@ function getChangedChildSizes(children, itemSize, field, log) {
|
|
|
37
50
|
if (!child || child.dataset.index === undefined) {
|
|
38
51
|
continue;
|
|
39
52
|
}
|
|
40
|
-
// eslint-disable-next-line radix
|
|
41
53
|
var index = parseInt(child.dataset.index);
|
|
42
54
|
var knownSize = parseFloat(child.dataset.knownSize);
|
|
43
55
|
var size = itemSize(child, field);
|
|
@@ -48,9 +60,7 @@ function getChangedChildSizes(children, itemSize, field, log) {
|
|
|
48
60
|
continue;
|
|
49
61
|
}
|
|
50
62
|
var lastResult = results[results.length - 1];
|
|
51
|
-
if (results.length === 0 ||
|
|
52
|
-
lastResult.size !== size ||
|
|
53
|
-
lastResult.endIndex !== index - 1) {
|
|
63
|
+
if (results.length === 0 || lastResult.size !== size || lastResult.endIndex !== index - 1) {
|
|
54
64
|
results.push({ startIndex: index, endIndex: index, size: size });
|
|
55
65
|
}
|
|
56
66
|
else {
|
|
@@ -59,3 +69,12 @@ function getChangedChildSizes(children, itemSize, field, log) {
|
|
|
59
69
|
}
|
|
60
70
|
return results;
|
|
61
71
|
}
|
|
72
|
+
function resolveGapValue(property, value, log) {
|
|
73
|
+
if (value !== 'normal' && !(value === null || value === void 0 ? void 0 : value.endsWith('px'))) {
|
|
74
|
+
log(property + " was not resolved to pixel value correctly", value, LogLevel.WARN);
|
|
75
|
+
}
|
|
76
|
+
if (value === 'normal') {
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
return parseInt(value !== null && value !== void 0 ? value : '0', 10);
|
|
80
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
var useIsomorphicLayoutEffect = typeof document !== 'undefined' ? useLayoutEffect : useEffect;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
var useIsomorphicLayoutEffect = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
3
3
|
export default useIsomorphicLayoutEffect;
|