@ringcentral/juno 2.4.2 → 2.6.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/Buttons/IconButton/IconButton.d.ts +10 -2
- package/components/Buttons/IconButton/IconButton.js +10 -8
- package/components/Buttons/IconButton/styles/StyledIconButton.js +15 -7
- package/components/Buttons/IconButton/utils/IconButtonUtils.d.ts +1 -1
- package/components/Buttons/IconButton/utils/IconButtonUtils.js +9 -1
- package/components/Dialer/DialPad/DialPad.d.ts +25 -7
- package/components/Dialer/DialPad/DialPad.js +6 -6
- package/components/Dialer/DialPad/utils/useDialKeyboard.d.ts +8 -9
- package/components/Dialer/DialTextField/DialTextField.d.ts +3 -1
- package/components/Dialer/DialTextField/DialTextField.js +7 -6
- package/components/Downshift/SuggestionList/SuggestionList.d.ts +74 -2
- package/components/Downshift/styles/DownshiftStyle.d.ts +1 -1
- package/components/Forms/Picker/DatePicker/styles/StyledDatePickerHeader.d.ts +1 -1
- package/components/Forms/Picker/DatePicker/styles/StyledYear.d.ts +1 -1
- package/components/Forms/Picker/TimePicker/styles/StyledSelectionItem.d.ts +1 -1
- package/components/Forms/Picker/TimePicker/styles/StyledTimeIconButton.d.ts +1 -1
- package/components/Forms/Picker/styles/PickerBaseIconButton.d.ts +1 -1
- package/components/Forms/TextField/styles/ClearIconButton.d.ts +2 -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/Buttons/IconButton/IconButton.js +12 -10
- package/es6/components/Buttons/IconButton/styles/StyledIconButton.js +16 -8
- package/es6/components/Buttons/IconButton/utils/IconButtonUtils.js +9 -1
- package/es6/components/Dialer/DialPad/DialPad.js +6 -6
- package/es6/components/Dialer/DialTextField/DialTextField.js +7 -6
- 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/es6/foundation/hooks/useEventListener/useEventListener.js +27 -8
- package/es6/foundation/hooks/useGlobalListener/createGlobalListener.js +81 -0
- package/es6/foundation/hooks/useGlobalListener/index.js +1 -0
- package/es6/foundation/hooks/useGlobalListener/useGlobalListener.js +67 -97
- package/es6/foundation/hooks/useLongPress/useLongPress.js +52 -33
- package/es6/foundation/hooks/useTouchMouseEvent/useTouchMouseEvent.js +27 -28
- package/foundation/hooks/useEventListener/useEventListener.d.ts +12 -16
- package/foundation/hooks/useEventListener/useEventListener.js +26 -7
- package/foundation/hooks/useGlobalListener/createGlobalListener.d.ts +55 -0
- package/foundation/hooks/useGlobalListener/createGlobalListener.js +83 -0
- package/foundation/hooks/useGlobalListener/index.d.ts +1 -0
- package/foundation/hooks/useGlobalListener/index.js +1 -0
- package/foundation/hooks/useGlobalListener/useGlobalListener.d.ts +11 -105
- package/foundation/hooks/useGlobalListener/useGlobalListener.js +67 -97
- package/foundation/hooks/useLongPress/useLongPress.d.ts +10 -8
- package/foundation/hooks/useLongPress/useLongPress.js +50 -31
- package/foundation/hooks/useTouchMouseEvent/useTouchMouseEvent.d.ts +27 -14
- package/foundation/hooks/useTouchMouseEvent/useTouchMouseEvent.js +27 -28
- package/foundation/typings/deepPartial.d.ts +1 -1
- package/package.json +2 -2
|
@@ -8,7 +8,9 @@ import { initialItemCountSystem } from './initialItemCountSystem';
|
|
|
8
8
|
import { initialScrollTopSystem } from './initialScrollTopSystem';
|
|
9
9
|
import { initialTopMostItemIndexSystem } from './initialTopMostItemIndexSystem';
|
|
10
10
|
import { listStateSystem } from './listStateSystem';
|
|
11
|
+
import { loggerSystem } from './loggerSystem';
|
|
11
12
|
import { propsReadySystem } from './propsReadySystem';
|
|
13
|
+
import { scrollIntoViewSystem } from './scrollIntoViewSystem';
|
|
12
14
|
import { scrollSeekSystem } from './scrollSeekSystem';
|
|
13
15
|
import { scrollToIndexSystem } from './scrollToIndexSystem';
|
|
14
16
|
import { sizeRangeSystem } from './sizeRangeSystem';
|
|
@@ -20,14 +22,14 @@ import { windowScrollerSystem } from './windowScrollerSystem';
|
|
|
20
22
|
// workaround the growing list of systems below
|
|
21
23
|
// fix this with 4.1 recursive conditional types
|
|
22
24
|
var featureGroup1System = u.system(function (_a) {
|
|
23
|
-
var _b = __read(_a,
|
|
24
|
-
return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, sizeRange), initialItemCount), propsReady), scrollSeek), totalListHeight), initialScrollTopSystem), alignToBottom), windowScroller);
|
|
25
|
-
}, u.tup(sizeRangeSystem, initialItemCountSystem, propsReadySystem, scrollSeekSystem, totalListHeightSystem, initialScrollTopSystem, alignToBottomSystem, windowScrollerSystem));
|
|
25
|
+
var _b = __read(_a, 9), sizeRange = _b[0], initialItemCount = _b[1], propsReady = _b[2], scrollSeek = _b[3], totalListHeight = _b[4], initialScrollTopSystem = _b[5], alignToBottom = _b[6], windowScroller = _b[7], scrollIntoView = _b[8];
|
|
26
|
+
return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, sizeRange), initialItemCount), propsReady), scrollSeek), totalListHeight), initialScrollTopSystem), alignToBottom), windowScroller), scrollIntoView);
|
|
27
|
+
}, u.tup(sizeRangeSystem, initialItemCountSystem, propsReadySystem, scrollSeekSystem, totalListHeightSystem, initialScrollTopSystem, alignToBottomSystem, windowScrollerSystem, scrollIntoViewSystem));
|
|
26
28
|
export var listSystem = u.system(function (_a) {
|
|
27
|
-
var _b = _a, _c = __read(_b,
|
|
29
|
+
var _b = _a, _c = __read(_b, 11), _d = _c[0], totalCount = _d.totalCount, sizeRanges = _d.sizeRanges, fixedItemSize = _d.fixedItemSize, defaultItemSize = _d.defaultItemSize, trackItemSizes = _d.trackItemSizes, itemSize = _d.itemSize, data = _d.data, firstItemIndex = _d.firstItemIndex, groupIndices = _d.groupIndices, statefulTotalCount = _d.statefulTotalCount, _e = _c[1], initialTopMostItemIndex = _e.initialTopMostItemIndex, scrolledToInitialItem = _e.scrolledToInitialItem, domIO = _c[2], followOutput = _c[3], _f = _c[4], scrollToIndex = _c[5].scrollToIndex, topItemCount = _c[7].topItemCount, groupCounts = _c[8].groupCounts, featureGroup1 = _c[9], log = _c[10], listState = _f.listState, topItemsIndexes = _f.topItemsIndexes, flags = __rest(_f, ["listState", "topItemsIndexes"]);
|
|
28
30
|
u.connect(flags.rangeChanged, featureGroup1.scrollSeekRangeChanged);
|
|
29
31
|
u.connect(u.pipe(featureGroup1.windowViewportRect, u.map(u.prop('visibleHeight'))), domIO.viewportHeight);
|
|
30
|
-
return __assign(__assign(__assign(__assign(__assign({
|
|
32
|
+
return __assign(__assign(__assign(__assign(__assign(__assign({
|
|
31
33
|
// input
|
|
32
34
|
totalCount: totalCount,
|
|
33
35
|
data: data,
|
|
@@ -39,9 +41,10 @@ export var listSystem = u.system(function (_a) {
|
|
|
39
41
|
topItemCount: topItemCount,
|
|
40
42
|
groupCounts: groupCounts, fixedItemHeight: fixedItemSize, defaultItemHeight: defaultItemSize }, followOutput), {
|
|
41
43
|
// output
|
|
44
|
+
statefulTotalCount: statefulTotalCount,
|
|
42
45
|
listState: listState,
|
|
43
46
|
scrollToIndex: scrollToIndex,
|
|
44
47
|
trackItemSizes: trackItemSizes,
|
|
45
48
|
itemSize: itemSize,
|
|
46
|
-
groupIndices: groupIndices }), flags), featureGroup1), domIO);
|
|
47
|
-
}, u.tup(sizeSystem, initialTopMostItemIndexSystem, domIOSystem, followOutputSystem, listStateSystem, scrollToIndexSystem, upwardScrollFixSystem, topItemCountSystem, groupedListSystem, featureGroup1System));
|
|
49
|
+
groupIndices: groupIndices }), flags), featureGroup1), domIO), log);
|
|
50
|
+
}, u.tup(sizeSystem, initialTopMostItemIndexSystem, domIOSystem, followOutputSystem, listStateSystem, scrollToIndexSystem, upwardScrollFixSystem, topItemCountSystem, groupedListSystem, featureGroup1System, loggerSystem));
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import * as u from '@virtuoso.dev/urx';
|
|
3
|
+
export var LogLevel;
|
|
4
|
+
(function (LogLevel) {
|
|
5
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
6
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
7
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
8
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
9
|
+
})(LogLevel || (LogLevel = {}));
|
|
10
|
+
var CONSOLE_METHOD_MAP = (_a = {},
|
|
11
|
+
_a[LogLevel.DEBUG] = 'debug',
|
|
12
|
+
_a[LogLevel.INFO] = 'log',
|
|
13
|
+
_a[LogLevel.WARN] = 'warn',
|
|
14
|
+
_a[LogLevel.ERROR] = 'error',
|
|
15
|
+
_a);
|
|
16
|
+
var getGlobalThis = function () {
|
|
17
|
+
return typeof globalThis === 'undefined' ? window : globalThis;
|
|
18
|
+
};
|
|
19
|
+
export var loggerSystem = u.system(function () {
|
|
20
|
+
var logLevel = u.statefulStream(LogLevel.ERROR);
|
|
21
|
+
var log = u.statefulStream(function (label, message, level) {
|
|
22
|
+
if (level === void 0) { level = LogLevel.INFO; }
|
|
23
|
+
var _a;
|
|
24
|
+
var currentLevel = (_a = getGlobalThis()['VIRTUOSO_LOG_LEVEL']) !== null && _a !== void 0 ? _a : u.getValue(logLevel);
|
|
25
|
+
if (level >= currentLevel) {
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console[CONSOLE_METHOD_MAP[level]]('%creact-virtuoso: %c%s %o', 'color: #0253b3; font-weight: bold', 'color: initial', label, message);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
log: log,
|
|
32
|
+
logLevel: logLevel,
|
|
33
|
+
};
|
|
34
|
+
}, [], { singleton: true });
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { __read } from "tslib";
|
|
1
2
|
import * as u from '@virtuoso.dev/urx';
|
|
2
|
-
|
|
3
|
+
import { getValue, tup } from '@virtuoso.dev/urx';
|
|
4
|
+
import { loggerSystem, LogLevel } from './loggerSystem';
|
|
5
|
+
export var propsReadySystem = u.system(function (_a) {
|
|
6
|
+
var _b = __read(_a, 1), log = _b[0].log;
|
|
3
7
|
var propsReady = u.statefulStream(false);
|
|
4
8
|
var didMount = u.streamFromEmitter(u.pipe(propsReady, u.filter(function (ready) { return ready; }), u.distinctUntilChanged()));
|
|
9
|
+
u.subscribe(propsReady, function (value) {
|
|
10
|
+
value && getValue(log)('props updated', {}, LogLevel.DEBUG);
|
|
11
|
+
});
|
|
5
12
|
return { propsReady: propsReady, didMount: didMount };
|
|
6
|
-
},
|
|
13
|
+
}, tup(loggerSystem), { singleton: true });
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { __read } from "tslib";
|
|
2
|
+
import * as u from '@virtuoso.dev/urx';
|
|
3
|
+
import { findMaxKeyValue } from './AATree';
|
|
4
|
+
import { domIOSystem } from './domIOSystem';
|
|
5
|
+
import { listStateSystem } from './listStateSystem';
|
|
6
|
+
import { loggerSystem } from './loggerSystem';
|
|
7
|
+
import { scrollToIndexSystem } from './scrollToIndexSystem';
|
|
8
|
+
import { offsetOf, originalIndexFromItemIndex, sizeSystem } from './sizeSystem';
|
|
9
|
+
export var scrollIntoViewSystem = u.system(function (_a) {
|
|
10
|
+
var _b = __read(_a, 3), _c = _b[0], sizes = _c.sizes, totalCount = _c.totalCount, _d = _b[1], scrollTop = _d.scrollTop, viewportHeight = _d.viewportHeight, headerHeight = _d.headerHeight, scrollingInProgress = _d.scrollingInProgress, scrollToIndex = _b[2].scrollToIndex;
|
|
11
|
+
var scrollIntoView = u.stream();
|
|
12
|
+
u.connect(u.pipe(scrollIntoView, u.withLatestFrom(sizes, viewportHeight, totalCount, headerHeight, scrollTop), u.map(function (_a) {
|
|
13
|
+
var _b = __read(_a, 6), _c = _b[0], index = _c.index, _d = _c.behavior, behavior = _d === void 0 ? 'auto' : _d, done = _c.done, sizes = _b[1], viewportHeight = _b[2], totalCount = _b[3], headerHeight = _b[4], scrollTop = _b[5];
|
|
14
|
+
var lastIndex = totalCount - 1;
|
|
15
|
+
var location = null;
|
|
16
|
+
index = originalIndexFromItemIndex(index, sizes);
|
|
17
|
+
index = Math.max(0, index, Math.min(lastIndex, index));
|
|
18
|
+
var itemTop = offsetOf(index, sizes.offsetTree) + headerHeight;
|
|
19
|
+
if (itemTop < scrollTop) {
|
|
20
|
+
location = { index: index, behavior: behavior, align: 'start' };
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
var itemBottom = itemTop + findMaxKeyValue(sizes.sizeTree, index)[1];
|
|
24
|
+
if (itemBottom > scrollTop + viewportHeight) {
|
|
25
|
+
location = { index: index, behavior: behavior, align: 'end' };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (location) {
|
|
29
|
+
done &&
|
|
30
|
+
u.handleNext(u.pipe(scrollingInProgress, u.skip(1), u.filter(function (value) { return value === false; })), done);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
done && done();
|
|
34
|
+
}
|
|
35
|
+
return location;
|
|
36
|
+
}), u.filter(function (value) { return value !== null; })), scrollToIndex);
|
|
37
|
+
return {
|
|
38
|
+
scrollIntoView: scrollIntoView,
|
|
39
|
+
};
|
|
40
|
+
}, u.tup(sizeSystem, domIOSystem, scrollToIndexSystem, listStateSystem, loggerSystem), { singleton: true });
|
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
import { __read } from "tslib";
|
|
2
|
-
import
|
|
3
|
-
import { domIOSystem } from './domIOSystem';
|
|
2
|
+
import * as u from '@virtuoso.dev/urx';
|
|
4
3
|
import { stateFlagsSystem } from './stateFlagsSystem';
|
|
5
|
-
export var scrollSeekSystem = system(function (_a) {
|
|
6
|
-
var _b = __read(_a,
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
connect(pipe(isScrolling, filter(function (value) { return !value; }), mapTo(0)), scrollVelocity);
|
|
12
|
-
connect(pipe(scrollTop, throttleTime(100), withLatestFrom(isScrolling), filter(function (_a) {
|
|
13
|
-
var _b = __read(_a, 2), isScrolling = _b[1];
|
|
14
|
-
return !!isScrolling;
|
|
15
|
-
}), scan(function (_a, _b) {
|
|
16
|
-
var _c = __read(_a, 2), prev = _c[1];
|
|
17
|
-
var _d = __read(_b, 1), next = _d[0];
|
|
18
|
-
return [prev, next];
|
|
19
|
-
}, [0, 0]), map(function (_a) {
|
|
20
|
-
var _b = __read(_a, 2), prev = _b[0], next = _b[1];
|
|
21
|
-
return next - prev;
|
|
22
|
-
})), scrollVelocity);
|
|
23
|
-
connect(pipe(scrollVelocity, withLatestFrom(scrollSeekConfiguration, isSeeking, rangeChanged), filter(function (_a) {
|
|
4
|
+
export var scrollSeekSystem = u.system(function (_a) {
|
|
5
|
+
var _b = __read(_a, 1), scrollVelocity = _b[0].scrollVelocity;
|
|
6
|
+
var isSeeking = u.statefulStream(false);
|
|
7
|
+
var rangeChanged = u.stream();
|
|
8
|
+
var scrollSeekConfiguration = u.statefulStream(false);
|
|
9
|
+
u.connect(u.pipe(scrollVelocity, u.withLatestFrom(scrollSeekConfiguration, isSeeking, rangeChanged), u.filter(function (_a) {
|
|
24
10
|
var _b = __read(_a, 2), config = _b[1];
|
|
25
11
|
return !!config;
|
|
26
|
-
}), map(function (_a) {
|
|
12
|
+
}), u.map(function (_a) {
|
|
27
13
|
var _b = __read(_a, 4), speed = _b[0], config = _b[1], isSeeking = _b[2], range = _b[3];
|
|
28
14
|
var _c = config, exit = _c.exit, enter = _c.enter;
|
|
29
15
|
if (isSeeking) {
|
|
@@ -35,8 +21,8 @@ export var scrollSeekSystem = system(function (_a) {
|
|
|
35
21
|
return true;
|
|
36
22
|
}
|
|
37
23
|
return isSeeking;
|
|
38
|
-
}), distinctUntilChanged()), isSeeking);
|
|
39
|
-
subscribe(pipe(combineLatest(isSeeking, scrollVelocity, rangeChanged), withLatestFrom(scrollSeekConfiguration)), function (_a) {
|
|
24
|
+
}), u.distinctUntilChanged()), isSeeking);
|
|
25
|
+
u.subscribe(u.pipe(u.combineLatest(isSeeking, scrollVelocity, rangeChanged), u.withLatestFrom(scrollSeekConfiguration)), function (_a) {
|
|
40
26
|
var _b = __read(_a, 2), _c = __read(_b[0], 3), isSeeking = _c[0], velocity = _c[1], range = _c[2], config = _b[1];
|
|
41
27
|
return isSeeking && config && config.change && config.change(velocity, range);
|
|
42
28
|
});
|
|
@@ -46,4 +32,4 @@ export var scrollSeekSystem = system(function (_a) {
|
|
|
46
32
|
scrollVelocity: scrollVelocity,
|
|
47
33
|
scrollSeekRangeChanged: rangeChanged,
|
|
48
34
|
};
|
|
49
|
-
}, tup(
|
|
35
|
+
}, u.tup(stateFlagsSystem), { singleton: true });
|
|
@@ -3,6 +3,7 @@ import { __read } from "tslib";
|
|
|
3
3
|
import * as u from '@virtuoso.dev/urx';
|
|
4
4
|
import { findMaxKeyValue } from './AATree';
|
|
5
5
|
import { domIOSystem } from './domIOSystem';
|
|
6
|
+
import { loggerSystem, LogLevel } from './loggerSystem';
|
|
6
7
|
import { offsetOf, originalIndexFromItemIndex, sizeSystem } from './sizeSystem';
|
|
7
8
|
var SUPPORTS_SCROLL_TO_OPTIONS = typeof document !== 'undefined' &&
|
|
8
9
|
'scrollBehavior' in document.documentElement.style;
|
|
@@ -20,13 +21,13 @@ export function normalizeIndexLocation(location) {
|
|
|
20
21
|
return result;
|
|
21
22
|
}
|
|
22
23
|
export var scrollToIndexSystem = u.system(function (_a) {
|
|
23
|
-
var _b = __read(_a,
|
|
24
|
+
var _b = __read(_a, 3), _c = _b[0], sizes = _c.sizes, totalCount = _c.totalCount, listRefresh = _c.listRefresh, _d = _b[1], scrollingInProgress = _d.scrollingInProgress, viewportHeight = _d.viewportHeight, scrollTo = _d.scrollTo, smoothScrollTargetReached = _d.smoothScrollTargetReached, headerHeight = _d.headerHeight, footerHeight = _d.footerHeight, log = _b[2].log;
|
|
24
25
|
var scrollToIndex = u.stream();
|
|
25
26
|
var topListHeight = u.statefulStream(0);
|
|
26
27
|
var unsubscribeNextListRefresh = null;
|
|
27
28
|
var cleartTimeoutRef = null;
|
|
28
29
|
var unsubscribeListRefresh = null;
|
|
29
|
-
|
|
30
|
+
function cleanup() {
|
|
30
31
|
if (unsubscribeNextListRefresh) {
|
|
31
32
|
unsubscribeNextListRefresh();
|
|
32
33
|
unsubscribeNextListRefresh = null;
|
|
@@ -40,28 +41,33 @@ export var scrollToIndexSystem = u.system(function (_a) {
|
|
|
40
41
|
cleartTimeoutRef = null;
|
|
41
42
|
}
|
|
42
43
|
u.publish(scrollingInProgress, false);
|
|
43
|
-
}
|
|
44
|
-
u.connect(u.pipe(scrollToIndex, u.withLatestFrom(sizes, viewportHeight, totalCount, topListHeight, headerHeight, footerHeight), u.map(function (_a) {
|
|
45
|
-
var _b = __read(_a,
|
|
44
|
+
}
|
|
45
|
+
u.connect(u.pipe(scrollToIndex, u.withLatestFrom(sizes, viewportHeight, totalCount, topListHeight, headerHeight, footerHeight, log), u.map(function (_a) {
|
|
46
|
+
var _b = __read(_a, 8), location = _b[0], sizes = _b[1], viewportHeight = _b[2], totalCount = _b[3], topListHeight = _b[4], headerHeight = _b[5], footerHeight = _b[6], log = _b[7];
|
|
46
47
|
var normalLocation = normalizeIndexLocation(location);
|
|
47
48
|
var align = normalLocation.align, behavior = normalLocation.behavior, offset = normalLocation.offset;
|
|
48
49
|
var lastIndex = totalCount - 1;
|
|
49
50
|
var index = normalLocation.index;
|
|
51
|
+
if (index === 'LAST') {
|
|
52
|
+
index = lastIndex;
|
|
53
|
+
}
|
|
50
54
|
index = originalIndexFromItemIndex(index, sizes);
|
|
51
55
|
index = Math.max(0, index, Math.min(lastIndex, index));
|
|
52
56
|
var top = offsetOf(index, sizes.offsetTree) + headerHeight;
|
|
53
57
|
if (align === 'end') {
|
|
54
|
-
top =
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
top =
|
|
59
|
+
top -
|
|
60
|
+
viewportHeight +
|
|
61
|
+
findMaxKeyValue(sizes.sizeTree, index)[1];
|
|
57
62
|
if (index === lastIndex) {
|
|
58
63
|
top += footerHeight;
|
|
59
64
|
}
|
|
60
65
|
}
|
|
61
66
|
else if (align === 'center') {
|
|
62
|
-
top =
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
top =
|
|
68
|
+
top -
|
|
69
|
+
viewportHeight / 2 +
|
|
70
|
+
findMaxKeyValue(sizes.sizeTree, index)[1] / 2;
|
|
65
71
|
}
|
|
66
72
|
else {
|
|
67
73
|
top -= topListHeight;
|
|
@@ -72,8 +78,12 @@ export var scrollToIndexSystem = u.system(function (_a) {
|
|
|
72
78
|
var retry = function (listChanged) {
|
|
73
79
|
cleanup();
|
|
74
80
|
if (listChanged) {
|
|
81
|
+
log('retrying to scroll to', { location: location }, LogLevel.DEBUG);
|
|
75
82
|
u.publish(scrollToIndex, location);
|
|
76
83
|
}
|
|
84
|
+
else {
|
|
85
|
+
log('list did not change, scroll successful', {}, LogLevel.DEBUG);
|
|
86
|
+
}
|
|
77
87
|
};
|
|
78
88
|
cleanup();
|
|
79
89
|
if (behavior === 'smooth') {
|
|
@@ -86,7 +96,7 @@ export var scrollToIndexSystem = u.system(function (_a) {
|
|
|
86
96
|
});
|
|
87
97
|
}
|
|
88
98
|
else {
|
|
89
|
-
unsubscribeNextListRefresh = u.handleNext(listRefresh, retry);
|
|
99
|
+
unsubscribeNextListRefresh = u.handleNext(u.pipe(listRefresh, watchChangesFor(50)), retry);
|
|
90
100
|
}
|
|
91
101
|
// if the scroll jump is too small, the list won't get rerendered.
|
|
92
102
|
// clean this listener
|
|
@@ -94,10 +104,24 @@ export var scrollToIndexSystem = u.system(function (_a) {
|
|
|
94
104
|
cleanup();
|
|
95
105
|
}, 1200);
|
|
96
106
|
u.publish(scrollingInProgress, true);
|
|
107
|
+
log('scrolling from index to', { index: index, top: top, behavior: behavior }, LogLevel.DEBUG);
|
|
97
108
|
return { top: top, behavior: behavior };
|
|
98
109
|
})), scrollTo);
|
|
99
110
|
return {
|
|
100
111
|
scrollToIndex: scrollToIndex,
|
|
101
112
|
topListHeight: topListHeight,
|
|
102
113
|
};
|
|
103
|
-
}, u.tup(sizeSystem, domIOSystem), { singleton: true });
|
|
114
|
+
}, u.tup(sizeSystem, domIOSystem, loggerSystem), { singleton: true });
|
|
115
|
+
function watchChangesFor(limit) {
|
|
116
|
+
return function (done) {
|
|
117
|
+
var timeoutRef = setTimeout(function () {
|
|
118
|
+
done(false);
|
|
119
|
+
}, limit);
|
|
120
|
+
return function (value) {
|
|
121
|
+
if (value) {
|
|
122
|
+
done(true);
|
|
123
|
+
clearTimeout(timeoutRef);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { __read } from "tslib";
|
|
2
2
|
import * as u from '@virtuoso.dev/urx';
|
|
3
3
|
import { tupleComparator } from './comparators';
|
|
4
|
-
import { domIOSystem
|
|
4
|
+
import { domIOSystem } from './domIOSystem';
|
|
5
|
+
import { DOWN, UP } from './stateFlagsSystem';
|
|
5
6
|
export var TOP = 'top';
|
|
6
7
|
export var BOTTOM = 'bottom';
|
|
7
8
|
export var NONE = 'none';
|
|
8
|
-
export
|
|
9
|
+
export function getOverscan(overscan, end, direction) {
|
|
9
10
|
if (typeof overscan === 'number') {
|
|
10
11
|
return (direction === UP && end === TOP) ||
|
|
11
12
|
(direction === DOWN && end === BOTTOM)
|
|
@@ -16,30 +17,55 @@ export var getOverscan = function (overscan, end, direction) {
|
|
|
16
17
|
return end === TOP ? overscan.main : overscan.reverse;
|
|
17
18
|
}
|
|
18
19
|
return end === BOTTOM ? overscan.main : overscan.reverse;
|
|
19
|
-
}
|
|
20
|
+
}
|
|
21
|
+
function getViewportIncrease(value, end) {
|
|
22
|
+
return typeof value === 'number' ? value : value[end] || 0;
|
|
23
|
+
}
|
|
20
24
|
export var sizeRangeSystem = u.system(function (_a) {
|
|
21
25
|
var _b = __read(_a, 1), _c = _b[0], scrollTop = _c.scrollTop, viewportHeight = _c.viewportHeight, deviation = _c.deviation, headerHeight = _c.headerHeight;
|
|
22
26
|
var listBoundary = u.stream();
|
|
23
27
|
var topListHeight = u.statefulStream(0);
|
|
28
|
+
var fixedHeaderHeight = u.statefulStream(0);
|
|
29
|
+
var increaseViewportBy = u.statefulStream(0);
|
|
24
30
|
var overscan = u.statefulStream(0);
|
|
25
|
-
var visibleRange = u.statefulStreamFromEmitter(u.pipe(u.combineLatest(u.duc(scrollTop), u.duc(viewportHeight), u.duc(headerHeight), u.duc(listBoundary, tupleComparator), u.duc(overscan), u.duc(topListHeight), u.duc(deviation)), u.map(function (_a) {
|
|
26
|
-
var _b = __read(_a,
|
|
31
|
+
var visibleRange = u.statefulStreamFromEmitter(u.pipe(u.combineLatest(u.duc(scrollTop), u.duc(viewportHeight), u.duc(headerHeight), u.duc(listBoundary, tupleComparator), u.duc(overscan), u.duc(topListHeight), u.duc(fixedHeaderHeight), u.duc(deviation), u.duc(increaseViewportBy)), u.map(function (_a) {
|
|
32
|
+
var _b = __read(_a, 9), scrollTop = _b[0], viewportHeight = _b[1], headerHeight = _b[2],
|
|
27
33
|
// @ts-ignore
|
|
28
|
-
_c = __read(_b[3], 2), listTop = _c[0], listBottom = _c[1], overscan = _b[4], topListHeight = _b[5],
|
|
29
|
-
var top = scrollTop -
|
|
34
|
+
_c = __read(_b[3], 2), listTop = _c[0], listBottom = _c[1], overscan = _b[4], topListHeight = _b[5], fixedHeaderHeight = _b[6], deviation = _b[7], increaseViewportBy = _b[8];
|
|
35
|
+
var top = scrollTop - deviation;
|
|
36
|
+
var stickyHeaderHeight = topListHeight + fixedHeaderHeight;
|
|
37
|
+
var headerVisible = Math.max(headerHeight - top, 0);
|
|
30
38
|
var direction = NONE;
|
|
39
|
+
var topViewportAddition = getViewportIncrease(increaseViewportBy, TOP);
|
|
40
|
+
var bottomViewportAddition = getViewportIncrease(increaseViewportBy, BOTTOM);
|
|
31
41
|
listTop -= deviation;
|
|
42
|
+
listTop += headerHeight + fixedHeaderHeight;
|
|
43
|
+
listBottom += headerHeight + fixedHeaderHeight;
|
|
32
44
|
listBottom -= deviation;
|
|
33
|
-
|
|
45
|
+
// console.log({ listTop, scrollTop, stickyHeaderHeight, topViewportAddition })
|
|
46
|
+
if (listTop >
|
|
47
|
+
scrollTop + stickyHeaderHeight - topViewportAddition) {
|
|
34
48
|
direction = UP;
|
|
35
49
|
}
|
|
36
|
-
if (listBottom <
|
|
50
|
+
if (listBottom <
|
|
51
|
+
scrollTop -
|
|
52
|
+
headerVisible +
|
|
53
|
+
viewportHeight +
|
|
54
|
+
bottomViewportAddition) {
|
|
37
55
|
direction = DOWN;
|
|
38
56
|
}
|
|
39
57
|
if (direction !== NONE) {
|
|
40
58
|
return [
|
|
41
|
-
Math.max(top -
|
|
42
|
-
|
|
59
|
+
Math.max(top -
|
|
60
|
+
headerHeight -
|
|
61
|
+
getOverscan(overscan, TOP, direction) -
|
|
62
|
+
topViewportAddition, 0),
|
|
63
|
+
top -
|
|
64
|
+
headerVisible -
|
|
65
|
+
fixedHeaderHeight +
|
|
66
|
+
viewportHeight +
|
|
67
|
+
getOverscan(overscan, BOTTOM, direction) +
|
|
68
|
+
bottomViewportAddition,
|
|
43
69
|
];
|
|
44
70
|
}
|
|
45
71
|
return null;
|
|
@@ -49,6 +75,8 @@ export var sizeRangeSystem = u.system(function (_a) {
|
|
|
49
75
|
listBoundary: listBoundary,
|
|
50
76
|
overscan: overscan,
|
|
51
77
|
topListHeight: topListHeight,
|
|
78
|
+
fixedHeaderHeight: fixedHeaderHeight,
|
|
79
|
+
increaseViewportBy: increaseViewportBy,
|
|
52
80
|
// output
|
|
53
81
|
visibleRange: visibleRange,
|
|
54
82
|
};
|
|
@@ -2,7 +2,9 @@ import { __assign, __read, __spread, __values } from "tslib";
|
|
|
2
2
|
/* eslint-disable no-continue */
|
|
3
3
|
import * as u from '@virtuoso.dev/urx';
|
|
4
4
|
import { arrayToRanges, empty, findMaxKeyValue, insert, newTree, rangesWithin, remove, walk, } from './AATree';
|
|
5
|
+
import { loggerSystem, LogLevel } from './loggerSystem';
|
|
5
6
|
import * as arrayBinarySearch from './utils/binaryArraySearch';
|
|
7
|
+
import { correctItemSize } from './utils/correctItemSize';
|
|
6
8
|
function rangeIncludes(refRange) {
|
|
7
9
|
var size = refRange.size, startIndex = refRange.startIndex, endIndex = refRange.endIndex;
|
|
8
10
|
return function (range) {
|
|
@@ -103,80 +105,92 @@ export function rangesWithinOffsets(tree, startOffset, endOffset, minStartIndex)
|
|
|
103
105
|
}
|
|
104
106
|
return arrayToRanges(arrayBinarySearch.findRange(tree, startOffset, endOffset, offsetComparator), offsetPointParser);
|
|
105
107
|
}
|
|
106
|
-
|
|
107
|
-
var
|
|
108
|
-
var
|
|
109
|
-
var sizeTree = state.sizeTree;
|
|
110
|
-
var offsetTree = state.offsetTree;
|
|
111
|
-
var newSizeTree = sizeTree;
|
|
112
|
-
var syncStart = 0;
|
|
113
|
-
// We receive probe item results from a group probe,
|
|
114
|
-
// which should always pass an item and a group
|
|
115
|
-
// the results contain two ranges, which we consider to mean that groups and items have different size
|
|
116
|
-
if (groupIndices.length > 0 && empty(sizeTree) && ranges.length === 2) {
|
|
117
|
-
var groupSize_1 = ranges[0].size;
|
|
118
|
-
var itemSize_1 = ranges[1].size;
|
|
119
|
-
newSizeTree = groupIndices.reduce(function (tree, groupIndex) {
|
|
120
|
-
return insert(insert(tree, groupIndex, groupSize_1), groupIndex + 1, itemSize_1);
|
|
121
|
-
}, newSizeTree);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
_b = __read(insertRanges(newSizeTree, ranges), 2), newSizeTree = _b[0], syncStart = _b[1];
|
|
125
|
-
}
|
|
126
|
-
if (newSizeTree === sizeTree) {
|
|
127
|
-
return state;
|
|
128
|
-
}
|
|
108
|
+
function createOffsetTree(prevOffsetTree, syncStart, sizeTree) {
|
|
109
|
+
var e_3, _a;
|
|
110
|
+
var offsetTree = prevOffsetTree;
|
|
129
111
|
var prevIndex = 0;
|
|
130
112
|
var prevSize = 0;
|
|
131
|
-
var
|
|
132
|
-
var
|
|
113
|
+
var prevOffset = 0;
|
|
114
|
+
var startIndex = 0;
|
|
133
115
|
if (syncStart !== 0) {
|
|
134
|
-
|
|
135
|
-
var offsetInfo = offsetTree[
|
|
136
|
-
|
|
137
|
-
var kv = findMaxKeyValue(
|
|
116
|
+
startIndex = arrayBinarySearch.findIndexOfClosestSmallerOrEqual(offsetTree, syncStart - 1, indexComparator);
|
|
117
|
+
var offsetInfo = offsetTree[startIndex];
|
|
118
|
+
prevOffset = offsetInfo.offset;
|
|
119
|
+
var kv = findMaxKeyValue(sizeTree, syncStart - 1);
|
|
138
120
|
prevIndex = kv[0];
|
|
139
121
|
prevSize = kv[1];
|
|
140
122
|
if (offsetTree.length &&
|
|
141
|
-
offsetTree[
|
|
142
|
-
|
|
143
|
-
startAIndex -= 1;
|
|
123
|
+
offsetTree[startIndex].size === findMaxKeyValue(sizeTree, syncStart)[1]) {
|
|
124
|
+
startIndex -= 1;
|
|
144
125
|
}
|
|
145
|
-
offsetTree = offsetTree.slice(0,
|
|
126
|
+
offsetTree = offsetTree.slice(0, startIndex + 1);
|
|
146
127
|
}
|
|
147
128
|
else {
|
|
148
129
|
offsetTree = [];
|
|
149
130
|
}
|
|
150
131
|
try {
|
|
151
|
-
for (var
|
|
152
|
-
var
|
|
153
|
-
var aOffset = (
|
|
132
|
+
for (var _b = __values(rangesWithin(sizeTree, syncStart, Infinity)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
133
|
+
var _d = _c.value, startIndex_1 = _d.start, value = _d.value;
|
|
134
|
+
var aOffset = (startIndex_1 - prevIndex) * prevSize + prevOffset;
|
|
154
135
|
offsetTree.push({
|
|
155
136
|
offset: aOffset,
|
|
156
137
|
size: value,
|
|
157
|
-
index:
|
|
138
|
+
index: startIndex_1,
|
|
158
139
|
});
|
|
159
|
-
prevIndex =
|
|
160
|
-
|
|
140
|
+
prevIndex = startIndex_1;
|
|
141
|
+
prevOffset = aOffset;
|
|
161
142
|
prevSize = value;
|
|
162
143
|
}
|
|
163
144
|
}
|
|
164
145
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
165
146
|
finally {
|
|
166
147
|
try {
|
|
167
|
-
if (
|
|
148
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
168
149
|
}
|
|
169
150
|
finally { if (e_3) throw e_3.error; }
|
|
170
151
|
}
|
|
171
152
|
return {
|
|
172
|
-
sizeTree: newSizeTree,
|
|
173
153
|
offsetTree: offsetTree,
|
|
174
|
-
groupOffsetTree: groupIndices.reduce(function (tree, index) {
|
|
175
|
-
return insert(tree, index, offsetOf(index, offsetTree));
|
|
176
|
-
}, newTree()),
|
|
177
154
|
lastIndex: prevIndex,
|
|
178
|
-
lastOffset:
|
|
155
|
+
lastOffset: prevOffset,
|
|
179
156
|
lastSize: prevSize,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
export function sizeStateReducer(state, _a) {
|
|
160
|
+
var _b;
|
|
161
|
+
var _c = __read(_a, 3), ranges = _c[0], groupIndices = _c[1], log = _c[2];
|
|
162
|
+
if (ranges.length > 0) {
|
|
163
|
+
log('received item sizes', ranges, LogLevel.DEBUG);
|
|
164
|
+
}
|
|
165
|
+
var sizeTree = state.sizeTree;
|
|
166
|
+
var newSizeTree = sizeTree;
|
|
167
|
+
var syncStart = 0;
|
|
168
|
+
// We receive probe item results from a group probe,
|
|
169
|
+
// which should always pass an item and a group
|
|
170
|
+
// the results contain two ranges, which we consider to mean that groups and items have different size
|
|
171
|
+
if (groupIndices.length > 0 && empty(sizeTree) && ranges.length === 2) {
|
|
172
|
+
var groupSize_1 = ranges[0].size;
|
|
173
|
+
var itemSize_1 = ranges[1].size;
|
|
174
|
+
newSizeTree = groupIndices.reduce(function (tree, groupIndex) {
|
|
175
|
+
return insert(insert(tree, groupIndex, groupSize_1), groupIndex + 1, itemSize_1);
|
|
176
|
+
}, newSizeTree);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
_b = __read(insertRanges(newSizeTree, ranges), 2), newSizeTree = _b[0], syncStart = _b[1];
|
|
180
|
+
}
|
|
181
|
+
if (newSizeTree === sizeTree) {
|
|
182
|
+
return state;
|
|
183
|
+
}
|
|
184
|
+
var _d = createOffsetTree(state.offsetTree, syncStart, newSizeTree), newOffsetTree = _d.offsetTree, lastIndex = _d.lastIndex, lastSize = _d.lastSize, lastOffset = _d.lastOffset;
|
|
185
|
+
return {
|
|
186
|
+
sizeTree: newSizeTree,
|
|
187
|
+
offsetTree: newOffsetTree,
|
|
188
|
+
lastIndex: lastIndex,
|
|
189
|
+
lastOffset: lastOffset,
|
|
190
|
+
lastSize: lastSize,
|
|
191
|
+
groupOffsetTree: groupIndices.reduce(function (tree, index) {
|
|
192
|
+
return insert(tree, index, offsetOf(index, newOffsetTree));
|
|
193
|
+
}, newTree()),
|
|
180
194
|
groupIndices: groupIndices,
|
|
181
195
|
};
|
|
182
196
|
}
|
|
@@ -201,18 +215,27 @@ export function originalIndexFromItemIndex(itemIndex, sizes) {
|
|
|
201
215
|
export function hasGroups(sizes) {
|
|
202
216
|
return !empty(sizes.groupOffsetTree);
|
|
203
217
|
}
|
|
204
|
-
|
|
218
|
+
var SIZE_MAP = {
|
|
219
|
+
offsetHeight: 'height',
|
|
220
|
+
offsetWidth: 'width',
|
|
221
|
+
};
|
|
222
|
+
export var sizeSystem = u.system(function (_a) {
|
|
223
|
+
var _b = __read(_a, 1), log = _b[0].log;
|
|
205
224
|
var sizeRanges = u.stream();
|
|
206
225
|
var totalCount = u.stream();
|
|
226
|
+
var statefulTotalCount = u.statefulStreamFromEmitter(totalCount, 0);
|
|
207
227
|
var unshiftWith = u.stream();
|
|
228
|
+
var shiftWith = u.stream();
|
|
208
229
|
var firstItemIndex = u.statefulStream(0);
|
|
209
230
|
var groupIndices = u.statefulStream([]);
|
|
210
231
|
var fixedItemSize = u.statefulStream(undefined);
|
|
211
232
|
var defaultItemSize = u.statefulStream(undefined);
|
|
212
|
-
var itemSize = u.statefulStream(function (el, field) {
|
|
233
|
+
var itemSize = u.statefulStream(function (el, field) {
|
|
234
|
+
return correctItemSize(el, SIZE_MAP[field]);
|
|
235
|
+
});
|
|
213
236
|
var data = u.statefulStream(undefined);
|
|
214
237
|
var initial = initialSizeState();
|
|
215
|
-
var sizes = u.statefulStreamFromEmitter(u.pipe(sizeRanges, u.withLatestFrom(groupIndices), u.scan(sizeStateReducer, initial), u.distinctUntilChanged()), initial);
|
|
238
|
+
var sizes = u.statefulStreamFromEmitter(u.pipe(sizeRanges, u.withLatestFrom(groupIndices, log), u.scan(sizeStateReducer, initial), u.distinctUntilChanged()), initial);
|
|
216
239
|
u.connect(u.pipe(groupIndices, u.filter(function (indexes) { return indexes.length > 0; }), u.withLatestFrom(sizes), u.map(function (_a) {
|
|
217
240
|
var _b = __read(_a, 2), groupIndices = _b[0], sizes = _b[1];
|
|
218
241
|
var groupOffsetTree = groupIndices.reduce(function (tree, index, idx) {
|
|
@@ -238,7 +261,9 @@ export var sizeSystem = u.system(function () {
|
|
|
238
261
|
})), sizeRanges);
|
|
239
262
|
u.connect(fixedItemSize, defaultItemSize);
|
|
240
263
|
var trackItemSizes = u.statefulStreamFromEmitter(u.pipe(fixedItemSize, u.map(function (size) { return size === undefined; })), true);
|
|
241
|
-
u.connect(u.pipe(defaultItemSize, u.filter(function (value) {
|
|
264
|
+
u.connect(u.pipe(defaultItemSize, u.filter(function (value) {
|
|
265
|
+
return value !== undefined && empty(u.getValue(sizes).sizeTree);
|
|
266
|
+
}), u.map(function (size) { return [{ startIndex: 0, endIndex: 0, size: size }]; })), sizeRanges);
|
|
242
267
|
var listRefresh = u.streamFromEmitter(u.pipe(sizeRanges, u.withLatestFrom(sizes), u.scan(function (_a, _b) {
|
|
243
268
|
var oldSizes = _a.sizes;
|
|
244
269
|
var _c = __read(_b, 2), newSizes = _c[1];
|
|
@@ -247,9 +272,22 @@ export var sizeSystem = u.system(function () {
|
|
|
247
272
|
sizes: newSizes,
|
|
248
273
|
};
|
|
249
274
|
}, { changed: false, sizes: initial }), u.map(function (value) { return value.changed; })));
|
|
250
|
-
u.
|
|
275
|
+
u.subscribe(u.pipe(firstItemIndex, u.scan(function (prev, next) {
|
|
251
276
|
return { diff: prev.prev - next, prev: next };
|
|
252
|
-
}, { diff: 0, prev: 0 }), u.map(function (val) { return val.diff; }),
|
|
277
|
+
}, { diff: 0, prev: 0 }), u.map(function (val) { return val.diff; })), function (offset) {
|
|
278
|
+
if (offset > 0) {
|
|
279
|
+
u.publish(unshiftWith, offset);
|
|
280
|
+
}
|
|
281
|
+
else if (offset < 0) {
|
|
282
|
+
u.publish(shiftWith, offset);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
u.subscribe(u.pipe(firstItemIndex, u.withLatestFrom(log)), function (_a) {
|
|
286
|
+
var _b = __read(_a, 2), index = _b[0], log = _b[1];
|
|
287
|
+
if (index < 0) {
|
|
288
|
+
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 }, LogLevel.ERROR);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
253
291
|
// Capture the current list top item before the sizes get refreshed
|
|
254
292
|
var beforeUnshiftWith = u.streamFromEmitter(unshiftWith);
|
|
255
293
|
u.connect(u.pipe(unshiftWith, u.withLatestFrom(sizes), u.map(function (_a) {
|
|
@@ -276,6 +314,22 @@ export var sizeSystem = u.system(function () {
|
|
|
276
314
|
prevSize: sizes.lastSize,
|
|
277
315
|
}).ranges;
|
|
278
316
|
})), sizeRanges);
|
|
317
|
+
var shiftWithOffset = u.streamFromEmitter(u.pipe(shiftWith, u.withLatestFrom(sizes), u.map(function (_a) {
|
|
318
|
+
var _b = __read(_a, 2), shiftWith = _b[0], offsetTree = _b[1].offsetTree;
|
|
319
|
+
var newFirstItemIndex = -shiftWith;
|
|
320
|
+
return offsetOf(newFirstItemIndex, offsetTree);
|
|
321
|
+
})));
|
|
322
|
+
u.connect(u.pipe(shiftWith, u.withLatestFrom(sizes), u.map(function (_a) {
|
|
323
|
+
var _b = __read(_a, 2), shiftWith = _b[0], sizes = _b[1];
|
|
324
|
+
if (sizes.groupIndices.length > 0) {
|
|
325
|
+
throw new Error('Virtuoso: shifting items does not work with groups');
|
|
326
|
+
}
|
|
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
|
+
})), sizes);
|
|
279
333
|
return {
|
|
280
334
|
// input
|
|
281
335
|
data: data,
|
|
@@ -285,12 +339,15 @@ export var sizeSystem = u.system(function () {
|
|
|
285
339
|
defaultItemSize: defaultItemSize,
|
|
286
340
|
fixedItemSize: fixedItemSize,
|
|
287
341
|
unshiftWith: unshiftWith,
|
|
342
|
+
shiftWith: shiftWith,
|
|
343
|
+
shiftWithOffset: shiftWithOffset,
|
|
288
344
|
beforeUnshiftWith: beforeUnshiftWith,
|
|
289
345
|
firstItemIndex: firstItemIndex,
|
|
290
346
|
// output
|
|
291
347
|
sizes: sizes,
|
|
292
348
|
listRefresh: listRefresh,
|
|
349
|
+
statefulTotalCount: statefulTotalCount,
|
|
293
350
|
trackItemSizes: trackItemSizes,
|
|
294
351
|
itemSize: itemSize,
|
|
295
352
|
};
|
|
296
|
-
},
|
|
353
|
+
}, u.tup(loggerSystem), { singleton: true });
|