@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
|
@@ -26,15 +26,12 @@ var PROBE_GRID_STATE = {
|
|
|
26
26
|
itemHeight: 0,
|
|
27
27
|
itemWidth: 0,
|
|
28
28
|
};
|
|
29
|
-
var ceil = Math.ceil, floor = Math.floor, min = Math.min, max = Math.max;
|
|
30
|
-
function hackFloor(val) {
|
|
31
|
-
return ceil(val) - val < 0.03 ? ceil(val) : floor(val);
|
|
32
|
-
}
|
|
29
|
+
var round = Math.round, ceil = Math.ceil, floor = Math.floor, min = Math.min, max = Math.max;
|
|
33
30
|
function buildItems(startIndex, endIndex) {
|
|
34
31
|
return Array.from({ length: endIndex - startIndex + 1 }).map(function (_, i) { return ({ index: i + startIndex }); });
|
|
35
32
|
}
|
|
36
33
|
export var gridSystem = u.system(function (_a) {
|
|
37
|
-
var _b = __read(_a, 6), _c = _b[0], overscan = _c.overscan, visibleRange = _c.visibleRange, listBoundary = _c.listBoundary, _d = _b[1], scrollTop = _d.scrollTop, viewportHeight = _d.viewportHeight, scrollBy = _d.scrollBy, scrollTo = _d.scrollTo, smoothScrollTargetReached = _d.smoothScrollTargetReached, stateFlags = _b[2], scrollSeek = _b[3], _e = _b[4], propsReady = _e.propsReady, didMount = _e.didMount, _f = _b[5], windowViewportRect = _f.windowViewportRect, windowScrollTo = _f.windowScrollTo, useWindowScroll = _f.useWindowScroll,
|
|
34
|
+
var _b = __read(_a, 6), _c = _b[0], overscan = _c.overscan, visibleRange = _c.visibleRange, listBoundary = _c.listBoundary, _d = _b[1], scrollTop = _d.scrollTop, viewportHeight = _d.viewportHeight, scrollBy = _d.scrollBy, scrollTo = _d.scrollTo, smoothScrollTargetReached = _d.smoothScrollTargetReached, scrollContainerState = _d.scrollContainerState, stateFlags = _b[2], scrollSeek = _b[3], _e = _b[4], propsReady = _e.propsReady, didMount = _e.didMount, _f = _b[5], windowViewportRect = _f.windowViewportRect, windowScrollTo = _f.windowScrollTo, useWindowScroll = _f.useWindowScroll, customScrollParent = _f.customScrollParent, windowScrollContainerState = _f.windowScrollContainerState;
|
|
38
35
|
var totalCount = u.statefulStream(0);
|
|
39
36
|
var initialItemCount = u.statefulStream(0);
|
|
40
37
|
var gridState = u.statefulStream(INITIAL_GRID_STATE);
|
|
@@ -47,6 +44,8 @@ export var gridSystem = u.system(function (_a) {
|
|
|
47
44
|
width: 0,
|
|
48
45
|
});
|
|
49
46
|
var scrollToIndex = u.stream();
|
|
47
|
+
var scrollHeight = u.stream();
|
|
48
|
+
var deviation = u.statefulStream(0);
|
|
50
49
|
u.connect(u.pipe(didMount, u.withLatestFrom(initialItemCount), u.filter(function (_a) {
|
|
51
50
|
var _b = __read(_a, 2), count = _b[1];
|
|
52
51
|
return count !== 0;
|
|
@@ -74,7 +73,7 @@ export var gridSystem = u.system(function (_a) {
|
|
|
74
73
|
if (itemWidth === 0) {
|
|
75
74
|
return PROBE_GRID_STATE;
|
|
76
75
|
}
|
|
77
|
-
var perRow =
|
|
76
|
+
var perRow = itemsPerRow(viewportWidth, itemWidth);
|
|
78
77
|
var startIndex = perRow * floor(startOffset / itemHeight);
|
|
79
78
|
var endIndex = perRow * ceil(endOffset / itemHeight) - 1;
|
|
80
79
|
endIndex = min(totalCount - 1, endIndex);
|
|
@@ -102,10 +101,6 @@ export var gridSystem = u.system(function (_a) {
|
|
|
102
101
|
var _c = gridLayout(viewportDimensions, item, items), top = _c.top, bottom = _c.bottom;
|
|
103
102
|
return [top, bottom];
|
|
104
103
|
}), u.distinctUntilChanged(tupleComparator)), listBoundary);
|
|
105
|
-
u.connect(u.pipe(listBoundary, u.withLatestFrom(gridState), u.map(function (_a) {
|
|
106
|
-
var _b = __read(_a, 2), _c = __read(_b[0], 2), bottom = _c[1], offsetBottom = _b[1].offsetBottom;
|
|
107
|
-
return { bottom: bottom, offsetBottom: offsetBottom };
|
|
108
|
-
})), stateFlags.listStateListener);
|
|
109
104
|
var endReached = u.streamFromEmitter(u.pipe(u.duc(gridState), u.filter(function (_a) {
|
|
110
105
|
var items = _a.items;
|
|
111
106
|
return items.length > 0;
|
|
@@ -136,13 +131,16 @@ export var gridSystem = u.system(function (_a) {
|
|
|
136
131
|
var normalLocation = normalizeIndexLocation(location);
|
|
137
132
|
var align = normalLocation.align, behavior = normalLocation.behavior, offset = normalLocation.offset;
|
|
138
133
|
var index = normalLocation.index;
|
|
139
|
-
|
|
134
|
+
if (index === 'LAST') {
|
|
135
|
+
index = totalCount - 1;
|
|
136
|
+
}
|
|
137
|
+
index = max(0, index, min(totalCount - 1, index));
|
|
140
138
|
var top = itemTop(viewport, item, index);
|
|
141
139
|
if (align === 'end') {
|
|
142
|
-
top =
|
|
140
|
+
top = round(top - viewport.height + item.height);
|
|
143
141
|
}
|
|
144
142
|
else if (align === 'center') {
|
|
145
|
-
top =
|
|
143
|
+
top = round(top - viewport.height / 2 + item.height / 2);
|
|
146
144
|
}
|
|
147
145
|
if (offset) {
|
|
148
146
|
top += offset;
|
|
@@ -162,6 +160,7 @@ export var gridSystem = u.system(function (_a) {
|
|
|
162
160
|
viewportDimensions: viewportDimensions,
|
|
163
161
|
itemDimensions: itemDimensions,
|
|
164
162
|
scrollTop: scrollTop,
|
|
163
|
+
scrollHeight: scrollHeight,
|
|
165
164
|
overscan: overscan,
|
|
166
165
|
scrollBy: scrollBy,
|
|
167
166
|
scrollTo: scrollTo,
|
|
@@ -170,7 +169,10 @@ export var gridSystem = u.system(function (_a) {
|
|
|
170
169
|
windowViewportRect: windowViewportRect,
|
|
171
170
|
windowScrollTo: windowScrollTo,
|
|
172
171
|
useWindowScroll: useWindowScroll,
|
|
173
|
-
|
|
172
|
+
customScrollParent: customScrollParent,
|
|
173
|
+
windowScrollContainerState: windowScrollContainerState,
|
|
174
|
+
deviation: deviation,
|
|
175
|
+
scrollContainerState: scrollContainerState,
|
|
174
176
|
initialItemCount: initialItemCount }, scrollSeek), {
|
|
175
177
|
// output
|
|
176
178
|
gridState: gridState,
|
|
@@ -193,5 +195,5 @@ function itemTop(viewport, item, index) {
|
|
|
193
195
|
return floor(index / perRow) * item.height;
|
|
194
196
|
}
|
|
195
197
|
function itemsPerRow(viewportWidth, itemWidth) {
|
|
196
|
-
return
|
|
198
|
+
return max(1, floor(viewportWidth / itemWidth));
|
|
197
199
|
}
|
|
@@ -1,13 +1,37 @@
|
|
|
1
|
+
/* eslint-disable no-continue */
|
|
2
|
+
import { useRcPortalWindowContext } from '../../../../foundation';
|
|
3
|
+
import { LogLevel } from '../loggerSystem';
|
|
1
4
|
import useSize from './useSize';
|
|
2
|
-
export default function
|
|
5
|
+
export default function useChangedListContentsSizes(callback, itemSize, enabled, scrollContainerStateCallback, log, customScrollParent) {
|
|
6
|
+
var _a = useRcPortalWindowContext().externalWindow, externalWindow = _a === void 0 ? window : _a;
|
|
3
7
|
return useSize(function (el) {
|
|
4
|
-
var ranges = getChangedChildSizes(el.children, itemSize, 'offsetHeight');
|
|
8
|
+
var ranges = getChangedChildSizes(el.children, itemSize, 'offsetHeight', log);
|
|
9
|
+
var scrollableElement = el.parentElement;
|
|
10
|
+
while (!scrollableElement.dataset['virtuosoScroller']) {
|
|
11
|
+
scrollableElement = scrollableElement.parentElement;
|
|
12
|
+
}
|
|
13
|
+
var scrollTop = customScrollParent
|
|
14
|
+
? customScrollParent.scrollTop
|
|
15
|
+
: // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
16
|
+
scrollableElement.firstElementChild.dataset['viewportType'] === 'window'
|
|
17
|
+
? externalWindow.pageYOffset ||
|
|
18
|
+
externalWindow.document.documentElement.scrollTop
|
|
19
|
+
: scrollableElement.scrollTop;
|
|
20
|
+
customScrollParent
|
|
21
|
+
? scrollContainerStateCallback([
|
|
22
|
+
Math.max(scrollTop, 0),
|
|
23
|
+
customScrollParent.scrollHeight,
|
|
24
|
+
])
|
|
25
|
+
: scrollContainerStateCallback([
|
|
26
|
+
Math.max(scrollTop, 0),
|
|
27
|
+
scrollableElement.scrollHeight,
|
|
28
|
+
]);
|
|
5
29
|
if (ranges !== null) {
|
|
6
30
|
callback(ranges);
|
|
7
31
|
}
|
|
8
32
|
}, enabled);
|
|
9
33
|
}
|
|
10
|
-
function getChangedChildSizes(children, itemSize, field) {
|
|
34
|
+
function getChangedChildSizes(children, itemSize, field, log) {
|
|
11
35
|
var length = children.length;
|
|
12
36
|
if (length === 0) {
|
|
13
37
|
return null;
|
|
@@ -18,11 +42,12 @@ function getChangedChildSizes(children, itemSize, field) {
|
|
|
18
42
|
if (!child || child.dataset.index === undefined) {
|
|
19
43
|
continue;
|
|
20
44
|
}
|
|
21
|
-
|
|
22
|
-
var
|
|
45
|
+
// eslint-disable-next-line radix
|
|
46
|
+
var index = parseInt(child.dataset.index);
|
|
47
|
+
var knownSize = parseFloat(child.dataset.knownSize);
|
|
23
48
|
var size = itemSize(child, field);
|
|
24
49
|
if (size === 0) {
|
|
25
|
-
|
|
50
|
+
log('Zero-sized element, this should not happen', { child: child }, LogLevel.ERROR);
|
|
26
51
|
}
|
|
27
52
|
if (size === knownSize) {
|
|
28
53
|
continue;
|
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef } from 'react';
|
|
2
2
|
import * as u from '@virtuoso.dev/urx';
|
|
3
|
-
|
|
3
|
+
import { correctItemSize } from '../utils/correctItemSize';
|
|
4
|
+
import { useRcPortalWindowContext } from '../../../../foundation';
|
|
5
|
+
function approximatelyEqual(num1, num2) {
|
|
6
|
+
return Math.abs(num1 - num2) < 1.01;
|
|
7
|
+
}
|
|
8
|
+
export default function useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, scrollerElement, scrollerRefCallback, customScrollParent) {
|
|
4
9
|
if (scrollerRefCallback === void 0) { scrollerRefCallback = u.noop; }
|
|
5
|
-
if (customWindow === void 0) { customWindow = window; }
|
|
6
10
|
var scrollerRef = useRef(null);
|
|
7
11
|
var scrollTopTarget = useRef(null);
|
|
8
12
|
var timeoutRef = useRef(null);
|
|
9
|
-
var
|
|
13
|
+
var _a = useRcPortalWindowContext().externalWindow, externalWindow = _a === void 0 ? window : _a;
|
|
10
14
|
var handler = useCallback(function (ev) {
|
|
11
15
|
var el = ev.target;
|
|
12
|
-
var scrollTop = el ===
|
|
13
|
-
|
|
16
|
+
var scrollTop = el === externalWindow ||
|
|
17
|
+
el === externalWindow.document
|
|
18
|
+
? externalWindow.pageYOffset ||
|
|
19
|
+
externalWindow.document.documentElement.scrollTop
|
|
14
20
|
: el.scrollTop;
|
|
15
|
-
|
|
21
|
+
var scrollHeight = el === externalWindow
|
|
22
|
+
? externalWindow.document.documentElement.scrollHeight
|
|
23
|
+
: el.scrollHeight;
|
|
24
|
+
scrollContainerStateCallback([Math.max(scrollTop, 0), scrollHeight]);
|
|
16
25
|
if (scrollTopTarget.current !== null) {
|
|
17
26
|
if (scrollTop === scrollTopTarget.current ||
|
|
18
27
|
scrollTop <= 0 ||
|
|
19
|
-
scrollTop === el.scrollHeight - el
|
|
28
|
+
scrollTop === el.scrollHeight - correctItemSize(el, 'height')) {
|
|
20
29
|
scrollTopTarget.current = null;
|
|
21
30
|
smoothScrollTargetReached(true);
|
|
22
31
|
if (timeoutRef.current) {
|
|
@@ -25,54 +34,59 @@ export default function useScrollTop(scrollTopCallback, smoothScrollTargetReache
|
|
|
25
34
|
}
|
|
26
35
|
}
|
|
27
36
|
}
|
|
28
|
-
}, [
|
|
29
|
-
customDocument,
|
|
30
|
-
customWindow,
|
|
31
|
-
scrollTopCallback,
|
|
32
|
-
smoothScrollTargetReached,
|
|
33
|
-
]);
|
|
37
|
+
}, [externalWindow, scrollContainerStateCallback, smoothScrollTargetReached]);
|
|
34
38
|
useEffect(function () {
|
|
35
|
-
var localRef =
|
|
36
|
-
|
|
39
|
+
var localRef = customScrollParent
|
|
40
|
+
? customScrollParent
|
|
41
|
+
: scrollerRef.current;
|
|
42
|
+
scrollerRefCallback(customScrollParent ? customScrollParent : scrollerRef.current);
|
|
37
43
|
handler({ target: localRef });
|
|
38
44
|
localRef.addEventListener('scroll', handler, { passive: true });
|
|
39
45
|
return function () {
|
|
40
46
|
scrollerRefCallback(null);
|
|
41
47
|
localRef.removeEventListener('scroll', handler);
|
|
42
48
|
};
|
|
43
|
-
}, [
|
|
49
|
+
}, [
|
|
50
|
+
scrollerRef,
|
|
51
|
+
handler,
|
|
52
|
+
scrollerElement,
|
|
53
|
+
scrollerRefCallback,
|
|
54
|
+
customScrollParent,
|
|
55
|
+
]);
|
|
44
56
|
function scrollToCallback(location) {
|
|
45
57
|
var scrollerElement = scrollerRef.current;
|
|
46
|
-
if (!scrollerElement
|
|
58
|
+
if (!scrollerElement ||
|
|
59
|
+
('offsetHeight' in scrollerElement && scrollerElement.offsetHeight === 0)) {
|
|
47
60
|
return;
|
|
48
61
|
}
|
|
49
62
|
var isSmooth = location.behavior === 'smooth';
|
|
50
63
|
var offsetHeight;
|
|
51
64
|
var scrollHeight;
|
|
52
65
|
var scrollTop;
|
|
53
|
-
if (scrollerElement ===
|
|
66
|
+
if (scrollerElement === externalWindow) {
|
|
54
67
|
// this is not a mistake
|
|
55
|
-
scrollHeight = Math.max(
|
|
56
|
-
offsetHeight =
|
|
57
|
-
scrollTop =
|
|
68
|
+
scrollHeight = Math.max(correctItemSize(externalWindow.document.documentElement, 'height'), externalWindow.document.documentElement.scrollHeight);
|
|
69
|
+
offsetHeight = externalWindow.window.innerHeight;
|
|
70
|
+
scrollTop = externalWindow.document.documentElement.scrollTop;
|
|
58
71
|
}
|
|
59
72
|
else {
|
|
60
73
|
scrollHeight = scrollerElement.scrollHeight;
|
|
61
|
-
offsetHeight = scrollerElement
|
|
74
|
+
offsetHeight = correctItemSize(scrollerElement, 'height');
|
|
62
75
|
scrollTop = scrollerElement.scrollTop;
|
|
63
76
|
}
|
|
77
|
+
var maxScrollTop = scrollHeight - offsetHeight;
|
|
78
|
+
location.top = Math.ceil(Math.max(Math.min(maxScrollTop, location.top), 0));
|
|
64
79
|
// avoid system hanging because the DOM never called back
|
|
65
80
|
// with the scrollTop
|
|
66
81
|
// scroller is already at this location
|
|
67
|
-
if (offsetHeight
|
|
68
|
-
|
|
82
|
+
if (approximatelyEqual(offsetHeight, scrollHeight) ||
|
|
83
|
+
location.top === scrollTop) {
|
|
84
|
+
scrollContainerStateCallback([scrollTop, scrollHeight]);
|
|
69
85
|
if (isSmooth) {
|
|
70
86
|
smoothScrollTargetReached(true);
|
|
71
87
|
}
|
|
72
88
|
return;
|
|
73
89
|
}
|
|
74
|
-
var maxScrollTop = scrollHeight - offsetHeight;
|
|
75
|
-
location.top = Math.max(Math.min(maxScrollTop, location.top), 0);
|
|
76
90
|
if (isSmooth) {
|
|
77
91
|
scrollTopTarget.current = location.top;
|
|
78
92
|
if (timeoutRef.current) {
|
|
@@ -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 });
|