@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,18 +1,26 @@
|
|
|
1
1
|
import { __assign, __read, __spread, __values } from "tslib";
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import { arrayToRanges, empty, findMaxKeyValue, insert, newTree, rangesWithin, remove, walk, } from './AATree';
|
|
5
|
-
import { loggerSystem, LogLevel } from './loggerSystem';
|
|
2
|
+
import * as u from './urx';
|
|
3
|
+
import { arrayToRanges, empty, find, findMaxKeyValue, insert, newTree, rangesWithin, remove, walk } from './AATree';
|
|
6
4
|
import * as arrayBinarySearch from './utils/binaryArraySearch';
|
|
7
5
|
import { correctItemSize } from './utils/correctItemSize';
|
|
6
|
+
import { loggerSystem, LogLevel } from './loggerSystem';
|
|
7
|
+
import { recalcSystem } from './recalcSystem';
|
|
8
8
|
function rangeIncludes(refRange) {
|
|
9
9
|
var size = refRange.size, startIndex = refRange.startIndex, endIndex = refRange.endIndex;
|
|
10
10
|
return function (range) {
|
|
11
|
-
return
|
|
12
|
-
(range.end === endIndex || range.end === Infinity) &&
|
|
13
|
-
range.value === size);
|
|
11
|
+
return range.start === startIndex && (range.end === endIndex || range.end === Infinity) && range.value === size;
|
|
14
12
|
};
|
|
15
13
|
}
|
|
14
|
+
function affectedGroupCount(offset, groupIndices) {
|
|
15
|
+
var recognizedOffsetItems = 0;
|
|
16
|
+
var groupIndex = 0;
|
|
17
|
+
while (recognizedOffsetItems < offset) {
|
|
18
|
+
recognizedOffsetItems += groupIndices[groupIndex + 1] - groupIndices[groupIndex] - 1;
|
|
19
|
+
groupIndex++;
|
|
20
|
+
}
|
|
21
|
+
var offsetIsExact = recognizedOffsetItems === offset;
|
|
22
|
+
return groupIndex - (offsetIsExact ? 0 : 1);
|
|
23
|
+
}
|
|
16
24
|
export function insertRanges(sizeTree, ranges) {
|
|
17
25
|
var e_1, _a, e_2, _b;
|
|
18
26
|
var syncStart = empty(sizeTree) ? 0 : Infinity;
|
|
@@ -42,10 +50,12 @@ export function insertRanges(sizeTree, ranges) {
|
|
|
42
50
|
shouldInsert = rangeValue !== size;
|
|
43
51
|
firstPassDone = true;
|
|
44
52
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
else {
|
|
54
|
+
// remove the range if it starts within the new range OR if
|
|
55
|
+
// it has the same value as it, in order to perform a merge
|
|
56
|
+
if (endIndex >= rangeStart || size === rangeValue) {
|
|
57
|
+
sizeTree = remove(sizeTree, rangeStart);
|
|
58
|
+
}
|
|
49
59
|
}
|
|
50
60
|
// next range
|
|
51
61
|
if (rangeEnd > endIndex && endIndex >= rangeStart) {
|
|
@@ -105,7 +115,7 @@ export function rangesWithinOffsets(tree, startOffset, endOffset, minStartIndex)
|
|
|
105
115
|
}
|
|
106
116
|
return arrayToRanges(arrayBinarySearch.findRange(tree, startOffset, endOffset, offsetComparator), offsetPointParser);
|
|
107
117
|
}
|
|
108
|
-
function createOffsetTree(prevOffsetTree, syncStart, sizeTree) {
|
|
118
|
+
function createOffsetTree(prevOffsetTree, syncStart, sizeTree, gap) {
|
|
109
119
|
var e_3, _a;
|
|
110
120
|
var offsetTree = prevOffsetTree;
|
|
111
121
|
var prevIndex = 0;
|
|
@@ -119,8 +129,7 @@ function createOffsetTree(prevOffsetTree, syncStart, sizeTree) {
|
|
|
119
129
|
var kv = findMaxKeyValue(sizeTree, syncStart - 1);
|
|
120
130
|
prevIndex = kv[0];
|
|
121
131
|
prevSize = kv[1];
|
|
122
|
-
if (offsetTree.length &&
|
|
123
|
-
offsetTree[startIndex].size === findMaxKeyValue(sizeTree, syncStart)[1]) {
|
|
132
|
+
if (offsetTree.length && offsetTree[startIndex].size === findMaxKeyValue(sizeTree, syncStart)[1]) {
|
|
124
133
|
startIndex -= 1;
|
|
125
134
|
}
|
|
126
135
|
offsetTree = offsetTree.slice(0, startIndex + 1);
|
|
@@ -131,7 +140,8 @@ function createOffsetTree(prevOffsetTree, syncStart, sizeTree) {
|
|
|
131
140
|
try {
|
|
132
141
|
for (var _b = __values(rangesWithin(sizeTree, syncStart, Infinity)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
133
142
|
var _d = _c.value, startIndex_1 = _d.start, value = _d.value;
|
|
134
|
-
var
|
|
143
|
+
var indexOffset = startIndex_1 - prevIndex;
|
|
144
|
+
var aOffset = indexOffset * prevSize + prevOffset + indexOffset * gap;
|
|
135
145
|
offsetTree.push({
|
|
136
146
|
offset: aOffset,
|
|
137
147
|
size: value,
|
|
@@ -158,7 +168,7 @@ function createOffsetTree(prevOffsetTree, syncStart, sizeTree) {
|
|
|
158
168
|
}
|
|
159
169
|
export function sizeStateReducer(state, _a) {
|
|
160
170
|
var _b;
|
|
161
|
-
var _c = __read(_a,
|
|
171
|
+
var _c = __read(_a, 4), ranges = _c[0], groupIndices = _c[1], log = _c[2], gap = _c[3];
|
|
162
172
|
if (ranges.length > 0) {
|
|
163
173
|
log('received item sizes', ranges, LogLevel.DEBUG);
|
|
164
174
|
}
|
|
@@ -176,12 +186,13 @@ export function sizeStateReducer(state, _a) {
|
|
|
176
186
|
}, newSizeTree);
|
|
177
187
|
}
|
|
178
188
|
else {
|
|
189
|
+
;
|
|
179
190
|
_b = __read(insertRanges(newSizeTree, ranges), 2), newSizeTree = _b[0], syncStart = _b[1];
|
|
180
191
|
}
|
|
181
192
|
if (newSizeTree === sizeTree) {
|
|
182
193
|
return state;
|
|
183
194
|
}
|
|
184
|
-
var _d = createOffsetTree(state.offsetTree, syncStart, newSizeTree), newOffsetTree = _d.offsetTree, lastIndex = _d.lastIndex, lastSize = _d.lastSize, lastOffset = _d.lastOffset;
|
|
195
|
+
var _d = createOffsetTree(state.offsetTree, syncStart, newSizeTree, gap), newOffsetTree = _d.offsetTree, lastIndex = _d.lastIndex, lastSize = _d.lastSize, lastOffset = _d.lastOffset;
|
|
185
196
|
return {
|
|
186
197
|
sizeTree: newSizeTree,
|
|
187
198
|
offsetTree: newOffsetTree,
|
|
@@ -189,17 +200,36 @@ export function sizeStateReducer(state, _a) {
|
|
|
189
200
|
lastOffset: lastOffset,
|
|
190
201
|
lastSize: lastSize,
|
|
191
202
|
groupOffsetTree: groupIndices.reduce(function (tree, index) {
|
|
192
|
-
return insert(tree, index, offsetOf(index, newOffsetTree));
|
|
203
|
+
return insert(tree, index, offsetOf(index, newOffsetTree, gap));
|
|
193
204
|
}, newTree()),
|
|
194
205
|
groupIndices: groupIndices,
|
|
195
206
|
};
|
|
196
207
|
}
|
|
197
|
-
export function offsetOf(index, tree) {
|
|
208
|
+
export function offsetOf(index, tree, gap) {
|
|
198
209
|
if (tree.length === 0) {
|
|
199
210
|
return 0;
|
|
200
211
|
}
|
|
201
212
|
var _a = arrayBinarySearch.findClosestSmallerOrEqual(tree, index, indexComparator), offset = _a.offset, startIndex = _a.index, size = _a.size;
|
|
202
|
-
|
|
213
|
+
var itemCount = index - startIndex;
|
|
214
|
+
var top = size * itemCount + (itemCount - 1) * gap + offset;
|
|
215
|
+
return top > 0 ? top + gap : top;
|
|
216
|
+
}
|
|
217
|
+
export function isGroupLocation(location) {
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
219
|
+
return typeof location.groupIndex !== 'undefined';
|
|
220
|
+
}
|
|
221
|
+
export function originalIndexFromLocation(location, sizes, lastIndex) {
|
|
222
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
223
|
+
if (isGroupLocation(location)) {
|
|
224
|
+
// return the index of the first item below the index
|
|
225
|
+
return sizes.groupIndices[location.groupIndex] + 1;
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
var numericIndex = location.index === 'LAST' ? lastIndex : location.index;
|
|
229
|
+
var result = originalIndexFromItemIndex(numericIndex, sizes);
|
|
230
|
+
result = Math.max(0, result, Math.min(lastIndex, result));
|
|
231
|
+
return result;
|
|
232
|
+
}
|
|
203
233
|
}
|
|
204
234
|
export function originalIndexFromItemIndex(itemIndex, sizes) {
|
|
205
235
|
if (!hasGroups(sizes)) {
|
|
@@ -215,12 +245,20 @@ export function originalIndexFromItemIndex(itemIndex, sizes) {
|
|
|
215
245
|
export function hasGroups(sizes) {
|
|
216
246
|
return !empty(sizes.groupOffsetTree);
|
|
217
247
|
}
|
|
248
|
+
export function sizeTreeToRanges(sizeTree) {
|
|
249
|
+
return walk(sizeTree).map(function (_a, index, sizeArray) {
|
|
250
|
+
var startIndex = _a.k, size = _a.v;
|
|
251
|
+
var nextSize = sizeArray[index + 1];
|
|
252
|
+
var endIndex = nextSize ? nextSize.k - 1 : Infinity;
|
|
253
|
+
return { startIndex: startIndex, endIndex: endIndex, size: size };
|
|
254
|
+
});
|
|
255
|
+
}
|
|
218
256
|
var SIZE_MAP = {
|
|
219
257
|
offsetHeight: 'height',
|
|
220
258
|
offsetWidth: 'width',
|
|
221
259
|
};
|
|
222
260
|
export var sizeSystem = u.system(function (_a) {
|
|
223
|
-
var _b = __read(_a,
|
|
261
|
+
var _b = __read(_a, 2), log = _b[0].log, recalcInProgress = _b[1].recalcInProgress;
|
|
224
262
|
var sizeRanges = u.stream();
|
|
225
263
|
var totalCount = u.stream();
|
|
226
264
|
var statefulTotalCount = u.statefulStreamFromEmitter(totalCount, 0);
|
|
@@ -230,22 +268,30 @@ export var sizeSystem = u.system(function (_a) {
|
|
|
230
268
|
var groupIndices = u.statefulStream([]);
|
|
231
269
|
var fixedItemSize = u.statefulStream(undefined);
|
|
232
270
|
var defaultItemSize = u.statefulStream(undefined);
|
|
233
|
-
var itemSize = u.statefulStream(function (el, field) {
|
|
234
|
-
return correctItemSize(el, SIZE_MAP[field]);
|
|
235
|
-
});
|
|
271
|
+
var itemSize = u.statefulStream(function (el, field) { return correctItemSize(el, SIZE_MAP[field]); });
|
|
236
272
|
var data = u.statefulStream(undefined);
|
|
273
|
+
var gap = u.statefulStream(0);
|
|
237
274
|
var initial = initialSizeState();
|
|
238
|
-
var sizes = u.statefulStreamFromEmitter(u.pipe(sizeRanges, u.withLatestFrom(groupIndices, log), u.scan(sizeStateReducer, initial), u.distinctUntilChanged()), initial);
|
|
239
|
-
u.
|
|
240
|
-
|
|
275
|
+
var sizes = u.statefulStreamFromEmitter(u.pipe(sizeRanges, u.withLatestFrom(groupIndices, log, gap), u.scan(sizeStateReducer, initial), u.distinctUntilChanged()), initial);
|
|
276
|
+
var prevGroupIndices = u.statefulStreamFromEmitter(u.pipe(groupIndices, u.distinctUntilChanged(), u.scan(function (prev, curr) { return ({ prev: prev.current, current: curr }); }, {
|
|
277
|
+
prev: [],
|
|
278
|
+
current: [],
|
|
279
|
+
}), u.map(function (_a) {
|
|
280
|
+
var prev = _a.prev;
|
|
281
|
+
return prev;
|
|
282
|
+
})), []);
|
|
283
|
+
u.connect(u.pipe(groupIndices, u.filter(function (indexes) { return indexes.length > 0; }), u.withLatestFrom(sizes, gap), u.map(function (_a) {
|
|
284
|
+
var _b = __read(_a, 3), groupIndices = _b[0], sizes = _b[1], gap = _b[2];
|
|
241
285
|
var groupOffsetTree = groupIndices.reduce(function (tree, index, idx) {
|
|
242
|
-
return insert(tree, index, offsetOf(index, sizes.offsetTree) || idx);
|
|
286
|
+
return insert(tree, index, offsetOf(index, sizes.offsetTree, gap) || idx);
|
|
243
287
|
}, newTree());
|
|
244
288
|
return __assign(__assign({}, sizes), { groupIndices: groupIndices,
|
|
245
289
|
groupOffsetTree: groupOffsetTree });
|
|
246
290
|
})), sizes);
|
|
247
291
|
// decreasing the total count should remove any existing entries
|
|
248
292
|
// beyond the last index - do this by publishing the default size as a range over them.
|
|
293
|
+
// This causes some size loss in for the last items, but it's better than having the wrong measurements
|
|
294
|
+
// see #896
|
|
249
295
|
u.connect(u.pipe(totalCount, u.withLatestFrom(sizes), u.filter(function (_a) {
|
|
250
296
|
var _b = __read(_a, 2), totalCount = _b[0], lastIndex = _b[1].lastIndex;
|
|
251
297
|
return totalCount < lastIndex;
|
|
@@ -266,7 +312,7 @@ export var sizeSystem = u.system(function (_a) {
|
|
|
266
312
|
}), u.map(function (size) { return [{ startIndex: 0, endIndex: 0, size: size }]; })), sizeRanges);
|
|
267
313
|
var listRefresh = u.streamFromEmitter(u.pipe(sizeRanges, u.withLatestFrom(sizes), u.scan(function (_a, _b) {
|
|
268
314
|
var oldSizes = _a.sizes;
|
|
269
|
-
var _c = __read(_b, 2), newSizes = _c[1];
|
|
315
|
+
var _c = __read(_b, 2), _ = _c[0], newSizes = _c[1];
|
|
270
316
|
return {
|
|
271
317
|
changed: newSizes !== oldSizes,
|
|
272
318
|
sizes: newSizes,
|
|
@@ -275,10 +321,16 @@ export var sizeSystem = u.system(function (_a) {
|
|
|
275
321
|
u.subscribe(u.pipe(firstItemIndex, u.scan(function (prev, next) {
|
|
276
322
|
return { diff: prev.prev - next, prev: next };
|
|
277
323
|
}, { diff: 0, prev: 0 }), u.map(function (val) { return val.diff; })), function (offset) {
|
|
324
|
+
var groupIndices = u.getValue(sizes).groupIndices;
|
|
278
325
|
if (offset > 0) {
|
|
279
|
-
u.publish(
|
|
326
|
+
u.publish(recalcInProgress, true);
|
|
327
|
+
u.publish(unshiftWith, offset + affectedGroupCount(offset, groupIndices));
|
|
280
328
|
}
|
|
281
329
|
else if (offset < 0) {
|
|
330
|
+
var prevGroupIndicesValue = u.getValue(prevGroupIndices);
|
|
331
|
+
if (prevGroupIndicesValue.length > 0) {
|
|
332
|
+
offset -= affectedGroupCount(-offset, prevGroupIndicesValue);
|
|
333
|
+
}
|
|
282
334
|
u.publish(shiftWith, offset);
|
|
283
335
|
}
|
|
284
336
|
});
|
|
@@ -292,43 +344,117 @@ export var sizeSystem = u.system(function (_a) {
|
|
|
292
344
|
var beforeUnshiftWith = u.streamFromEmitter(unshiftWith);
|
|
293
345
|
u.connect(u.pipe(unshiftWith, u.withLatestFrom(sizes), u.map(function (_a) {
|
|
294
346
|
var _b = __read(_a, 2), unshiftWith = _b[0], sizes = _b[1];
|
|
295
|
-
|
|
296
|
-
|
|
347
|
+
var groupedMode = sizes.groupIndices.length > 0;
|
|
348
|
+
var initialRanges = [];
|
|
349
|
+
var defaultSize = sizes.lastSize;
|
|
350
|
+
if (groupedMode) {
|
|
351
|
+
var firstGroupSize = find(sizes.sizeTree, 0);
|
|
352
|
+
var prependedGroupItemsCount = 0;
|
|
353
|
+
var groupIndex = 0;
|
|
354
|
+
while (prependedGroupItemsCount < unshiftWith) {
|
|
355
|
+
var theGroupIndex = sizes.groupIndices[groupIndex];
|
|
356
|
+
var groupItemCount = sizes.groupIndices.length === groupIndex + 1 ? Infinity : sizes.groupIndices[groupIndex + 1] - theGroupIndex - 1;
|
|
357
|
+
initialRanges.push({
|
|
358
|
+
startIndex: theGroupIndex,
|
|
359
|
+
endIndex: theGroupIndex,
|
|
360
|
+
size: firstGroupSize,
|
|
361
|
+
});
|
|
362
|
+
initialRanges.push({
|
|
363
|
+
startIndex: theGroupIndex + 1,
|
|
364
|
+
endIndex: theGroupIndex + 1 + groupItemCount - 1,
|
|
365
|
+
size: defaultSize,
|
|
366
|
+
});
|
|
367
|
+
groupIndex++;
|
|
368
|
+
prependedGroupItemsCount += groupItemCount + 1;
|
|
369
|
+
}
|
|
370
|
+
var sizeTreeKV = walk(sizes.sizeTree);
|
|
371
|
+
// here, we detect if the first group item size has increased, so that we can delete its value.
|
|
372
|
+
var firstGroupIsExpanded = prependedGroupItemsCount !== unshiftWith;
|
|
373
|
+
if (firstGroupIsExpanded) {
|
|
374
|
+
// remove the first group item size, already incorporated
|
|
375
|
+
sizeTreeKV.shift();
|
|
376
|
+
}
|
|
377
|
+
return sizeTreeKV.reduce(function (acc, _a) {
|
|
378
|
+
var index = _a.k, size = _a.v;
|
|
379
|
+
var ranges = acc.ranges;
|
|
380
|
+
if (acc.prevSize !== 0) {
|
|
381
|
+
ranges = __spread(acc.ranges, [
|
|
382
|
+
{
|
|
383
|
+
startIndex: acc.prevIndex,
|
|
384
|
+
endIndex: index + unshiftWith - 1,
|
|
385
|
+
size: acc.prevSize,
|
|
386
|
+
},
|
|
387
|
+
]);
|
|
388
|
+
}
|
|
389
|
+
return {
|
|
390
|
+
ranges: ranges,
|
|
391
|
+
prevIndex: index + unshiftWith,
|
|
392
|
+
prevSize: size,
|
|
393
|
+
};
|
|
394
|
+
}, {
|
|
395
|
+
ranges: initialRanges,
|
|
396
|
+
prevIndex: unshiftWith,
|
|
397
|
+
prevSize: 0,
|
|
398
|
+
}).ranges;
|
|
297
399
|
}
|
|
298
400
|
return walk(sizes.sizeTree).reduce(function (acc, _a) {
|
|
299
401
|
var index = _a.k, size = _a.v;
|
|
300
402
|
return {
|
|
301
|
-
ranges: __spread(acc.ranges, [
|
|
302
|
-
{
|
|
303
|
-
startIndex: acc.prevIndex,
|
|
304
|
-
endIndex: index + unshiftWith - 1,
|
|
305
|
-
size: acc.prevSize,
|
|
306
|
-
},
|
|
307
|
-
]),
|
|
403
|
+
ranges: __spread(acc.ranges, [{ startIndex: acc.prevIndex, endIndex: index + unshiftWith - 1, size: acc.prevSize }]),
|
|
308
404
|
prevIndex: index + unshiftWith,
|
|
309
405
|
prevSize: size,
|
|
310
406
|
};
|
|
311
407
|
}, {
|
|
312
408
|
ranges: [],
|
|
313
409
|
prevIndex: 0,
|
|
314
|
-
prevSize:
|
|
410
|
+
prevSize: defaultSize,
|
|
315
411
|
}).ranges;
|
|
316
412
|
})), sizeRanges);
|
|
317
|
-
var shiftWithOffset = u.streamFromEmitter(u.pipe(shiftWith, u.withLatestFrom(sizes), u.map(function (_a) {
|
|
318
|
-
var _b = __read(_a,
|
|
413
|
+
var shiftWithOffset = u.streamFromEmitter(u.pipe(shiftWith, u.withLatestFrom(sizes, gap), u.map(function (_a) {
|
|
414
|
+
var _b = __read(_a, 3), shiftWith = _b[0], offsetTree = _b[1].offsetTree, gap = _b[2];
|
|
319
415
|
var newFirstItemIndex = -shiftWith;
|
|
320
|
-
return offsetOf(newFirstItemIndex, offsetTree);
|
|
416
|
+
return offsetOf(newFirstItemIndex, offsetTree, gap);
|
|
321
417
|
})));
|
|
322
|
-
u.connect(u.pipe(shiftWith, u.withLatestFrom(sizes), u.map(function (_a) {
|
|
323
|
-
var _b = __read(_a,
|
|
324
|
-
|
|
325
|
-
|
|
418
|
+
u.connect(u.pipe(shiftWith, u.withLatestFrom(sizes, gap), u.map(function (_a) {
|
|
419
|
+
var _b = __read(_a, 3), shiftWith = _b[0], sizes = _b[1], gap = _b[2];
|
|
420
|
+
var groupedMode = sizes.groupIndices.length > 0;
|
|
421
|
+
if (groupedMode) {
|
|
422
|
+
// we can't shift an empty tree
|
|
423
|
+
if (empty(sizes.sizeTree)) {
|
|
424
|
+
return sizes;
|
|
425
|
+
}
|
|
426
|
+
var newSizeTree = newTree();
|
|
427
|
+
var prevGroupIndicesValue = u.getValue(prevGroupIndices);
|
|
428
|
+
var removedItemsCount = 0;
|
|
429
|
+
var groupIndex = 0;
|
|
430
|
+
var groupOffset = 0;
|
|
431
|
+
while (removedItemsCount < -shiftWith) {
|
|
432
|
+
groupOffset = prevGroupIndicesValue[groupIndex];
|
|
433
|
+
var groupItemCount = prevGroupIndicesValue[groupIndex + 1] - groupOffset - 1;
|
|
434
|
+
groupIndex++;
|
|
435
|
+
removedItemsCount += groupItemCount + 1;
|
|
436
|
+
}
|
|
437
|
+
newSizeTree = walk(sizes.sizeTree).reduce(function (acc, _a) {
|
|
438
|
+
var k = _a.k, v = _a.v;
|
|
439
|
+
return insert(acc, Math.max(0, k + shiftWith), v);
|
|
440
|
+
}, newSizeTree);
|
|
441
|
+
// here, we detect if the first group item size has increased, so that we can delete its value.
|
|
442
|
+
var aGroupIsShrunk = removedItemsCount !== -shiftWith;
|
|
443
|
+
if (aGroupIsShrunk) {
|
|
444
|
+
var firstGroupSize = find(sizes.sizeTree, groupOffset);
|
|
445
|
+
newSizeTree = insert(newSizeTree, 0, firstGroupSize);
|
|
446
|
+
var nextItemSize = findMaxKeyValue(sizes.sizeTree, -shiftWith + 1)[1];
|
|
447
|
+
newSizeTree = insert(newSizeTree, 1, nextItemSize);
|
|
448
|
+
}
|
|
449
|
+
return __assign(__assign(__assign({}, sizes), { sizeTree: newSizeTree }), createOffsetTree(sizes.offsetTree, 0, newSizeTree, gap));
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
var newSizeTree = walk(sizes.sizeTree).reduce(function (acc, _a) {
|
|
453
|
+
var k = _a.k, v = _a.v;
|
|
454
|
+
return insert(acc, Math.max(0, k + shiftWith), v);
|
|
455
|
+
}, newTree());
|
|
456
|
+
return __assign(__assign(__assign({}, sizes), { sizeTree: newSizeTree }), createOffsetTree(sizes.offsetTree, 0, newSizeTree, gap));
|
|
326
457
|
}
|
|
327
|
-
var newSizeTree = walk(sizes.sizeTree).reduce(function (acc, _a) {
|
|
328
|
-
var k = _a.k, v = _a.v;
|
|
329
|
-
return insert(acc, Math.max(0, k + shiftWith), v);
|
|
330
|
-
}, newTree());
|
|
331
|
-
return __assign(__assign(__assign({}, sizes), { sizeTree: newSizeTree }), createOffsetTree(sizes.offsetTree, 0, newSizeTree));
|
|
332
458
|
})), sizes);
|
|
333
459
|
return {
|
|
334
460
|
// input
|
|
@@ -343,6 +469,7 @@ export var sizeSystem = u.system(function (_a) {
|
|
|
343
469
|
shiftWithOffset: shiftWithOffset,
|
|
344
470
|
beforeUnshiftWith: beforeUnshiftWith,
|
|
345
471
|
firstItemIndex: firstItemIndex,
|
|
472
|
+
gap: gap,
|
|
346
473
|
// output
|
|
347
474
|
sizes: sizes,
|
|
348
475
|
listRefresh: listRefresh,
|
|
@@ -350,4 +477,4 @@ export var sizeSystem = u.system(function (_a) {
|
|
|
350
477
|
trackItemSizes: trackItemSizes,
|
|
351
478
|
itemSize: itemSize,
|
|
352
479
|
};
|
|
353
|
-
}, u.tup(loggerSystem), { singleton: true });
|
|
480
|
+
}, u.tup(loggerSystem, recalcSystem), { singleton: true });
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __read } from "tslib";
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-
|
|
3
|
-
import * as u from '
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
3
|
+
import * as u from './urx';
|
|
4
4
|
import { domIOSystem } from './domIOSystem';
|
|
5
|
+
import { approximatelyEqual } from './utils/approximatelyEqual';
|
|
5
6
|
export var UP = 'up';
|
|
6
7
|
export var DOWN = 'down';
|
|
7
8
|
export var NONE = 'none';
|
|
@@ -15,6 +16,7 @@ var INITIAL_BOTTOM_STATE = {
|
|
|
15
16
|
scrollHeight: 0,
|
|
16
17
|
},
|
|
17
18
|
};
|
|
19
|
+
var DEFAULT_AT_TOP_THRESHOLD = 0;
|
|
18
20
|
export var stateFlagsSystem = u.system(function (_a) {
|
|
19
21
|
var _b = __read(_a, 1), _c = _b[0], scrollContainerState = _c.scrollContainerState, scrollTop = _c.scrollTop, viewportHeight = _c.viewportHeight, headerHeight = _c.headerHeight, footerHeight = _c.footerHeight, scrollBy = _c.scrollBy;
|
|
20
22
|
var isAtBottom = u.statefulStream(false);
|
|
@@ -22,12 +24,16 @@ export var stateFlagsSystem = u.system(function (_a) {
|
|
|
22
24
|
var atBottomStateChange = u.stream();
|
|
23
25
|
var atTopStateChange = u.stream();
|
|
24
26
|
var atBottomThreshold = u.statefulStream(4);
|
|
27
|
+
var atTopThreshold = u.statefulStream(DEFAULT_AT_TOP_THRESHOLD);
|
|
25
28
|
// skip 1 to avoid an initial on/off flick
|
|
26
|
-
var isScrolling = u.
|
|
29
|
+
var isScrolling = u.statefulStreamFromEmitter(u.pipe(u.merge(u.pipe(u.duc(scrollTop), u.skip(1), u.mapTo(true)), u.pipe(u.duc(scrollTop), u.skip(1), u.mapTo(false), u.debounceTime(100))), u.distinctUntilChanged()), false);
|
|
27
30
|
var isScrollingBy = u.statefulStreamFromEmitter(u.pipe(u.merge(u.pipe(scrollBy, u.mapTo(true)), u.pipe(scrollBy, u.mapTo(false), u.debounceTime(200))), u.distinctUntilChanged()), false);
|
|
28
31
|
// u.subscribe(isScrollingBy, (isScrollingBy) => console.log({ isScrollingBy }))
|
|
29
|
-
u.connect(u.pipe(u.duc(scrollTop), u.
|
|
30
|
-
|
|
32
|
+
u.connect(u.pipe(u.combineLatest(u.duc(scrollTop), u.duc(atTopThreshold)), u.map(function (_a) {
|
|
33
|
+
var _b = __read(_a, 2), top = _b[0], atTopThreshold = _b[1];
|
|
34
|
+
return top <= atTopThreshold;
|
|
35
|
+
}), u.distinctUntilChanged()), isAtTop);
|
|
36
|
+
u.connect(u.pipe(isAtTop, u.throttleTime(50)), atTopStateChange);
|
|
31
37
|
var atBottomState = u.streamFromEmitter(u.pipe(u.combineLatest(scrollContainerState, u.duc(viewportHeight), u.duc(headerHeight), u.duc(footerHeight), u.duc(atBottomThreshold)), u.scan(function (current, _a) {
|
|
32
38
|
var _b = __read(_a, 5), _c = _b[0], scrollTop = _c.scrollTop, scrollHeight = _c.scrollHeight, viewportHeight = _b[1], _headerHeight = _b[2], _footerHeight = _b[3], atBottomThreshold = _b[4];
|
|
33
39
|
var isAtBottom = scrollTop + viewportHeight - scrollHeight > -atBottomThreshold;
|
|
@@ -45,9 +51,7 @@ export var stateFlagsSystem = u.system(function (_a) {
|
|
|
45
51
|
}
|
|
46
52
|
else {
|
|
47
53
|
atBottomBecause = 'SIZE_DECREASED';
|
|
48
|
-
scrollTopDelta =
|
|
49
|
-
current.state.scrollTop - scrollTop ||
|
|
50
|
-
current.scrollTopDelta;
|
|
54
|
+
scrollTopDelta = current.state.scrollTop - scrollTop || current.scrollTopDelta;
|
|
51
55
|
}
|
|
52
56
|
return {
|
|
53
57
|
atBottom: true,
|
|
@@ -79,8 +83,8 @@ export var stateFlagsSystem = u.system(function (_a) {
|
|
|
79
83
|
})));
|
|
80
84
|
var lastJumpDueToItemResize = u.statefulStreamFromEmitter(u.pipe(scrollContainerState, u.scan(function (current, _a) {
|
|
81
85
|
var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, viewportHeight = _a.viewportHeight;
|
|
82
|
-
if (current.scrollHeight
|
|
83
|
-
var atBottom = scrollTop
|
|
86
|
+
if (!approximatelyEqual(current.scrollHeight, scrollHeight)) {
|
|
87
|
+
var atBottom = scrollHeight - (scrollTop + viewportHeight) < 1;
|
|
84
88
|
if (current.scrollTop !== scrollTop && atBottom) {
|
|
85
89
|
return {
|
|
86
90
|
scrollHeight: scrollHeight,
|
|
@@ -89,19 +93,23 @@ export var stateFlagsSystem = u.system(function (_a) {
|
|
|
89
93
|
changed: true,
|
|
90
94
|
};
|
|
91
95
|
}
|
|
96
|
+
else {
|
|
97
|
+
return {
|
|
98
|
+
scrollHeight: scrollHeight,
|
|
99
|
+
scrollTop: scrollTop,
|
|
100
|
+
jump: 0,
|
|
101
|
+
changed: true,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
92
106
|
return {
|
|
93
|
-
scrollHeight: scrollHeight,
|
|
94
107
|
scrollTop: scrollTop,
|
|
108
|
+
scrollHeight: scrollHeight,
|
|
95
109
|
jump: 0,
|
|
96
|
-
changed:
|
|
110
|
+
changed: false,
|
|
97
111
|
};
|
|
98
112
|
}
|
|
99
|
-
return {
|
|
100
|
-
scrollTop: scrollTop,
|
|
101
|
-
scrollHeight: scrollHeight,
|
|
102
|
-
jump: 0,
|
|
103
|
-
changed: false,
|
|
104
|
-
};
|
|
105
113
|
}, { scrollHeight: 0, jump: 0, scrollTop: 0, changed: false }), u.filter(function (value) { return value.changed; }), u.map(function (value) { return value.jump; })), 0);
|
|
106
114
|
u.connect(u.pipe(atBottomState, u.map(function (state) { return state.atBottom; })), isAtBottom);
|
|
107
115
|
u.connect(u.pipe(isAtBottom, u.throttleTime(50)), atBottomStateChange);
|
|
@@ -115,14 +123,14 @@ export var stateFlagsSystem = u.system(function (_a) {
|
|
|
115
123
|
if (u.getValue(isScrollingBy)) {
|
|
116
124
|
return { direction: acc.direction, prevScrollTop: scrollTop };
|
|
117
125
|
}
|
|
118
|
-
return {
|
|
119
|
-
direction: scrollTop < acc.prevScrollTop ? UP : DOWN,
|
|
120
|
-
prevScrollTop: scrollTop,
|
|
121
|
-
};
|
|
126
|
+
return { direction: scrollTop < acc.prevScrollTop ? UP : DOWN, prevScrollTop: scrollTop };
|
|
122
127
|
}, { direction: DOWN, prevScrollTop: 0 }), u.map(function (value) { return value.direction; })), scrollDirection);
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
123
129
|
u.connect(u.pipe(scrollContainerState, u.throttleTime(50), u.mapTo(NONE)), scrollDirection);
|
|
124
130
|
var scrollVelocity = u.statefulStream(0);
|
|
125
|
-
u.connect(u.pipe(isScrolling, u.filter(function (value) { return !value; }),
|
|
131
|
+
u.connect(u.pipe(isScrolling, u.filter(function (value) { return !value; }),
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
133
|
+
u.mapTo(0)), scrollVelocity);
|
|
126
134
|
u.connect(u.pipe(scrollTop, u.throttleTime(100), u.withLatestFrom(isScrolling), u.filter(function (_a) {
|
|
127
135
|
var _b = __read(_a, 2), _ = _b[0], isScrolling = _b[1];
|
|
128
136
|
return !!isScrolling;
|
|
@@ -143,6 +151,7 @@ export var stateFlagsSystem = u.system(function (_a) {
|
|
|
143
151
|
atBottomStateChange: atBottomStateChange,
|
|
144
152
|
scrollDirection: scrollDirection,
|
|
145
153
|
atBottomThreshold: atBottomThreshold,
|
|
154
|
+
atTopThreshold: atTopThreshold,
|
|
146
155
|
scrollVelocity: scrollVelocity,
|
|
147
156
|
lastJumpDueToItemResize: lastJumpDueToItemResize,
|
|
148
157
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { __read } from "tslib";
|
|
2
|
+
import { domIOSystem } from './domIOSystem';
|
|
3
|
+
import { initialTopMostItemIndexSystem } from './initialTopMostItemIndexSystem';
|
|
4
|
+
import { propsReadySystem } from './propsReadySystem';
|
|
5
|
+
import { sizeSystem, sizeTreeToRanges } from './sizeSystem';
|
|
6
|
+
import * as u from './urx';
|
|
7
|
+
import { windowScrollerSystem } from './windowScrollerSystem';
|
|
8
|
+
export var stateLoadSystem = u.system(function (_a) {
|
|
9
|
+
var _b = __read(_a, 5), _c = _b[0], sizes = _c.sizes, sizeRanges = _c.sizeRanges, scrollTop = _b[1].scrollTop, initialTopMostItemIndex = _b[2].initialTopMostItemIndex, didMount = _b[3].didMount, _d = _b[4], useWindowScroll = _d.useWindowScroll, windowScrollContainerState = _d.windowScrollContainerState, windowViewportRect = _d.windowViewportRect;
|
|
10
|
+
var getState = u.stream();
|
|
11
|
+
var restoreStateFrom = u.statefulStream(undefined);
|
|
12
|
+
var statefulWindowScrollContainerState = u.statefulStream(null);
|
|
13
|
+
var statefulWindowViewportRect = u.statefulStream(null);
|
|
14
|
+
u.connect(windowScrollContainerState, statefulWindowScrollContainerState);
|
|
15
|
+
u.connect(windowViewportRect, statefulWindowViewportRect);
|
|
16
|
+
u.subscribe(u.pipe(getState, u.withLatestFrom(sizes, scrollTop, useWindowScroll, statefulWindowScrollContainerState, statefulWindowViewportRect)), function (_a) {
|
|
17
|
+
var _b = __read(_a, 6), callback = _b[0], sizes = _b[1], scrollTop = _b[2], useWindowScroll = _b[3], windowScrollContainerState = _b[4], windowViewportRect = _b[5];
|
|
18
|
+
var ranges = sizeTreeToRanges(sizes.sizeTree);
|
|
19
|
+
if (useWindowScroll && windowScrollContainerState !== null && windowViewportRect !== null) {
|
|
20
|
+
scrollTop = windowScrollContainerState.scrollTop - windowViewportRect.offsetTop;
|
|
21
|
+
}
|
|
22
|
+
callback({ ranges: ranges, scrollTop: scrollTop });
|
|
23
|
+
});
|
|
24
|
+
u.connect(u.pipe(restoreStateFrom, u.filter(u.isDefined), u.map(locationFromSnapshot)), initialTopMostItemIndex);
|
|
25
|
+
u.connect(u.pipe(didMount, u.withLatestFrom(restoreStateFrom), u.filter(function (_a) {
|
|
26
|
+
var _b = __read(_a, 2), state = _b[1];
|
|
27
|
+
return state !== undefined;
|
|
28
|
+
}), u.distinctUntilChanged(), u.map(function (_a) {
|
|
29
|
+
var _b = __read(_a, 2), snapshot = _b[1];
|
|
30
|
+
return snapshot.ranges;
|
|
31
|
+
})), sizeRanges);
|
|
32
|
+
return {
|
|
33
|
+
getState: getState,
|
|
34
|
+
restoreStateFrom: restoreStateFrom,
|
|
35
|
+
};
|
|
36
|
+
}, u.tup(sizeSystem, domIOSystem, initialTopMostItemIndexSystem, propsReadySystem, windowScrollerSystem));
|
|
37
|
+
function locationFromSnapshot(snapshot) {
|
|
38
|
+
return { offset: snapshot.scrollTop, index: 0, align: 'start' };
|
|
39
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __read } from "tslib";
|
|
2
|
-
import
|
|
2
|
+
import * as u from './urx';
|
|
3
3
|
import { listStateSystem } from './listStateSystem';
|
|
4
|
-
export var topItemCountSystem = system(function (_a) {
|
|
4
|
+
export var topItemCountSystem = u.system(function (_a) {
|
|
5
5
|
var _b = __read(_a, 1), topItemsIndexes = _b[0].topItemsIndexes;
|
|
6
|
-
var topItemCount = statefulStream(0);
|
|
7
|
-
connect(pipe(topItemCount, filter(function (length) { return length > 0; }), map(function (length) { return Array.from({ length: length }).map(function (_, index) { return index; }); })), topItemsIndexes);
|
|
6
|
+
var topItemCount = u.statefulStream(0);
|
|
7
|
+
u.connect(u.pipe(topItemCount, u.filter(function (length) { return length > 0; }), u.map(function (length) { return Array.from({ length: length }).map(function (_, index) { return index; }); })), topItemsIndexes);
|
|
8
8
|
return { topItemCount: topItemCount };
|
|
9
|
-
}, tup(listStateSystem));
|
|
9
|
+
}, u.tup(listStateSystem));
|
|
@@ -1,20 +1,13 @@
|
|
|
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 { listStateSystem } from './listStateSystem';
|
|
4
|
+
import { domIOSystem } from './domIOSystem';
|
|
5
5
|
export var totalListHeightSystem = u.system(function (_a) {
|
|
6
|
-
var _b = __read(_a, 2), _c = _b[0], footerHeight = _c.footerHeight, headerHeight = _c.headerHeight, listState = _b[1].listState;
|
|
6
|
+
var _b = __read(_a, 2), _c = _b[0], footerHeight = _c.footerHeight, headerHeight = _c.headerHeight, fixedHeaderHeight = _c.fixedHeaderHeight, fixedFooterHeight = _c.fixedFooterHeight, listState = _b[1].listState;
|
|
7
7
|
var totalListHeightChanged = u.stream();
|
|
8
|
-
var totalListHeight = u.statefulStreamFromEmitter(u.pipe(u.combineLatest(footerHeight, headerHeight, listState), u.map(function (_a) {
|
|
9
|
-
var _b = __read(_a,
|
|
10
|
-
|
|
11
|
-
// console.log('-------- [totalListHeightSystem Log] --------');
|
|
12
|
-
// console.log(footerHeight, headerHeight, listState);
|
|
13
|
-
// console.log('---------------- [Log End] ----------------');
|
|
14
|
-
return (footerHeight +
|
|
15
|
-
headerHeight +
|
|
16
|
-
listState.offsetBottom +
|
|
17
|
-
listState.bottom);
|
|
8
|
+
var totalListHeight = u.statefulStreamFromEmitter(u.pipe(u.combineLatest(footerHeight, fixedFooterHeight, headerHeight, fixedHeaderHeight, listState), u.map(function (_a) {
|
|
9
|
+
var _b = __read(_a, 5), footerHeight = _b[0], fixedFooterHeight = _b[1], headerHeight = _b[2], fixedHeaderHeight = _b[3], listState = _b[4];
|
|
10
|
+
return footerHeight + fixedFooterHeight + headerHeight + fixedHeaderHeight + listState.offsetBottom + listState.bottom;
|
|
18
11
|
})), 0);
|
|
19
12
|
u.connect(u.duc(totalListHeight), totalListHeightChanged);
|
|
20
13
|
return { totalListHeight: totalListHeight, totalListHeightChanged: totalListHeightChanged };
|