@ringcentral/juno 2.4.2 → 2.5.0-beta.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 +74 -2
- package/components/Grid/Grid.d.ts +1 -1
- package/components/Pagination/Pagination/Pagination.d.ts +1 -1
- package/components/Stepper/StepButton/StepButton.d.ts +1 -1
- package/components/Stepper/StepLabel/StepLabel.d.ts +1 -1
- package/components/Table/TableCell/styles/TableCellStyle.js +3 -1
- package/components/Table/types.d.ts +1 -1
- package/components/TablePagination/TablePagination.d.ts +1 -1
- package/components/VirtualizedMenu/VirtualizedMenu.js +11 -0
- package/components/VirtualizedMenu/VirtualizedMenuList.js +6 -2
- package/components/Virtuoso/react-virtuoso/AATree.js +15 -15
- package/components/Virtuoso/react-virtuoso/Grid.d.ts +193 -106
- package/components/Virtuoso/react-virtuoso/Grid.js +19 -24
- package/components/Virtuoso/react-virtuoso/List.d.ts +2664 -596
- package/components/Virtuoso/react-virtuoso/List.js +83 -70
- package/components/Virtuoso/react-virtuoso/Table.d.ts +6253 -0
- package/components/Virtuoso/react-virtuoso/Table.js +184 -0
- package/components/Virtuoso/react-virtuoso/alignToBottomSystem.d.ts +153 -37
- package/components/Virtuoso/react-virtuoso/components.d.ts +248 -41
- package/components/Virtuoso/react-virtuoso/components.js +2 -0
- package/components/Virtuoso/react-virtuoso/domIOSystem.d.ts +2 -4
- package/components/Virtuoso/react-virtuoso/domIOSystem.js +12 -10
- package/components/Virtuoso/react-virtuoso/followOutputSystem.d.ts +146 -27
- package/components/Virtuoso/react-virtuoso/followOutputSystem.js +28 -15
- package/components/Virtuoso/react-virtuoso/gridSystem.d.ts +67 -52
- package/components/Virtuoso/react-virtuoso/gridSystem.js +17 -15
- package/components/Virtuoso/react-virtuoso/groupedListSystem.d.ts +17 -3
- package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.d.ts +2 -1
- package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +32 -7
- package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +40 -26
- package/components/Virtuoso/react-virtuoso/hooks/useSize.d.ts +2 -2
- package/components/Virtuoso/react-virtuoso/hooks/useSize.js +26 -28
- package/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +32 -12
- package/components/Virtuoso/react-virtuoso/index.d.ts +1 -0
- package/components/Virtuoso/react-virtuoso/index.js +2 -0
- package/components/Virtuoso/react-virtuoso/initialItemCountSystem.d.ts +165 -35
- package/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +1 -8
- package/components/Virtuoso/react-virtuoso/initialScrollTopSystem.d.ts +160 -38
- package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.d.ts +54 -12
- package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +26 -10
- package/components/Virtuoso/react-virtuoso/interfaces.d.ts +134 -28
- package/components/Virtuoso/react-virtuoso/listStateSystem.d.ts +141 -32
- package/components/Virtuoso/react-virtuoso/listStateSystem.js +1 -2
- package/components/Virtuoso/react-virtuoso/listSystem.d.ts +2123 -407
- package/components/Virtuoso/react-virtuoso/listSystem.js +10 -7
- package/components/Virtuoso/react-virtuoso/loggerSystem.d.ts +17 -0
- package/components/Virtuoso/react-virtuoso/loggerSystem.js +37 -0
- package/components/Virtuoso/react-virtuoso/propsReadySystem.d.ts +8 -1
- package/components/Virtuoso/react-virtuoso/propsReadySystem.js +8 -2
- package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.d.ts +641 -0
- package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +42 -0
- package/components/Virtuoso/react-virtuoso/scrollSeekSystem.d.ts +52 -67
- package/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +11 -25
- package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.d.ts +26 -5
- package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +37 -13
- package/components/Virtuoso/react-virtuoso/sizeRangeSystem.d.ts +11 -4
- package/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +44 -15
- package/components/Virtuoso/react-virtuoso/sizeSystem.d.ts +12 -2
- package/components/Virtuoso/react-virtuoso/sizeSystem.js +109 -52
- package/components/Virtuoso/react-virtuoso/stateFlagsSystem.d.ts +17 -5
- package/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +87 -18
- package/components/Virtuoso/react-virtuoso/topItemCountSystem.d.ts +145 -33
- package/components/Virtuoso/react-virtuoso/totalListHeightSystem.d.ts +149 -35
- package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.d.ts +183 -42
- package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +37 -26
- package/components/Virtuoso/react-virtuoso/utils/correctItemSize.d.ts +1 -0
- package/components/Virtuoso/react-virtuoso/utils/correctItemSize.js +6 -0
- package/components/Virtuoso/react-virtuoso/windowScrollerSystem.d.ts +7 -4
- package/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +9 -7
- package/es6/components/Table/TableCell/TableCell.js +2 -2
- package/es6/components/Table/TableCell/styles/TableCellStyle.js +3 -1
- package/es6/components/VirtualizedMenu/VirtualizedMenu.js +13 -2
- package/es6/components/VirtualizedMenu/VirtualizedMenuList.js +6 -2
- package/es6/components/Virtuoso/react-virtuoso/AATree.js +15 -15
- package/es6/components/Virtuoso/react-virtuoso/Grid.js +20 -25
- package/es6/components/Virtuoso/react-virtuoso/List.js +84 -72
- package/es6/components/Virtuoso/react-virtuoso/Table.js +182 -0
- package/es6/components/Virtuoso/react-virtuoso/components.js +2 -0
- package/es6/components/Virtuoso/react-virtuoso/domIOSystem.js +13 -10
- package/es6/components/Virtuoso/react-virtuoso/followOutputSystem.js +28 -15
- package/es6/components/Virtuoso/react-virtuoso/gridSystem.js +17 -15
- package/es6/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +31 -6
- package/es6/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +40 -26
- package/es6/components/Virtuoso/react-virtuoso/hooks/useSize.js +27 -29
- package/es6/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +32 -12
- package/es6/components/Virtuoso/react-virtuoso/index.js +1 -0
- package/es6/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +1 -8
- package/es6/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +25 -10
- package/es6/components/Virtuoso/react-virtuoso/listStateSystem.js +2 -3
- package/es6/components/Virtuoso/react-virtuoso/listSystem.js +10 -7
- package/es6/components/Virtuoso/react-virtuoso/loggerSystem.js +34 -0
- package/es6/components/Virtuoso/react-virtuoso/propsReadySystem.js +9 -2
- package/es6/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +40 -0
- package/es6/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +11 -25
- package/es6/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +37 -13
- package/es6/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +39 -11
- package/es6/components/Virtuoso/react-virtuoso/sizeSystem.js +109 -52
- package/es6/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +87 -18
- package/es6/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +39 -28
- package/es6/components/Virtuoso/react-virtuoso/utils/correctItemSize.js +3 -0
- package/es6/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +9 -7
- package/package.json +2 -2
|
@@ -4,7 +4,9 @@ var tslib_1 = require("tslib");
|
|
|
4
4
|
/* eslint-disable no-continue */
|
|
5
5
|
var u = tslib_1.__importStar(require("@virtuoso.dev/urx"));
|
|
6
6
|
var AATree_1 = require("./AATree");
|
|
7
|
+
var loggerSystem_1 = require("./loggerSystem");
|
|
7
8
|
var arrayBinarySearch = tslib_1.__importStar(require("./utils/binaryArraySearch"));
|
|
9
|
+
var correctItemSize_1 = require("./utils/correctItemSize");
|
|
8
10
|
function rangeIncludes(refRange) {
|
|
9
11
|
var size = refRange.size, startIndex = refRange.startIndex, endIndex = refRange.endIndex;
|
|
10
12
|
return function (range) {
|
|
@@ -110,80 +112,92 @@ function rangesWithinOffsets(tree, startOffset, endOffset, minStartIndex) {
|
|
|
110
112
|
return AATree_1.arrayToRanges(arrayBinarySearch.findRange(tree, startOffset, endOffset, offsetComparator), offsetPointParser);
|
|
111
113
|
}
|
|
112
114
|
exports.rangesWithinOffsets = rangesWithinOffsets;
|
|
113
|
-
function
|
|
114
|
-
var
|
|
115
|
-
var
|
|
116
|
-
var sizeTree = state.sizeTree;
|
|
117
|
-
var offsetTree = state.offsetTree;
|
|
118
|
-
var newSizeTree = sizeTree;
|
|
119
|
-
var syncStart = 0;
|
|
120
|
-
// We receive probe item results from a group probe,
|
|
121
|
-
// which should always pass an item and a group
|
|
122
|
-
// the results contain two ranges, which we consider to mean that groups and items have different size
|
|
123
|
-
if (groupIndices.length > 0 && AATree_1.empty(sizeTree) && ranges.length === 2) {
|
|
124
|
-
var groupSize_1 = ranges[0].size;
|
|
125
|
-
var itemSize_1 = ranges[1].size;
|
|
126
|
-
newSizeTree = groupIndices.reduce(function (tree, groupIndex) {
|
|
127
|
-
return AATree_1.insert(AATree_1.insert(tree, groupIndex, groupSize_1), groupIndex + 1, itemSize_1);
|
|
128
|
-
}, newSizeTree);
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
_b = tslib_1.__read(insertRanges(newSizeTree, ranges), 2), newSizeTree = _b[0], syncStart = _b[1];
|
|
132
|
-
}
|
|
133
|
-
if (newSizeTree === sizeTree) {
|
|
134
|
-
return state;
|
|
135
|
-
}
|
|
115
|
+
function createOffsetTree(prevOffsetTree, syncStart, sizeTree) {
|
|
116
|
+
var e_3, _a;
|
|
117
|
+
var offsetTree = prevOffsetTree;
|
|
136
118
|
var prevIndex = 0;
|
|
137
119
|
var prevSize = 0;
|
|
138
|
-
var
|
|
139
|
-
var
|
|
120
|
+
var prevOffset = 0;
|
|
121
|
+
var startIndex = 0;
|
|
140
122
|
if (syncStart !== 0) {
|
|
141
|
-
|
|
142
|
-
var offsetInfo = offsetTree[
|
|
143
|
-
|
|
144
|
-
var kv = AATree_1.findMaxKeyValue(
|
|
123
|
+
startIndex = arrayBinarySearch.findIndexOfClosestSmallerOrEqual(offsetTree, syncStart - 1, indexComparator);
|
|
124
|
+
var offsetInfo = offsetTree[startIndex];
|
|
125
|
+
prevOffset = offsetInfo.offset;
|
|
126
|
+
var kv = AATree_1.findMaxKeyValue(sizeTree, syncStart - 1);
|
|
145
127
|
prevIndex = kv[0];
|
|
146
128
|
prevSize = kv[1];
|
|
147
129
|
if (offsetTree.length &&
|
|
148
|
-
offsetTree[
|
|
149
|
-
|
|
150
|
-
startAIndex -= 1;
|
|
130
|
+
offsetTree[startIndex].size === AATree_1.findMaxKeyValue(sizeTree, syncStart)[1]) {
|
|
131
|
+
startIndex -= 1;
|
|
151
132
|
}
|
|
152
|
-
offsetTree = offsetTree.slice(0,
|
|
133
|
+
offsetTree = offsetTree.slice(0, startIndex + 1);
|
|
153
134
|
}
|
|
154
135
|
else {
|
|
155
136
|
offsetTree = [];
|
|
156
137
|
}
|
|
157
138
|
try {
|
|
158
|
-
for (var
|
|
159
|
-
var
|
|
160
|
-
var aOffset = (
|
|
139
|
+
for (var _b = tslib_1.__values(AATree_1.rangesWithin(sizeTree, syncStart, Infinity)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
140
|
+
var _d = _c.value, startIndex_1 = _d.start, value = _d.value;
|
|
141
|
+
var aOffset = (startIndex_1 - prevIndex) * prevSize + prevOffset;
|
|
161
142
|
offsetTree.push({
|
|
162
143
|
offset: aOffset,
|
|
163
144
|
size: value,
|
|
164
|
-
index:
|
|
145
|
+
index: startIndex_1,
|
|
165
146
|
});
|
|
166
|
-
prevIndex =
|
|
167
|
-
|
|
147
|
+
prevIndex = startIndex_1;
|
|
148
|
+
prevOffset = aOffset;
|
|
168
149
|
prevSize = value;
|
|
169
150
|
}
|
|
170
151
|
}
|
|
171
152
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
172
153
|
finally {
|
|
173
154
|
try {
|
|
174
|
-
if (
|
|
155
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
175
156
|
}
|
|
176
157
|
finally { if (e_3) throw e_3.error; }
|
|
177
158
|
}
|
|
178
159
|
return {
|
|
179
|
-
sizeTree: newSizeTree,
|
|
180
160
|
offsetTree: offsetTree,
|
|
181
|
-
groupOffsetTree: groupIndices.reduce(function (tree, index) {
|
|
182
|
-
return AATree_1.insert(tree, index, offsetOf(index, offsetTree));
|
|
183
|
-
}, AATree_1.newTree()),
|
|
184
161
|
lastIndex: prevIndex,
|
|
185
|
-
lastOffset:
|
|
162
|
+
lastOffset: prevOffset,
|
|
186
163
|
lastSize: prevSize,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function sizeStateReducer(state, _a) {
|
|
167
|
+
var _b;
|
|
168
|
+
var _c = tslib_1.__read(_a, 3), ranges = _c[0], groupIndices = _c[1], log = _c[2];
|
|
169
|
+
if (ranges.length > 0) {
|
|
170
|
+
log('received item sizes', ranges, loggerSystem_1.LogLevel.DEBUG);
|
|
171
|
+
}
|
|
172
|
+
var sizeTree = state.sizeTree;
|
|
173
|
+
var newSizeTree = sizeTree;
|
|
174
|
+
var syncStart = 0;
|
|
175
|
+
// We receive probe item results from a group probe,
|
|
176
|
+
// which should always pass an item and a group
|
|
177
|
+
// the results contain two ranges, which we consider to mean that groups and items have different size
|
|
178
|
+
if (groupIndices.length > 0 && AATree_1.empty(sizeTree) && ranges.length === 2) {
|
|
179
|
+
var groupSize_1 = ranges[0].size;
|
|
180
|
+
var itemSize_1 = ranges[1].size;
|
|
181
|
+
newSizeTree = groupIndices.reduce(function (tree, groupIndex) {
|
|
182
|
+
return AATree_1.insert(AATree_1.insert(tree, groupIndex, groupSize_1), groupIndex + 1, itemSize_1);
|
|
183
|
+
}, newSizeTree);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
_b = tslib_1.__read(insertRanges(newSizeTree, ranges), 2), newSizeTree = _b[0], syncStart = _b[1];
|
|
187
|
+
}
|
|
188
|
+
if (newSizeTree === sizeTree) {
|
|
189
|
+
return state;
|
|
190
|
+
}
|
|
191
|
+
var _d = createOffsetTree(state.offsetTree, syncStart, newSizeTree), newOffsetTree = _d.offsetTree, lastIndex = _d.lastIndex, lastSize = _d.lastSize, lastOffset = _d.lastOffset;
|
|
192
|
+
return {
|
|
193
|
+
sizeTree: newSizeTree,
|
|
194
|
+
offsetTree: newOffsetTree,
|
|
195
|
+
lastIndex: lastIndex,
|
|
196
|
+
lastOffset: lastOffset,
|
|
197
|
+
lastSize: lastSize,
|
|
198
|
+
groupOffsetTree: groupIndices.reduce(function (tree, index) {
|
|
199
|
+
return AATree_1.insert(tree, index, offsetOf(index, newOffsetTree));
|
|
200
|
+
}, AATree_1.newTree()),
|
|
187
201
|
groupIndices: groupIndices,
|
|
188
202
|
};
|
|
189
203
|
}
|
|
@@ -212,18 +226,27 @@ function hasGroups(sizes) {
|
|
|
212
226
|
return !AATree_1.empty(sizes.groupOffsetTree);
|
|
213
227
|
}
|
|
214
228
|
exports.hasGroups = hasGroups;
|
|
215
|
-
|
|
229
|
+
var SIZE_MAP = {
|
|
230
|
+
offsetHeight: 'height',
|
|
231
|
+
offsetWidth: 'width',
|
|
232
|
+
};
|
|
233
|
+
exports.sizeSystem = u.system(function (_a) {
|
|
234
|
+
var _b = tslib_1.__read(_a, 1), log = _b[0].log;
|
|
216
235
|
var sizeRanges = u.stream();
|
|
217
236
|
var totalCount = u.stream();
|
|
237
|
+
var statefulTotalCount = u.statefulStreamFromEmitter(totalCount, 0);
|
|
218
238
|
var unshiftWith = u.stream();
|
|
239
|
+
var shiftWith = u.stream();
|
|
219
240
|
var firstItemIndex = u.statefulStream(0);
|
|
220
241
|
var groupIndices = u.statefulStream([]);
|
|
221
242
|
var fixedItemSize = u.statefulStream(undefined);
|
|
222
243
|
var defaultItemSize = u.statefulStream(undefined);
|
|
223
|
-
var itemSize = u.statefulStream(function (el, field) {
|
|
244
|
+
var itemSize = u.statefulStream(function (el, field) {
|
|
245
|
+
return correctItemSize_1.correctItemSize(el, SIZE_MAP[field]);
|
|
246
|
+
});
|
|
224
247
|
var data = u.statefulStream(undefined);
|
|
225
248
|
var initial = initialSizeState();
|
|
226
|
-
var sizes = u.statefulStreamFromEmitter(u.pipe(sizeRanges, u.withLatestFrom(groupIndices), u.scan(sizeStateReducer, initial), u.distinctUntilChanged()), initial);
|
|
249
|
+
var sizes = u.statefulStreamFromEmitter(u.pipe(sizeRanges, u.withLatestFrom(groupIndices, log), u.scan(sizeStateReducer, initial), u.distinctUntilChanged()), initial);
|
|
227
250
|
u.connect(u.pipe(groupIndices, u.filter(function (indexes) { return indexes.length > 0; }), u.withLatestFrom(sizes), u.map(function (_a) {
|
|
228
251
|
var _b = tslib_1.__read(_a, 2), groupIndices = _b[0], sizes = _b[1];
|
|
229
252
|
var groupOffsetTree = groupIndices.reduce(function (tree, index, idx) {
|
|
@@ -249,7 +272,9 @@ exports.sizeSystem = u.system(function () {
|
|
|
249
272
|
})), sizeRanges);
|
|
250
273
|
u.connect(fixedItemSize, defaultItemSize);
|
|
251
274
|
var trackItemSizes = u.statefulStreamFromEmitter(u.pipe(fixedItemSize, u.map(function (size) { return size === undefined; })), true);
|
|
252
|
-
u.connect(u.pipe(defaultItemSize, u.filter(function (value) {
|
|
275
|
+
u.connect(u.pipe(defaultItemSize, u.filter(function (value) {
|
|
276
|
+
return value !== undefined && AATree_1.empty(u.getValue(sizes).sizeTree);
|
|
277
|
+
}), u.map(function (size) { return [{ startIndex: 0, endIndex: 0, size: size }]; })), sizeRanges);
|
|
253
278
|
var listRefresh = u.streamFromEmitter(u.pipe(sizeRanges, u.withLatestFrom(sizes), u.scan(function (_a, _b) {
|
|
254
279
|
var oldSizes = _a.sizes;
|
|
255
280
|
var _c = tslib_1.__read(_b, 2), newSizes = _c[1];
|
|
@@ -258,9 +283,22 @@ exports.sizeSystem = u.system(function () {
|
|
|
258
283
|
sizes: newSizes,
|
|
259
284
|
};
|
|
260
285
|
}, { changed: false, sizes: initial }), u.map(function (value) { return value.changed; })));
|
|
261
|
-
u.
|
|
286
|
+
u.subscribe(u.pipe(firstItemIndex, u.scan(function (prev, next) {
|
|
262
287
|
return { diff: prev.prev - next, prev: next };
|
|
263
|
-
}, { diff: 0, prev: 0 }), u.map(function (val) { return val.diff; }),
|
|
288
|
+
}, { diff: 0, prev: 0 }), u.map(function (val) { return val.diff; })), function (offset) {
|
|
289
|
+
if (offset > 0) {
|
|
290
|
+
u.publish(unshiftWith, offset);
|
|
291
|
+
}
|
|
292
|
+
else if (offset < 0) {
|
|
293
|
+
u.publish(shiftWith, offset);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
u.subscribe(u.pipe(firstItemIndex, u.withLatestFrom(log)), function (_a) {
|
|
297
|
+
var _b = tslib_1.__read(_a, 2), index = _b[0], log = _b[1];
|
|
298
|
+
if (index < 0) {
|
|
299
|
+
log("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value", { firstItemIndex: firstItemIndex }, loggerSystem_1.LogLevel.ERROR);
|
|
300
|
+
}
|
|
301
|
+
});
|
|
264
302
|
// Capture the current list top item before the sizes get refreshed
|
|
265
303
|
var beforeUnshiftWith = u.streamFromEmitter(unshiftWith);
|
|
266
304
|
u.connect(u.pipe(unshiftWith, u.withLatestFrom(sizes), u.map(function (_a) {
|
|
@@ -287,6 +325,22 @@ exports.sizeSystem = u.system(function () {
|
|
|
287
325
|
prevSize: sizes.lastSize,
|
|
288
326
|
}).ranges;
|
|
289
327
|
})), sizeRanges);
|
|
328
|
+
var shiftWithOffset = u.streamFromEmitter(u.pipe(shiftWith, u.withLatestFrom(sizes), u.map(function (_a) {
|
|
329
|
+
var _b = tslib_1.__read(_a, 2), shiftWith = _b[0], offsetTree = _b[1].offsetTree;
|
|
330
|
+
var newFirstItemIndex = -shiftWith;
|
|
331
|
+
return offsetOf(newFirstItemIndex, offsetTree);
|
|
332
|
+
})));
|
|
333
|
+
u.connect(u.pipe(shiftWith, u.withLatestFrom(sizes), u.map(function (_a) {
|
|
334
|
+
var _b = tslib_1.__read(_a, 2), shiftWith = _b[0], sizes = _b[1];
|
|
335
|
+
if (sizes.groupIndices.length > 0) {
|
|
336
|
+
throw new Error('Virtuoso: shifting items does not work with groups');
|
|
337
|
+
}
|
|
338
|
+
var newSizeTree = AATree_1.walk(sizes.sizeTree).reduce(function (acc, _a) {
|
|
339
|
+
var k = _a.k, v = _a.v;
|
|
340
|
+
return AATree_1.insert(acc, Math.max(0, k + shiftWith), v);
|
|
341
|
+
}, AATree_1.newTree());
|
|
342
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, sizes), { sizeTree: newSizeTree }), createOffsetTree(sizes.offsetTree, 0, newSizeTree));
|
|
343
|
+
})), sizes);
|
|
290
344
|
return {
|
|
291
345
|
// input
|
|
292
346
|
data: data,
|
|
@@ -296,12 +350,15 @@ exports.sizeSystem = u.system(function () {
|
|
|
296
350
|
defaultItemSize: defaultItemSize,
|
|
297
351
|
fixedItemSize: fixedItemSize,
|
|
298
352
|
unshiftWith: unshiftWith,
|
|
353
|
+
shiftWith: shiftWith,
|
|
354
|
+
shiftWithOffset: shiftWithOffset,
|
|
299
355
|
beforeUnshiftWith: beforeUnshiftWith,
|
|
300
356
|
firstItemIndex: firstItemIndex,
|
|
301
357
|
// output
|
|
302
358
|
sizes: sizes,
|
|
303
359
|
listRefresh: listRefresh,
|
|
360
|
+
statefulTotalCount: statefulTotalCount,
|
|
304
361
|
trackItemSizes: trackItemSizes,
|
|
305
362
|
itemSize: itemSize,
|
|
306
363
|
};
|
|
307
|
-
},
|
|
364
|
+
}, u.tup(loggerSystem_1.loggerSystem), { singleton: true });
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import * as u from '@virtuoso.dev/urx';
|
|
2
|
+
export declare const UP: "up";
|
|
3
|
+
export declare const DOWN: "down";
|
|
4
|
+
export declare const NONE: "none";
|
|
5
|
+
export declare type ScrollDirection = typeof UP | typeof DOWN | typeof NONE;
|
|
2
6
|
export interface ListBottomInfo {
|
|
3
7
|
bottom: number;
|
|
4
8
|
offsetBottom: number;
|
|
@@ -7,9 +11,10 @@ export interface AtBottomParams {
|
|
|
7
11
|
offsetBottom: number;
|
|
8
12
|
scrollTop: number;
|
|
9
13
|
viewportHeight: number;
|
|
10
|
-
|
|
14
|
+
scrollHeight: number;
|
|
11
15
|
}
|
|
12
16
|
export declare type NotAtBottomReason = 'SIZE_INCREASED' | 'NOT_SHOWING_LAST_ITEM' | 'VIEWPORT_HEIGHT_DECREASING' | 'SCROLLING_UPWARDS' | 'NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM';
|
|
17
|
+
export declare type AtBottomReason = 'SIZE_DECREASED' | 'SCROLLED_DOWN';
|
|
13
18
|
export declare type AtBottomState = {
|
|
14
19
|
atBottom: false;
|
|
15
20
|
notAtBottomBecause: NotAtBottomReason;
|
|
@@ -17,28 +22,32 @@ export declare type AtBottomState = {
|
|
|
17
22
|
} | {
|
|
18
23
|
atBottom: true;
|
|
19
24
|
state: AtBottomParams;
|
|
25
|
+
atBottomBecause: AtBottomReason;
|
|
26
|
+
scrollTopDelta: number;
|
|
20
27
|
};
|
|
21
28
|
export declare const stateFlagsSystem: u.SystemSpec<[u.SystemSpec<never[], () => {
|
|
29
|
+
scrollContainerState: u.Stream<[number, number]>;
|
|
22
30
|
scrollTop: u.Stream<number>;
|
|
23
31
|
viewportHeight: u.Stream<number>;
|
|
24
32
|
headerHeight: u.StatefulStream<number>;
|
|
25
33
|
footerHeight: u.StatefulStream<number>;
|
|
34
|
+
scrollHeight: u.Stream<number>;
|
|
26
35
|
smoothScrollTargetReached: u.Stream<true>;
|
|
27
36
|
scrollTo: u.Stream<ScrollToOptions>;
|
|
28
37
|
scrollBy: u.Stream<ScrollToOptions>;
|
|
29
|
-
scrollDirection: u.StatefulStream<import("./domIOSystem").ScrollDirection>;
|
|
30
38
|
statefulScrollTop: u.StatefulStream<number>;
|
|
31
39
|
deviation: u.StatefulStream<number>;
|
|
32
40
|
scrollingInProgress: u.StatefulStream<boolean>;
|
|
33
|
-
}>], ([{ scrollTop, viewportHeight }]: [{
|
|
41
|
+
}>], ([{ scrollContainerState, scrollTop, viewportHeight, headerHeight, footerHeight, scrollBy, },]: [{
|
|
42
|
+
scrollContainerState: u.Stream<[number, number]>;
|
|
34
43
|
scrollTop: u.Stream<number>;
|
|
35
44
|
viewportHeight: u.Stream<number>;
|
|
36
45
|
headerHeight: u.StatefulStream<number>;
|
|
37
46
|
footerHeight: u.StatefulStream<number>;
|
|
47
|
+
scrollHeight: u.Stream<number>;
|
|
38
48
|
smoothScrollTargetReached: u.Stream<true>;
|
|
39
49
|
scrollTo: u.Stream<ScrollToOptions>;
|
|
40
50
|
scrollBy: u.Stream<ScrollToOptions>;
|
|
41
|
-
scrollDirection: u.StatefulStream<import("./domIOSystem").ScrollDirection>;
|
|
42
51
|
statefulScrollTop: u.StatefulStream<number>;
|
|
43
52
|
deviation: u.StatefulStream<number>;
|
|
44
53
|
scrollingInProgress: u.StatefulStream<boolean>;
|
|
@@ -49,5 +58,8 @@ export declare const stateFlagsSystem: u.SystemSpec<[u.SystemSpec<never[], () =>
|
|
|
49
58
|
atBottomState: u.Stream<AtBottomState>;
|
|
50
59
|
atTopStateChange: u.Stream<boolean>;
|
|
51
60
|
atBottomStateChange: u.Stream<boolean>;
|
|
52
|
-
|
|
61
|
+
scrollDirection: u.StatefulStream<ScrollDirection>;
|
|
62
|
+
atBottomThreshold: u.StatefulStream<number>;
|
|
63
|
+
scrollVelocity: u.StatefulStream<number>;
|
|
64
|
+
lastJumpDueToItemResize: u.StatefulStream<number>;
|
|
53
65
|
}>;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
5
|
var u = tslib_1.__importStar(require("@virtuoso.dev/urx"));
|
|
5
6
|
var domIOSystem_1 = require("./domIOSystem");
|
|
7
|
+
exports.UP = 'up';
|
|
8
|
+
exports.DOWN = 'down';
|
|
9
|
+
exports.NONE = 'none';
|
|
6
10
|
var INITIAL_BOTTOM_STATE = {
|
|
7
11
|
atBottom: false,
|
|
8
12
|
notAtBottomBecause: 'NOT_SHOWING_LAST_ITEM',
|
|
@@ -10,42 +14,54 @@ var INITIAL_BOTTOM_STATE = {
|
|
|
10
14
|
offsetBottom: 0,
|
|
11
15
|
scrollTop: 0,
|
|
12
16
|
viewportHeight: 0,
|
|
13
|
-
|
|
17
|
+
scrollHeight: 0,
|
|
14
18
|
},
|
|
15
19
|
};
|
|
16
20
|
exports.stateFlagsSystem = u.system(function (_a) {
|
|
17
|
-
var _b = tslib_1.__read(_a, 1), _c = _b[0], scrollTop = _c.scrollTop, viewportHeight = _c.viewportHeight;
|
|
21
|
+
var _b = tslib_1.__read(_a, 1), _c = _b[0], scrollContainerState = _c.scrollContainerState, scrollTop = _c.scrollTop, viewportHeight = _c.viewportHeight, headerHeight = _c.headerHeight, footerHeight = _c.footerHeight, scrollBy = _c.scrollBy;
|
|
18
22
|
var isAtBottom = u.statefulStream(false);
|
|
19
23
|
var isAtTop = u.statefulStream(true);
|
|
20
24
|
var atBottomStateChange = u.stream();
|
|
21
25
|
var atTopStateChange = u.stream();
|
|
22
|
-
var
|
|
26
|
+
var atBottomThreshold = u.statefulStream(4);
|
|
23
27
|
// skip 1 to avoid an initial on/off flick
|
|
24
28
|
var isScrolling = u.streamFromEmitter(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()));
|
|
29
|
+
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);
|
|
30
|
+
// u.subscribe(isScrollingBy, (isScrollingBy) => console.log({ isScrollingBy }))
|
|
25
31
|
u.connect(u.pipe(u.duc(scrollTop), u.map(function (top) { return top === 0; }), u.distinctUntilChanged()), isAtTop);
|
|
26
32
|
u.connect(isAtTop, atTopStateChange);
|
|
27
|
-
var atBottomState = u.streamFromEmitter(u.pipe(u.combineLatest(
|
|
28
|
-
var _b = tslib_1.__read(_a,
|
|
29
|
-
var isAtBottom =
|
|
33
|
+
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) {
|
|
34
|
+
var _b = tslib_1.__read(_a, 5), _c = tslib_1.__read(_b[0], 2), scrollTop = _c[0], scrollHeight = _c[1], viewportHeight = _b[1], _headerHeight = _b[2], _footerHeight = _b[3], atBottomThreshold = _b[4];
|
|
35
|
+
var isAtBottom = scrollTop + viewportHeight - scrollHeight > -atBottomThreshold;
|
|
30
36
|
var state = {
|
|
31
37
|
viewportHeight: viewportHeight,
|
|
32
38
|
scrollTop: scrollTop,
|
|
33
|
-
|
|
34
|
-
totalHeight: bottom + offsetBottom,
|
|
39
|
+
scrollHeight: scrollHeight,
|
|
35
40
|
};
|
|
36
41
|
if (isAtBottom) {
|
|
42
|
+
var atBottomBecause = void 0;
|
|
43
|
+
var scrollTopDelta = void 0;
|
|
44
|
+
if (scrollTop > current.state.scrollTop) {
|
|
45
|
+
atBottomBecause = 'SCROLLED_DOWN';
|
|
46
|
+
scrollTopDelta = current.state.scrollTop - scrollTop;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
atBottomBecause = 'SIZE_DECREASED';
|
|
50
|
+
scrollTopDelta =
|
|
51
|
+
current.state.scrollTop - scrollTop ||
|
|
52
|
+
current.scrollTopDelta;
|
|
53
|
+
}
|
|
37
54
|
return {
|
|
38
55
|
atBottom: true,
|
|
39
56
|
state: state,
|
|
57
|
+
atBottomBecause: atBottomBecause,
|
|
58
|
+
scrollTopDelta: scrollTopDelta,
|
|
40
59
|
};
|
|
41
60
|
}
|
|
42
61
|
var notAtBottomBecause;
|
|
43
|
-
if (state.
|
|
62
|
+
if (state.scrollHeight > current.state.scrollHeight) {
|
|
44
63
|
notAtBottomBecause = 'SIZE_INCREASED';
|
|
45
64
|
}
|
|
46
|
-
else if (offsetBottom !== 0) {
|
|
47
|
-
notAtBottomBecause = 'NOT_SHOWING_LAST_ITEM';
|
|
48
|
-
}
|
|
49
65
|
else if (viewportHeight < current.state.viewportHeight) {
|
|
50
66
|
notAtBottomBecause = 'VIEWPORT_HEIGHT_DECREASING';
|
|
51
67
|
}
|
|
@@ -61,14 +77,64 @@ exports.stateFlagsSystem = u.system(function (_a) {
|
|
|
61
77
|
state: state,
|
|
62
78
|
};
|
|
63
79
|
}, INITIAL_BOTTOM_STATE), u.distinctUntilChanged(function (prev, next) {
|
|
64
|
-
// prev && console.log(prev.atBottom, next.atBottom)
|
|
65
80
|
return prev && prev.atBottom === next.atBottom;
|
|
66
81
|
})));
|
|
82
|
+
var lastJumpDueToItemResize = u.statefulStreamFromEmitter(u.pipe(scrollContainerState, u.scan(function (current, _a) {
|
|
83
|
+
var _b = tslib_1.__read(_a, 2), scrollTop = _b[0], scrollHeight = _b[1];
|
|
84
|
+
if (current.scrollHeight !== scrollHeight) {
|
|
85
|
+
if (current.scrollTop !== scrollTop) {
|
|
86
|
+
return {
|
|
87
|
+
scrollHeight: scrollHeight,
|
|
88
|
+
scrollTop: scrollTop,
|
|
89
|
+
jump: current.scrollTop - scrollTop,
|
|
90
|
+
changed: true,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
scrollHeight: scrollHeight,
|
|
95
|
+
scrollTop: scrollTop,
|
|
96
|
+
jump: 0,
|
|
97
|
+
changed: true,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
scrollTop: scrollTop,
|
|
102
|
+
scrollHeight: scrollHeight,
|
|
103
|
+
jump: 0,
|
|
104
|
+
changed: false,
|
|
105
|
+
};
|
|
106
|
+
}, { scrollHeight: 0, jump: 0, scrollTop: 0, changed: false }), u.filter(function (value) { return value.changed; }), u.map(function (value) { return value.jump; })), 0);
|
|
67
107
|
u.connect(u.pipe(atBottomState, u.map(function (state) { return state.atBottom; })), isAtBottom);
|
|
68
|
-
u.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
108
|
+
u.connect(u.pipe(isAtBottom, u.throttleTime(50)), atBottomStateChange);
|
|
109
|
+
var scrollDirection = u.statefulStream(exports.DOWN);
|
|
110
|
+
u.connect(u.pipe(scrollContainerState, u.map(function (_a) {
|
|
111
|
+
var _b = tslib_1.__read(_a, 1), scrollTop = _b[0];
|
|
112
|
+
return scrollTop;
|
|
113
|
+
}), u.distinctUntilChanged(), u.scan(function (acc, scrollTop) {
|
|
114
|
+
// if things change while compensating for items, ignore,
|
|
115
|
+
// but store the new scrollTop
|
|
116
|
+
if (u.getValue(isScrollingBy)) {
|
|
117
|
+
return { direction: acc.direction, prevScrollTop: scrollTop };
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
direction: scrollTop < acc.prevScrollTop ? exports.UP : exports.DOWN,
|
|
121
|
+
prevScrollTop: scrollTop,
|
|
122
|
+
};
|
|
123
|
+
}, { direction: exports.DOWN, prevScrollTop: 0 }), u.map(function (value) { return value.direction; })), scrollDirection);
|
|
124
|
+
u.connect(u.pipe(scrollContainerState, u.throttleTime(50), u.mapTo(exports.NONE)), scrollDirection);
|
|
125
|
+
var scrollVelocity = u.statefulStream(0);
|
|
126
|
+
u.connect(u.pipe(isScrolling, u.filter(function (value) { return !value; }), u.mapTo(0)), scrollVelocity);
|
|
127
|
+
u.connect(u.pipe(scrollTop, u.throttleTime(100), u.withLatestFrom(isScrolling), u.filter(function (_a) {
|
|
128
|
+
var _b = tslib_1.__read(_a, 2), _ = _b[0], isScrolling = _b[1];
|
|
129
|
+
return !!isScrolling;
|
|
130
|
+
}), u.scan(function (_a, _b) {
|
|
131
|
+
var _c = tslib_1.__read(_a, 2), _ = _c[0], prev = _c[1];
|
|
132
|
+
var _d = tslib_1.__read(_b, 1), next = _d[0];
|
|
133
|
+
return [prev, next];
|
|
134
|
+
}, [0, 0]), u.map(function (_a) {
|
|
135
|
+
var _b = tslib_1.__read(_a, 2), prev = _b[0], next = _b[1];
|
|
136
|
+
return next - prev;
|
|
137
|
+
})), scrollVelocity);
|
|
72
138
|
return {
|
|
73
139
|
isScrolling: isScrolling,
|
|
74
140
|
isAtTop: isAtTop,
|
|
@@ -76,6 +142,9 @@ exports.stateFlagsSystem = u.system(function (_a) {
|
|
|
76
142
|
atBottomState: atBottomState,
|
|
77
143
|
atTopStateChange: atTopStateChange,
|
|
78
144
|
atBottomStateChange: atBottomStateChange,
|
|
79
|
-
|
|
145
|
+
scrollDirection: scrollDirection,
|
|
146
|
+
atBottomThreshold: atBottomThreshold,
|
|
147
|
+
scrollVelocity: scrollVelocity,
|
|
148
|
+
lastJumpDueToItemResize: lastJumpDueToItemResize,
|
|
80
149
|
};
|
|
81
150
|
}, u.tup(domIOSystem_1.domIOSystem));
|