@ringcentral/juno 2.4.1 → 2.5.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 +6 -2
- package/components/Buttons/IconButton/IconButton.js +9 -7
- 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/SuggestionList/SuggestionList.js +4 -1
- 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 +7 -14
- 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/components/Virtuoso/utils/useHighlightScroll.d.ts +4 -0
- package/components/Virtuoso/utils/useHighlightScroll.js +17 -0
- package/es6/components/Buttons/IconButton/IconButton.js +11 -9
- 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/Downshift/SuggestionList/SuggestionList.js +5 -2
- 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 +9 -16
- 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/components/Virtuoso/utils/useHighlightScroll.js +16 -0
- package/es6/foundation/hooks/useLongPress/useLongPress.js +7 -7
- package/es6/foundation/index.js +1 -1
- package/es6/foundation/isWebKit154.js +57 -0
- package/es6/foundation/theme/ThemeProvider.js +4 -4
- package/foundation/hooks/useLongPress/useLongPress.d.ts +3 -1
- package/foundation/hooks/useLongPress/useLongPress.js +7 -7
- package/foundation/index.d.ts +1 -1
- package/foundation/index.js +1 -1
- package/foundation/isWebKit154.d.ts +20 -0
- package/foundation/{isSafari154.js → isWebKit154.js} +22 -17
- package/foundation/theme/ThemeProvider.d.ts +1 -1
- package/foundation/theme/ThemeProvider.js +4 -4
- package/package.json +2 -2
- package/es6/foundation/isSafari154.js +0 -52
- package/foundation/isSafari154.d.ts +0 -15
|
@@ -1,37 +1,35 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useRcPortalWindowContext } from '../../../../foundation';
|
|
3
3
|
export function useSizeWithElRef(callback, enabled) {
|
|
4
4
|
if (enabled === void 0) { enabled = true; }
|
|
5
|
-
var externalWindow = useRcPortalWindowContext().externalWindow;
|
|
6
5
|
var ref = useRef(null);
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
// https://github.com/edunad/react-virtuoso/commit/581d4558f2994adea375291b76fe59605556c08f
|
|
13
|
-
// requestAnimationFrame(() => {
|
|
14
|
-
//
|
|
15
|
-
// if display: none, the element won't have an offsetParent
|
|
16
|
-
// measuring it at this mode is not going to work
|
|
17
|
-
// https://stackoverflow.com/a/21696585/1009797
|
|
18
|
-
if (element.offsetParent !== null) {
|
|
19
|
-
callback(element);
|
|
20
|
-
}
|
|
21
|
-
// })
|
|
22
|
-
}, externalWindow);
|
|
23
|
-
var callbackRef = function (elRef) {
|
|
24
|
-
if (elRef && enabled) {
|
|
25
|
-
observer.observe(elRef);
|
|
26
|
-
ref.current = elRef;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
if (ref.current) {
|
|
30
|
-
observer.unobserve(ref.current);
|
|
31
|
-
}
|
|
32
|
-
ref.current = null;
|
|
33
|
-
}
|
|
6
|
+
var _a = useRcPortalWindowContext().externalWindow, externalWindow = _a === void 0 ? window : _a;
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8
|
+
var callbackRef = function (_el) {
|
|
9
|
+
// eslint-disable-next-line no-void
|
|
10
|
+
void 0;
|
|
34
11
|
};
|
|
12
|
+
// TODO: fix after upgrade ts
|
|
13
|
+
if (typeof externalWindow['ResizeObserver'] !== 'undefined') {
|
|
14
|
+
var observer_1 = new externalWindow['ResizeObserver'](function (entries) {
|
|
15
|
+
var element = entries[0].target;
|
|
16
|
+
if (element.offsetParent !== null) {
|
|
17
|
+
callback(element);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
callbackRef = function (elRef) {
|
|
21
|
+
if (elRef && enabled) {
|
|
22
|
+
observer_1.observe(elRef);
|
|
23
|
+
ref.current = elRef;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
if (ref.current) {
|
|
27
|
+
observer_1.unobserve(ref.current);
|
|
28
|
+
}
|
|
29
|
+
ref.current = null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
35
33
|
return { ref: ref, callbackRef: callbackRef };
|
|
36
34
|
}
|
|
37
35
|
export default function useSize(callback, enabled) {
|
|
@@ -1,34 +1,54 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { useRcPortalWindowContext } from '../../../../foundation';
|
|
2
3
|
import { useSizeWithElRef } from './useSize';
|
|
3
|
-
export default function useWindowViewportRectRef(callback,
|
|
4
|
-
if (customWindow === void 0) { customWindow = window; }
|
|
4
|
+
export default function useWindowViewportRectRef(callback, customScrollParent) {
|
|
5
5
|
var viewportInfo = useRef(null);
|
|
6
|
+
var _a = useRcPortalWindowContext().externalWindow, externalWindow = _a === void 0 ? window : _a;
|
|
6
7
|
var calculateInfo = useCallback(function (element) {
|
|
7
8
|
if (element === null) {
|
|
8
9
|
return;
|
|
9
10
|
}
|
|
10
11
|
var rect = element.getBoundingClientRect();
|
|
11
|
-
var visibleHeight = customWindow.innerHeight - Math.max(0, rect.top);
|
|
12
12
|
var visibleWidth = rect.width;
|
|
13
|
-
var
|
|
13
|
+
var visibleHeight;
|
|
14
|
+
var offsetTop;
|
|
15
|
+
if (customScrollParent) {
|
|
16
|
+
var customScrollParentRect = customScrollParent.getBoundingClientRect();
|
|
17
|
+
var deltaTop = rect.top - customScrollParentRect.top;
|
|
18
|
+
visibleHeight = customScrollParentRect.height - Math.max(0, deltaTop);
|
|
19
|
+
offsetTop = deltaTop + customScrollParent.scrollTop;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
visibleHeight = externalWindow.innerHeight - Math.max(0, rect.top);
|
|
23
|
+
offsetTop = rect.top + externalWindow.pageYOffset;
|
|
24
|
+
}
|
|
14
25
|
viewportInfo.current = {
|
|
15
26
|
offsetTop: offsetTop,
|
|
16
27
|
visibleHeight: visibleHeight,
|
|
17
28
|
visibleWidth: visibleWidth,
|
|
18
29
|
};
|
|
19
30
|
callback(viewportInfo.current);
|
|
20
|
-
}, [callback,
|
|
21
|
-
var
|
|
22
|
-
var
|
|
31
|
+
}, [callback, customScrollParent, externalWindow]);
|
|
32
|
+
var _b = useSizeWithElRef(calculateInfo), callbackRef = _b.callbackRef, ref = _b.ref;
|
|
33
|
+
var scrollAndResizeEventHandler = useCallback(function () {
|
|
23
34
|
calculateInfo(ref.current);
|
|
24
35
|
}, [calculateInfo, ref]);
|
|
25
36
|
useEffect(function () {
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
if (customScrollParent) {
|
|
38
|
+
customScrollParent.addEventListener('scroll', scrollAndResizeEventHandler);
|
|
39
|
+
var observer_1 = new externalWindow['ResizeObserver'](scrollAndResizeEventHandler);
|
|
40
|
+
observer_1.observe(customScrollParent);
|
|
41
|
+
return function () {
|
|
42
|
+
customScrollParent.removeEventListener('scroll', scrollAndResizeEventHandler);
|
|
43
|
+
observer_1.unobserve(customScrollParent);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
externalWindow.addEventListener('scroll', scrollAndResizeEventHandler);
|
|
47
|
+
externalWindow.addEventListener('resize', scrollAndResizeEventHandler);
|
|
28
48
|
return function () {
|
|
29
|
-
|
|
30
|
-
|
|
49
|
+
externalWindow.removeEventListener('scroll', scrollAndResizeEventHandler);
|
|
50
|
+
externalWindow.removeEventListener('resize', scrollAndResizeEventHandler);
|
|
31
51
|
};
|
|
32
|
-
}, [
|
|
52
|
+
}, [scrollAndResizeEventHandler, customScrollParent, externalWindow]);
|
|
33
53
|
return callbackRef;
|
|
34
54
|
}
|
|
@@ -32,14 +32,7 @@ export var initialItemCountSystem = u.system(function (_a) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
var adjustedCount = count + includedGroupsCount;
|
|
35
|
-
var items = Array.from({
|
|
36
|
-
length: adjustedCount,
|
|
37
|
-
}).map(function (_, index) { return ({
|
|
38
|
-
index: index,
|
|
39
|
-
size: 0,
|
|
40
|
-
offset: 0,
|
|
41
|
-
data: data[index],
|
|
42
|
-
}); });
|
|
35
|
+
var items = Array.from({ length: adjustedCount }).map(function (_, index) { return ({ index: index, size: 0, offset: 0, data: data[index] }); });
|
|
43
36
|
return buildListState(items, [], adjustedCount, sizes, firstItemIndex);
|
|
44
37
|
})), listState);
|
|
45
38
|
return { initialItemCount: initialItemCount };
|
|
@@ -5,23 +5,38 @@ import { domIOSystem } from './domIOSystem';
|
|
|
5
5
|
import { propsReadySystem } from './propsReadySystem';
|
|
6
6
|
import { scrollToIndexSystem } from './scrollToIndexSystem';
|
|
7
7
|
import { sizeSystem } from './sizeSystem';
|
|
8
|
+
export function getInitialTopMostItemIndexNumber(location, totalCount) {
|
|
9
|
+
var lastIndex = totalCount - 1;
|
|
10
|
+
var index = typeof location === 'number'
|
|
11
|
+
? location
|
|
12
|
+
: location.index === 'LAST'
|
|
13
|
+
? lastIndex
|
|
14
|
+
: location.index;
|
|
15
|
+
return index;
|
|
16
|
+
}
|
|
8
17
|
export var initialTopMostItemIndexSystem = u.system(function (_a) {
|
|
9
|
-
var _b = __read(_a, 4), _c = _b[0], sizes = _c.sizes, listRefresh = _c.listRefresh, scrollTop = _b[1].scrollTop, scrollToIndex = _b[2].scrollToIndex, didMount = _b[3].didMount;
|
|
18
|
+
var _b = __read(_a, 4), _c = _b[0], sizes = _c.sizes, listRefresh = _c.listRefresh, defaultItemSize = _c.defaultItemSize, scrollTop = _b[1].scrollTop, scrollToIndex = _b[2].scrollToIndex, didMount = _b[3].didMount;
|
|
10
19
|
var scrolledToInitialItem = u.statefulStream(true);
|
|
11
20
|
var initialTopMostItemIndex = u.statefulStream(0);
|
|
12
|
-
u.connect(u.pipe(didMount, u.withLatestFrom(initialTopMostItemIndex),
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
u.connect(u.pipe(didMount, u.withLatestFrom(initialTopMostItemIndex),
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
|
+
u.filter(function (_a) {
|
|
24
|
+
var _b = __read(_a, 2), location = _b[1];
|
|
25
|
+
return !!location;
|
|
15
26
|
}), u.mapTo(false)), scrolledToInitialItem);
|
|
16
|
-
u.subscribe(u.pipe(listRefresh, u.withLatestFrom(scrolledToInitialItem, sizes), u.filter(function (_a) {
|
|
17
|
-
var _b = __read(_a,
|
|
18
|
-
return
|
|
27
|
+
u.subscribe(u.pipe(u.combineLatest(listRefresh, didMount), u.withLatestFrom(scrolledToInitialItem, sizes, defaultItemSize), u.filter(function (_a) {
|
|
28
|
+
var _b = __read(_a, 4), _c = __read(_b[0], 2), didMount = _c[1], scrolledToInitialItem = _b[1], sizeTree = _b[2].sizeTree, defaultItemSize = _b[3];
|
|
29
|
+
return (didMount &&
|
|
30
|
+
(!empty(sizeTree) || defaultItemSize !== undefined) &&
|
|
31
|
+
!scrolledToInitialItem);
|
|
19
32
|
}), u.withLatestFrom(initialTopMostItemIndex)), function (_a) {
|
|
20
33
|
var _b = __read(_a, 2), initialTopMostItemIndex = _b[1];
|
|
21
|
-
|
|
22
|
-
u.
|
|
34
|
+
setTimeout(function () {
|
|
35
|
+
u.handleNext(scrollTop, function () {
|
|
36
|
+
u.publish(scrolledToInitialItem, true);
|
|
37
|
+
});
|
|
38
|
+
u.publish(scrollToIndex, initialTopMostItemIndex);
|
|
23
39
|
});
|
|
24
|
-
u.publish(scrollToIndex, initialTopMostItemIndex);
|
|
25
40
|
});
|
|
26
41
|
return {
|
|
27
42
|
scrolledToInitialItem: scrolledToInitialItem,
|
|
@@ -3,7 +3,7 @@ import * as u from '@virtuoso.dev/urx';
|
|
|
3
3
|
import { empty, findMaxKeyValue, rangesWithin } from './AATree';
|
|
4
4
|
import { rangeComparator, tupleComparator } from './comparators';
|
|
5
5
|
import { groupedListSystem } from './groupedListSystem';
|
|
6
|
-
import { initialTopMostItemIndexSystem } from './initialTopMostItemIndexSystem';
|
|
6
|
+
import { getInitialTopMostItemIndexNumber, initialTopMostItemIndexSystem, } from './initialTopMostItemIndexSystem';
|
|
7
7
|
import { propsReadySystem } from './propsReadySystem';
|
|
8
8
|
import { scrollToIndexSystem } from './scrollToIndexSystem';
|
|
9
9
|
import { sizeRangeSystem } from './sizeRangeSystem';
|
|
@@ -116,7 +116,7 @@ export var listStateSystem = u.system(function (_a) {
|
|
|
116
116
|
return EMPTY_LIST_STATE;
|
|
117
117
|
}
|
|
118
118
|
if (empty(sizeTree)) {
|
|
119
|
-
return buildListState(probeItemSet(initialTopMostItemIndex, sizesValue, data), [], totalCount, sizesValue, firstItemIndex);
|
|
119
|
+
return buildListState(probeItemSet(getInitialTopMostItemIndexNumber(initialTopMostItemIndex, totalCount), sizesValue, data), [], totalCount, sizesValue, firstItemIndex);
|
|
120
120
|
}
|
|
121
121
|
var topItems = [];
|
|
122
122
|
if (topItemsIndexes.length > 0) {
|
|
@@ -209,7 +209,6 @@ export var listStateSystem = u.system(function (_a) {
|
|
|
209
209
|
u.connect(u.pipe(data, u.filter(function (data) { return data !== undefined; }), u.map(function (data) { return data.length; })), totalCount);
|
|
210
210
|
u.connect(u.pipe(listState, u.map(u.prop('topListHeight'))), topListHeight);
|
|
211
211
|
u.connect(topListHeight, rangeTopListHeight);
|
|
212
|
-
u.connect(listState, stateFlags.listStateListener);
|
|
213
212
|
u.connect(u.pipe(listState, u.map(function (state) { return [state.top, state.bottom]; })), listBoundary);
|
|
214
213
|
u.connect(u.pipe(listState, u.map(function (state) { return state.items; })), itemsRendered);
|
|
215
214
|
var endReached = u.streamFromEmitter(u.pipe(listState, u.filter(function (_a) {
|
|
@@ -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
|
};
|