@ringcentral/juno 2.40.1 → 2.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Downshift/SuggestionList/SuggestionList.d.ts +3 -3
- package/components/Downshift/utils/useDownshift.d.ts +1 -1
- package/components/Virtuoso/index.d.ts +1 -1
- package/components/Virtuoso/index.js +1 -1
- package/components/Virtuoso/react-virtuoso/AATree.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/AATree.js +60 -48
- package/components/Virtuoso/react-virtuoso/TableVirtuoso.d.ts +5 -0
- package/components/Virtuoso/react-virtuoso/TableVirtuoso.js +217 -0
- package/components/Virtuoso/react-virtuoso/Virtuoso.d.ts +7696 -0
- package/components/Virtuoso/react-virtuoso/Virtuoso.js +317 -0
- package/components/Virtuoso/react-virtuoso/{Grid.d.ts → VirtuosoGrid.d.ts} +170 -72
- package/components/Virtuoso/react-virtuoso/VirtuosoGrid.js +199 -0
- package/components/Virtuoso/react-virtuoso/alignToBottomSystem.d.ts +119 -65
- package/components/Virtuoso/react-virtuoso/alignToBottomSystem.js +3 -3
- package/components/Virtuoso/react-virtuoso/comparators.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/comparators.js +1 -3
- package/components/Virtuoso/react-virtuoso/component-interfaces/TableVirtuoso.d.ts +194 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/TableVirtuoso.js +2 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/Virtuoso.d.ts +274 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/Virtuoso.js +2 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/VirtuosoGrid.d.ts +125 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/VirtuosoGrid.js +2 -0
- package/components/Virtuoso/react-virtuoso/domIOSystem.d.ts +3 -2
- package/components/Virtuoso/react-virtuoso/domIOSystem.js +5 -3
- package/components/Virtuoso/react-virtuoso/followOutputSystem.d.ts +80 -43
- package/components/Virtuoso/react-virtuoso/followOutputSystem.js +21 -19
- package/components/Virtuoso/react-virtuoso/gridSystem.d.ts +57 -31
- package/components/Virtuoso/react-virtuoso/gridSystem.js +173 -86
- package/components/Virtuoso/react-virtuoso/groupedListSystem.d.ts +76 -67
- package/components/Virtuoso/react-virtuoso/groupedListSystem.js +12 -12
- package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.d.ts +6 -3
- package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +36 -17
- package/components/Virtuoso/react-virtuoso/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/components/Virtuoso/react-virtuoso/hooks/useIsomorphicLayoutEffect.js +3 -2
- package/components/Virtuoso/react-virtuoso/hooks/useRcPortalWindowContext.d.ts +2 -0
- package/components/Virtuoso/react-virtuoso/hooks/useRcPortalWindowContext.js +5 -0
- package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.d.ts +2 -3
- package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +36 -51
- package/components/Virtuoso/react-virtuoso/hooks/useSize.d.ts +2 -3
- package/components/Virtuoso/react-virtuoso/hooks/useSize.js +13 -13
- package/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +17 -15
- package/components/Virtuoso/react-virtuoso/index.d.ts +7 -1
- package/components/Virtuoso/react-virtuoso/index.js +8 -1
- package/components/Virtuoso/react-virtuoso/initialItemCountSystem.d.ts +304 -68
- package/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +9 -31
- package/components/Virtuoso/react-virtuoso/initialScrollTopSystem.d.ts +127 -109
- package/components/Virtuoso/react-virtuoso/initialScrollTopSystem.js +7 -7
- package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.d.ts +38 -22
- package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +13 -20
- package/components/Virtuoso/react-virtuoso/interfaces.d.ts +150 -51
- package/components/Virtuoso/react-virtuoso/listStateSystem.d.ts +109 -59
- package/components/Virtuoso/react-virtuoso/listStateSystem.js +100 -52
- package/components/Virtuoso/react-virtuoso/listSystem.d.ts +1691 -693
- package/components/Virtuoso/react-virtuoso/listSystem.js +15 -16
- package/components/Virtuoso/react-virtuoso/loggerSystem.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/loggerSystem.js +2 -4
- package/components/Virtuoso/react-virtuoso/propsReadySystem.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/propsReadySystem.js +3 -4
- package/components/Virtuoso/react-virtuoso/react-urx/index.d.ts +110 -0
- package/components/Virtuoso/react-virtuoso/react-urx/index.js +200 -0
- package/components/Virtuoso/react-virtuoso/react-urx/package.json +5 -0
- package/components/Virtuoso/react-virtuoso/recalcSystem.d.ts +4 -0
- package/components/Virtuoso/react-virtuoso/recalcSystem.js +8 -0
- package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.d.ts +144 -78
- package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +33 -21
- package/components/Virtuoso/react-virtuoso/scrollSeekSystem.d.ts +12 -7
- package/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +7 -10
- package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.d.ts +19 -11
- package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +11 -23
- package/components/Virtuoso/react-virtuoso/sizeRangeSystem.d.ts +7 -6
- package/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +15 -27
- package/components/Virtuoso/react-virtuoso/sizeSystem.d.ts +20 -11
- package/components/Virtuoso/react-virtuoso/sizeSystem.js +182 -52
- package/components/Virtuoso/react-virtuoso/stateFlagsSystem.d.ts +8 -5
- package/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +32 -23
- package/components/Virtuoso/react-virtuoso/stateLoadSystem.d.ts +318 -0
- package/components/Virtuoso/react-virtuoso/stateLoadSystem.js +41 -0
- package/components/Virtuoso/react-virtuoso/topItemCountSystem.d.ts +518 -467
- package/components/Virtuoso/react-virtuoso/topItemCountSystem.js +5 -5
- package/components/Virtuoso/react-virtuoso/totalListHeightSystem.d.ts +115 -63
- package/components/Virtuoso/react-virtuoso/totalListHeightSystem.js +6 -13
- package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.d.ts +139 -73
- package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +74 -31
- package/components/Virtuoso/react-virtuoso/urx/actions.d.ts +127 -0
- package/components/Virtuoso/react-virtuoso/urx/actions.js +98 -0
- package/components/Virtuoso/react-virtuoso/urx/constants.d.ts +8 -0
- package/components/Virtuoso/react-virtuoso/urx/constants.js +6 -0
- package/components/Virtuoso/react-virtuoso/urx/index.d.ts +6 -0
- package/components/Virtuoso/react-virtuoso/urx/index.js +9 -0
- package/components/Virtuoso/react-virtuoso/urx/package.json +5 -0
- package/components/Virtuoso/react-virtuoso/urx/pipe.d.ts +220 -0
- package/components/Virtuoso/react-virtuoso/urx/pipe.js +279 -0
- package/components/Virtuoso/react-virtuoso/urx/streams.d.ts +143 -0
- package/components/Virtuoso/react-virtuoso/urx/streams.js +227 -0
- package/components/Virtuoso/react-virtuoso/urx/system.d.ts +148 -0
- package/components/Virtuoso/react-virtuoso/urx/system.js +106 -0
- package/components/Virtuoso/react-virtuoso/urx/transformers.d.ts +71 -0
- package/components/Virtuoso/react-virtuoso/urx/transformers.js +106 -0
- package/components/Virtuoso/react-virtuoso/urx/utils.d.ts +57 -0
- package/components/Virtuoso/react-virtuoso/urx/utils.js +102 -0
- package/components/Virtuoso/react-virtuoso/utils/approximatelyEqual.d.ts +1 -0
- package/components/Virtuoso/react-virtuoso/utils/approximatelyEqual.js +6 -0
- package/components/Virtuoso/react-virtuoso/utils/context.d.ts +13 -0
- package/components/Virtuoso/react-virtuoso/utils/context.js +6 -0
- package/components/Virtuoso/react-virtuoso/utils/skipFrames.d.ts +1 -0
- package/components/Virtuoso/react-virtuoso/utils/skipFrames.js +11 -0
- package/components/Virtuoso/react-virtuoso/windowScrollerSystem.d.ts +6 -4
- package/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +1 -1
- package/components/Virtuoso/utils/isOutOfRange.d.ts +1 -1
- package/components/Virtuoso/utils/useHighlightScroll.d.ts +2 -2
- package/es6/components/Virtuoso/index.js +1 -1
- package/es6/components/Virtuoso/react-virtuoso/AATree.js +60 -48
- package/es6/components/Virtuoso/react-virtuoso/{Table.js → TableVirtuoso.js} +73 -52
- package/es6/components/Virtuoso/react-virtuoso/{List.js → Virtuoso.js} +85 -161
- package/es6/components/Virtuoso/react-virtuoso/VirtuosoGrid.js +198 -0
- package/es6/components/Virtuoso/react-virtuoso/alignToBottomSystem.js +3 -3
- package/es6/components/Virtuoso/react-virtuoso/comparators.js +1 -3
- package/es6/components/Virtuoso/react-virtuoso/component-interfaces/TableVirtuoso.js +0 -0
- package/es6/components/Virtuoso/react-virtuoso/component-interfaces/Virtuoso.js +0 -0
- package/es6/components/Virtuoso/react-virtuoso/component-interfaces/VirtuosoGrid.js +0 -0
- package/es6/components/Virtuoso/react-virtuoso/domIOSystem.js +5 -3
- package/es6/components/Virtuoso/react-virtuoso/followOutputSystem.js +21 -19
- package/es6/components/Virtuoso/react-virtuoso/gridSystem.js +173 -87
- package/es6/components/Virtuoso/react-virtuoso/groupedListSystem.js +13 -13
- package/es6/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +35 -16
- package/es6/components/Virtuoso/react-virtuoso/hooks/useIsomorphicLayoutEffect.js +2 -2
- package/es6/components/Virtuoso/react-virtuoso/hooks/useRcPortalWindowContext.js +2 -0
- package/es6/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +35 -50
- package/es6/components/Virtuoso/react-virtuoso/hooks/useSize.js +11 -12
- package/es6/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +15 -14
- package/es6/components/Virtuoso/react-virtuoso/index.js +4 -1
- package/es6/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +11 -33
- package/es6/components/Virtuoso/react-virtuoso/initialScrollTopSystem.js +7 -7
- package/es6/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +13 -20
- package/es6/components/Virtuoso/react-virtuoso/listStateSystem.js +101 -54
- package/es6/components/Virtuoso/react-virtuoso/listSystem.js +15 -16
- package/es6/components/Virtuoso/react-virtuoso/loggerSystem.js +2 -4
- package/es6/components/Virtuoso/react-virtuoso/propsReadySystem.js +3 -4
- package/es6/components/Virtuoso/react-virtuoso/react-urx/index.js +197 -0
- package/es6/components/Virtuoso/react-virtuoso/recalcSystem.js +5 -0
- package/es6/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +34 -22
- package/es6/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +7 -10
- package/es6/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +11 -23
- package/es6/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +16 -28
- package/es6/components/Virtuoso/react-virtuoso/sizeSystem.js +180 -53
- package/es6/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +32 -23
- package/es6/components/Virtuoso/react-virtuoso/stateLoadSystem.js +39 -0
- package/es6/components/Virtuoso/react-virtuoso/topItemCountSystem.js +5 -5
- package/es6/components/Virtuoso/react-virtuoso/totalListHeightSystem.js +6 -13
- package/es6/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +75 -32
- package/es6/components/Virtuoso/react-virtuoso/urx/actions.js +90 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/constants.js +4 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/index.js +6 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/pipe.js +266 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/streams.js +220 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/system.js +102 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/transformers.js +101 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/utils.js +88 -0
- package/es6/components/Virtuoso/react-virtuoso/utils/approximatelyEqual.js +3 -0
- package/es6/components/Virtuoso/react-virtuoso/utils/context.js +3 -0
- package/es6/components/Virtuoso/react-virtuoso/utils/skipFrames.js +8 -0
- package/es6/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +1 -1
- package/package.json +2 -2
- package/components/Virtuoso/Virtuoso.d.ts +0 -1
- package/components/Virtuoso/Virtuoso.js +0 -4
- package/components/Virtuoso/react-virtuoso/Grid.js +0 -168
- package/components/Virtuoso/react-virtuoso/List.d.ts +0 -6749
- package/components/Virtuoso/react-virtuoso/List.js +0 -393
- package/components/Virtuoso/react-virtuoso/Table.d.ts +0 -6515
- package/components/Virtuoso/react-virtuoso/Table.js +0 -196
- package/components/Virtuoso/react-virtuoso/components.d.ts +0 -505
- package/components/Virtuoso/react-virtuoso/components.js +0 -9
- package/components/Virtuoso/react-virtuoso/utils/conditionalFlushSync.d.ts +0 -1
- package/components/Virtuoso/react-virtuoso/utils/conditionalFlushSync.js +0 -11
- package/es6/components/Virtuoso/Virtuoso.js +0 -1
- package/es6/components/Virtuoso/react-virtuoso/Grid.js +0 -166
- package/es6/components/Virtuoso/react-virtuoso/components.js +0 -7
- package/es6/components/Virtuoso/react-virtuoso/utils/conditionalFlushSync.js +0 -8
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
import { __read } from "tslib";
|
|
2
|
-
import * as u from '
|
|
2
|
+
import * as u from './urx';
|
|
3
3
|
import { domIOSystem } from './domIOSystem';
|
|
4
4
|
import { listStateSystem } from './listStateSystem';
|
|
5
|
-
import { loggerSystem, LogLevel } from './loggerSystem';
|
|
6
5
|
import { sizeSystem } from './sizeSystem';
|
|
7
|
-
import {
|
|
6
|
+
import { UP, stateFlagsSystem } from './stateFlagsSystem';
|
|
7
|
+
import { loggerSystem, LogLevel } from './loggerSystem';
|
|
8
|
+
import { simpleMemoize } from './utils/simpleMemoize';
|
|
9
|
+
import { recalcSystem } from './recalcSystem';
|
|
10
|
+
import { find } from './AATree';
|
|
11
|
+
var isMobileSafari = simpleMemoize(function () {
|
|
12
|
+
return /iP(ad|od|hone)/i.test(navigator.userAgent) && /WebKit/i.test(navigator.userAgent);
|
|
13
|
+
});
|
|
8
14
|
/**
|
|
9
15
|
* Fixes upward scrolling by calculating and compensation from changed item heights, using scrollBy.
|
|
10
16
|
*/
|
|
11
17
|
export var upwardScrollFixSystem = u.system(function (_a) {
|
|
12
|
-
var _b = __read(_a,
|
|
18
|
+
var _b = __read(_a, 6), _c = _b[0], scrollBy = _c.scrollBy, scrollTop = _c.scrollTop, deviation = _c.deviation, scrollingInProgress = _c.scrollingInProgress, _d = _b[1], isScrolling = _d.isScrolling, isAtBottom = _d.isAtBottom, scrollDirection = _d.scrollDirection, lastJumpDueToItemResize = _d.lastJumpDueToItemResize, listState = _b[2].listState, _e = _b[3], beforeUnshiftWith = _e.beforeUnshiftWith, shiftWithOffset = _e.shiftWithOffset, sizes = _e.sizes, gap = _e.gap, log = _b[4].log, recalcInProgress = _b[5].recalcInProgress;
|
|
13
19
|
var deviationOffset = u.streamFromEmitter(u.pipe(listState, u.withLatestFrom(lastJumpDueToItemResize), u.scan(function (_a, _b) {
|
|
14
20
|
var _c = __read(_a, 4), prevItems = _c[1], prevTotalCount = _c[2], prevTotalHeight = _c[3];
|
|
15
|
-
var _d = __read(_b, 2),
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
_e = _d[0], items = _e.items, totalCount = _e.totalCount, bottom = _e.bottom, offsetBottom = _e.offsetBottom, lastJumpDueToItemResize = _d[1];
|
|
21
|
+
var _d = __read(_b, 2), _e = _d[0], items = _e.items, totalCount = _e.totalCount, bottom = _e.bottom, offsetBottom = _e.offsetBottom, lastJumpDueToItemResize = _d[1];
|
|
18
22
|
var totalHeight = bottom + offsetBottom;
|
|
19
23
|
var newDev = 0;
|
|
20
24
|
if (prevTotalCount === totalCount) {
|
|
21
25
|
if (prevItems.length > 0 && items.length > 0) {
|
|
22
|
-
var atStart = items[0].originalIndex === 0 &&
|
|
23
|
-
prevItems[0].originalIndex === 0;
|
|
26
|
+
var atStart = items[0].originalIndex === 0 && prevItems[0].originalIndex === 0;
|
|
24
27
|
if (!atStart) {
|
|
25
28
|
newDev = totalHeight - prevTotalHeight;
|
|
26
29
|
if (newDev !== 0) {
|
|
@@ -33,28 +36,15 @@ export var upwardScrollFixSystem = u.system(function (_a) {
|
|
|
33
36
|
}, [0, [], 0, 0]), u.filter(function (_a) {
|
|
34
37
|
var _b = __read(_a, 1), amount = _b[0];
|
|
35
38
|
return amount !== 0;
|
|
36
|
-
}), u.withLatestFrom(scrollTop, scrollDirection, scrollingInProgress,
|
|
37
|
-
var _b = __read(_a,
|
|
38
|
-
|
|
39
|
-
return (!scrollingInProgress && scrollTop !== 0 && scrollDirection === UP); // && (isAtBottom ? amount > 0 : true)
|
|
39
|
+
}), u.withLatestFrom(scrollTop, scrollDirection, scrollingInProgress, isAtBottom, log, recalcInProgress), u.filter(function (_a) {
|
|
40
|
+
var _b = __read(_a, 7), scrollTop = _b[1], scrollDirection = _b[2], scrollingInProgress = _b[3], recalcInProgress = _b[6];
|
|
41
|
+
return !recalcInProgress && !scrollingInProgress && scrollTop !== 0 && scrollDirection === UP;
|
|
40
42
|
}), u.map(function (_a) {
|
|
41
|
-
var _b = __read(_a,
|
|
43
|
+
var _b = __read(_a, 6), _c = __read(_b[0], 1), amount = _c[0], log = _b[5];
|
|
42
44
|
log('Upward scrolling compensation', { amount: amount }, LogLevel.DEBUG);
|
|
43
45
|
return amount;
|
|
44
46
|
})));
|
|
45
|
-
|
|
46
|
-
var _b = __read(_a, 2), amount = _b[0], deviation = _b[1];
|
|
47
|
-
return deviation - amount;
|
|
48
|
-
})), deviation);
|
|
49
|
-
// when the browser stops scrolling,
|
|
50
|
-
// restore the position and reset the glitching
|
|
51
|
-
u.subscribe(u.pipe(u.combineLatest(u.statefulStreamFromEmitter(isScrolling, false), deviation), u.filter(function (_a) {
|
|
52
|
-
var _b = __read(_a, 2), is = _b[0], deviation = _b[1];
|
|
53
|
-
return !is && deviation !== 0;
|
|
54
|
-
}), u.map(function (_a) {
|
|
55
|
-
var _b = __read(_a, 2), deviation = _b[1];
|
|
56
|
-
return deviation;
|
|
57
|
-
}), u.throttleTime(1)), function (offset) {
|
|
47
|
+
function scrollByWith(offset) {
|
|
58
48
|
if (offset > 0) {
|
|
59
49
|
u.publish(scrollBy, { top: -offset, behavior: 'auto' });
|
|
60
50
|
u.publish(deviation, 0);
|
|
@@ -63,13 +53,66 @@ export var upwardScrollFixSystem = u.system(function (_a) {
|
|
|
63
53
|
u.publish(deviation, 0);
|
|
64
54
|
u.publish(scrollBy, { top: -offset, behavior: 'auto' });
|
|
65
55
|
}
|
|
56
|
+
}
|
|
57
|
+
u.subscribe(u.pipe(deviationOffset, u.withLatestFrom(deviation, isScrolling)), function (_a) {
|
|
58
|
+
var _b = __read(_a, 3), offset = _b[0], deviationAmount = _b[1], isScrolling = _b[2];
|
|
59
|
+
if (isScrolling && isMobileSafari()) {
|
|
60
|
+
u.publish(deviation, deviationAmount - offset);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
scrollByWith(-offset);
|
|
64
|
+
}
|
|
66
65
|
});
|
|
66
|
+
// this hack is only necessary for mobile safari which does not support scrollBy while scrolling is in progress.
|
|
67
|
+
// when the browser stops scrolling, restore the position and reset the glitching
|
|
68
|
+
u.subscribe(u.pipe(u.combineLatest(u.statefulStreamFromEmitter(isScrolling, false), deviation, recalcInProgress), u.filter(function (_a) {
|
|
69
|
+
var _b = __read(_a, 3), is = _b[0], deviation = _b[1], recalc = _b[2];
|
|
70
|
+
return !is && !recalc && deviation !== 0;
|
|
71
|
+
}), u.map(function (_a) {
|
|
72
|
+
var _b = __read(_a, 2), _ = _b[0], deviation = _b[1];
|
|
73
|
+
return deviation;
|
|
74
|
+
}), u.throttleTime(1)), scrollByWith);
|
|
67
75
|
u.connect(u.pipe(shiftWithOffset, u.map(function (offset) {
|
|
68
76
|
return { top: -offset };
|
|
69
77
|
})), scrollBy);
|
|
70
|
-
u.
|
|
71
|
-
var _b = __read(_a,
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
u.subscribe(u.pipe(beforeUnshiftWith, u.withLatestFrom(sizes, gap), u.map(function (_a) {
|
|
79
|
+
var _b = __read(_a, 3), offset = _b[0], _c = _b[1], defaultItemSize = _c.lastSize, groupIndices = _c.groupIndices, sizeTree = _c.sizeTree, gap = _b[2];
|
|
80
|
+
function getItemOffset(itemCount) {
|
|
81
|
+
return itemCount * (defaultItemSize + gap);
|
|
82
|
+
}
|
|
83
|
+
if (groupIndices.length === 0) {
|
|
84
|
+
return getItemOffset(offset);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
var amount = 0;
|
|
88
|
+
var defaultGroupSize = find(sizeTree, 0);
|
|
89
|
+
var recognizedOffsetItems = 0;
|
|
90
|
+
var groupIndex = 0;
|
|
91
|
+
while (recognizedOffsetItems < offset) {
|
|
92
|
+
// increase once for the group itself
|
|
93
|
+
recognizedOffsetItems++;
|
|
94
|
+
amount += defaultGroupSize;
|
|
95
|
+
var groupItemCount = groupIndices.length === groupIndex + 1 ? Infinity : groupIndices[groupIndex + 1] - groupIndices[groupIndex] - 1;
|
|
96
|
+
// if the group is larger than the offset, we have an expanded group. remove the group size, and replace with 1 item.
|
|
97
|
+
if (recognizedOffsetItems + groupItemCount > offset) {
|
|
98
|
+
amount -= defaultGroupSize;
|
|
99
|
+
groupItemCount = offset - recognizedOffsetItems + 1;
|
|
100
|
+
}
|
|
101
|
+
recognizedOffsetItems += groupItemCount;
|
|
102
|
+
amount += getItemOffset(groupItemCount);
|
|
103
|
+
groupIndex++;
|
|
104
|
+
}
|
|
105
|
+
return amount;
|
|
106
|
+
}
|
|
107
|
+
})), function (offset) {
|
|
108
|
+
u.publish(deviation, offset);
|
|
109
|
+
requestAnimationFrame(function () {
|
|
110
|
+
u.publish(scrollBy, { top: offset });
|
|
111
|
+
requestAnimationFrame(function () {
|
|
112
|
+
u.publish(deviation, 0);
|
|
113
|
+
u.publish(recalcInProgress, false);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
});
|
|
74
117
|
return { deviation: deviation };
|
|
75
|
-
}, u.tup(domIOSystem, stateFlagsSystem, listStateSystem, sizeSystem, loggerSystem));
|
|
118
|
+
}, u.tup(domIOSystem, stateFlagsSystem, listStateSystem, sizeSystem, loggerSystem, recalcSystem));
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* urx Actions operate on streams - `publish` publishes data in a stream, and `subscribe` attaches a subscription to a stream.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
import { PUBLISH, RESET, SUBSCRIBE, VALUE } from './constants';
|
|
6
|
+
import { curry2to1 } from './utils';
|
|
7
|
+
/**
|
|
8
|
+
* Subscribes the specified [[Subscription]] to the updates from the Emitter.
|
|
9
|
+
* The emitter calls the subscription with the new data each time new data is published into it.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const foo = stream<number>();
|
|
13
|
+
* subscribe(foo, (value) => console.log(value));
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @returns an [[Unsubscribe]] handle - calling it will unbind the subscription from the emitter.
|
|
17
|
+
*```ts
|
|
18
|
+
* const foo = stream<number>();
|
|
19
|
+
* const unsub = subscribe(foo, (value) => console.log(value));
|
|
20
|
+
* unsub();
|
|
21
|
+
*```
|
|
22
|
+
*/
|
|
23
|
+
export function subscribe(emitter, subscription) {
|
|
24
|
+
return emitter(SUBSCRIBE, subscription);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Publishes the value into the passed [[Publisher]].
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* const foo = stream<number>();
|
|
31
|
+
* publish(foo, 42);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export function publish(publisher, value) {
|
|
35
|
+
publisher(PUBLISH, value);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Clears all subscriptions from the [[Emitter]].
|
|
39
|
+
* ```ts
|
|
40
|
+
* const foo = stream<number>();
|
|
41
|
+
* subscribe(foo, (value) => console.log(value));
|
|
42
|
+
* reset(foo);
|
|
43
|
+
* publish(foo, 42);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export function reset(emitter) {
|
|
47
|
+
emitter(RESET);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Extracts the current value from a stateful stream. Use it only as an escape hatch, as it violates the concept of reactive programming.
|
|
51
|
+
* ```ts
|
|
52
|
+
* const foo = statefulStream(42);
|
|
53
|
+
* console.log(getValue(foo));
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export function getValue(depot) {
|
|
57
|
+
return depot(VALUE);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Connects two streams - any value emitted from the emitter will be published in the publisher.
|
|
61
|
+
* ```ts
|
|
62
|
+
* const foo = stream<number>();
|
|
63
|
+
* const bar = stream<number>();
|
|
64
|
+
* subscribe(bar, (value) => console.log(`Bar emitted ${value}`));
|
|
65
|
+
*
|
|
66
|
+
* connect(foo, bar);
|
|
67
|
+
* publish(foo);
|
|
68
|
+
* ```
|
|
69
|
+
* @returns an [[Unsubscribe]] handle which will disconnect the two streams.
|
|
70
|
+
*/
|
|
71
|
+
export function connect(emitter, publisher) {
|
|
72
|
+
return subscribe(emitter, curry2to1(publisher, PUBLISH));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Executes the passed subscription at most once, for the next emit from the emitter.
|
|
76
|
+
* ```ts
|
|
77
|
+
* const foo = stream<number>()
|
|
78
|
+
* handleNext(foo, value => console.log(value)) // called once, with 42
|
|
79
|
+
* publish(foo, 42)
|
|
80
|
+
* publish(foo, 43)
|
|
81
|
+
* ```
|
|
82
|
+
* @returns an [[Unsubscribe]] handle to unbind the subscription if necessary.
|
|
83
|
+
*/
|
|
84
|
+
export function handleNext(emitter, subscription) {
|
|
85
|
+
var unsub = emitter(SUBSCRIBE, function (value) {
|
|
86
|
+
unsub();
|
|
87
|
+
subscription(value);
|
|
88
|
+
});
|
|
89
|
+
return unsub;
|
|
90
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { __read, __spread } from "tslib";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Stream values can be transformed and controlled by {@link pipe | **piping**} through **operators**.
|
|
5
|
+
* urx includes several operators like [[map]], [[filter]], [[scan]], and [[throttleTime]].
|
|
6
|
+
* The [[withLatestFrom]] operator allows the combination of values from other streams.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const foo = stream<number>()
|
|
10
|
+
*
|
|
11
|
+
* // create an emitter that first adds 2 to the passed value, then multiplies it by * 2
|
|
12
|
+
* const bar = pipe(foo, map(value => value + 2), map(value => value * 2))
|
|
13
|
+
* subscribe(bar, value => console.log(value))
|
|
14
|
+
* publish(foo, 2) // outputs 8
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ### Implementing Custom Operators
|
|
18
|
+
* To implement your own operators, implement the [[Operator]] interface.
|
|
19
|
+
* @packageDocumentation
|
|
20
|
+
*/
|
|
21
|
+
import { compose, thrush } from './utils';
|
|
22
|
+
import { subscribe, reset } from './actions';
|
|
23
|
+
import { SUBSCRIBE, RESET } from './constants';
|
|
24
|
+
/** @internal */
|
|
25
|
+
function combineOperators() {
|
|
26
|
+
var operators = [];
|
|
27
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
28
|
+
operators[_i] = arguments[_i];
|
|
29
|
+
}
|
|
30
|
+
return function (subscriber) {
|
|
31
|
+
return operators.reduceRight(thrush, subscriber);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function pipe(source) {
|
|
35
|
+
var operators = [];
|
|
36
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
37
|
+
operators[_i - 1] = arguments[_i];
|
|
38
|
+
}
|
|
39
|
+
// prettier-ignore
|
|
40
|
+
var project = combineOperators.apply(void 0, __spread(operators));
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
42
|
+
return (function (action, subscription) {
|
|
43
|
+
switch (action) {
|
|
44
|
+
case SUBSCRIBE:
|
|
45
|
+
return subscribe(source, project(subscription));
|
|
46
|
+
case RESET:
|
|
47
|
+
reset(source);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The default [[Comparator]] for [[distinctUntilChanged]] and [[duc]].
|
|
54
|
+
*/
|
|
55
|
+
export function defaultComparator(previous, next) {
|
|
56
|
+
return previous === next;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Filters out identical values. Pass an optional [[Comparator]] if you need to filter non-primitive values.
|
|
60
|
+
* ```ts
|
|
61
|
+
* const foo = stream<number>()
|
|
62
|
+
*
|
|
63
|
+
* subscribe(
|
|
64
|
+
* pipe(foo, distinctUntilChanged()),
|
|
65
|
+
* console.log
|
|
66
|
+
* ) // will be called only once
|
|
67
|
+
*
|
|
68
|
+
* publish(foo, 42)
|
|
69
|
+
* publish(foo, 42)
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export function distinctUntilChanged(comparator) {
|
|
73
|
+
if (comparator === void 0) { comparator = defaultComparator; }
|
|
74
|
+
var current;
|
|
75
|
+
return function (done) { return function (next) {
|
|
76
|
+
if (!comparator(current, next)) {
|
|
77
|
+
current = next;
|
|
78
|
+
done(next);
|
|
79
|
+
}
|
|
80
|
+
}; };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Filters out values for which the predicator does not return `true`-ish.
|
|
84
|
+
* ```ts
|
|
85
|
+
* const foo = stream<number>()
|
|
86
|
+
*
|
|
87
|
+
* subscribe(
|
|
88
|
+
* pipe(foo, filter(value => value % 2 === 0)),
|
|
89
|
+
* console.log
|
|
90
|
+
* ) // will be called only with even values
|
|
91
|
+
*
|
|
92
|
+
* publish(foo, 2)
|
|
93
|
+
* publish(foo, 3)
|
|
94
|
+
* publish(foo, 4)
|
|
95
|
+
* publish(foo, 5)
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export function filter(predicate) {
|
|
99
|
+
return function (done) { return function (value) {
|
|
100
|
+
predicate(value) && done(value);
|
|
101
|
+
}; };
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Maps values using the provided project function.
|
|
105
|
+
* ```ts
|
|
106
|
+
* const foo = stream<number>()
|
|
107
|
+
*
|
|
108
|
+
* subscribe(
|
|
109
|
+
* pipe(foo, map(value => value * 2)),
|
|
110
|
+
* console.log
|
|
111
|
+
* ) // 4, 6
|
|
112
|
+
*
|
|
113
|
+
* publish(foo, 2)
|
|
114
|
+
* publish(foo, 3)
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export function map(project) {
|
|
118
|
+
return function (done) { return compose(done, project); };
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Maps values to the hard-coded value.
|
|
122
|
+
* ```ts
|
|
123
|
+
* const foo = stream<number>()
|
|
124
|
+
*
|
|
125
|
+
* subscribe(
|
|
126
|
+
* pipe(foo, mapTo(3)),
|
|
127
|
+
* console.log
|
|
128
|
+
* ) // 3, 3
|
|
129
|
+
*
|
|
130
|
+
* publish(foo, 1)
|
|
131
|
+
* publish(foo, 2)
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export function mapTo(value) {
|
|
135
|
+
return function (done) { return function () { return done(value); }; };
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Works like Array#reduce.
|
|
139
|
+
* Applies an accumulator function on the emitter, and outputs intermediate result. Starts with the initial value.
|
|
140
|
+
* ```ts
|
|
141
|
+
* const foo = stream<number>()
|
|
142
|
+
*
|
|
143
|
+
* subscribe(
|
|
144
|
+
* pipe(foo, scan((acc, value) => acc + value, 2),
|
|
145
|
+
* console.log
|
|
146
|
+
* ) // 3, 5
|
|
147
|
+
*
|
|
148
|
+
* publish(foo, 1)
|
|
149
|
+
* publish(foo, 2)
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export function scan(scanner, initial) {
|
|
153
|
+
return function (done) { return function (value) { return done((initial = scanner(initial, value))); }; };
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Skips the specified amount of values from the emitter.
|
|
157
|
+
* ```ts
|
|
158
|
+
* const foo = stream<number>()
|
|
159
|
+
*
|
|
160
|
+
* subscribe(
|
|
161
|
+
* pipe(foo, skip(2)),
|
|
162
|
+
* console.log
|
|
163
|
+
* ) // 3, 4
|
|
164
|
+
*
|
|
165
|
+
* publish(foo, 1) // skipped
|
|
166
|
+
* publish(foo, 2) // skipped
|
|
167
|
+
* publish(foo, 3)
|
|
168
|
+
* publish(foo, 4)
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export function skip(times) {
|
|
172
|
+
return function (done) { return function (value) {
|
|
173
|
+
times > 0 ? times-- : done(value);
|
|
174
|
+
}; };
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Throttles flowing values at the provided interval in milliseconds.
|
|
178
|
+
* [Throttle VS Debounce in SO](https://stackoverflow.com/questions/25991367/difference-between-throttling-and-debouncing-a-function).
|
|
179
|
+
*
|
|
180
|
+
* ```ts
|
|
181
|
+
* const foo = stream<number>()
|
|
182
|
+
* publish(foo, 1)
|
|
183
|
+
*
|
|
184
|
+
* setTimeout(() => publish(foo, 2), 20)
|
|
185
|
+
* setTimeout(() => publish(foo, 3), 20)
|
|
186
|
+
*
|
|
187
|
+
* subscribe(pipe(foo, throttleTime(50)), val => {
|
|
188
|
+
* console.log(value); // 3
|
|
189
|
+
* })
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
export function throttleTime(interval) {
|
|
193
|
+
var currentValue = null;
|
|
194
|
+
var timeout;
|
|
195
|
+
return function (done) { return function (value) {
|
|
196
|
+
currentValue = value;
|
|
197
|
+
if (timeout) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
timeout = setTimeout(function () {
|
|
201
|
+
timeout = undefined;
|
|
202
|
+
done(currentValue);
|
|
203
|
+
}, interval);
|
|
204
|
+
}; };
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Debounces flowing values at the provided interval in milliseconds.
|
|
208
|
+
* [Throttle VS Debounce in SO](https://stackoverflow.com/questions/25991367/difference-between-throttling-and-debouncing-a-function).
|
|
209
|
+
*
|
|
210
|
+
* ```ts
|
|
211
|
+
* const foo = stream<number>()
|
|
212
|
+
* publish(foo, 1)
|
|
213
|
+
*
|
|
214
|
+
* setTimeout(() => publish(foo, 2), 20)
|
|
215
|
+
* setTimeout(() => publish(foo, 3), 20)
|
|
216
|
+
*
|
|
217
|
+
* subscribe(pipe(foo, debounceTime(50)), val => {
|
|
218
|
+
* console.log(value); // 3
|
|
219
|
+
* })
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
export function debounceTime(interval) {
|
|
223
|
+
var currentValue;
|
|
224
|
+
var timeout;
|
|
225
|
+
return function (done) { return function (value) {
|
|
226
|
+
currentValue = value;
|
|
227
|
+
if (timeout) {
|
|
228
|
+
clearTimeout(timeout);
|
|
229
|
+
}
|
|
230
|
+
timeout = setTimeout(function () {
|
|
231
|
+
done(currentValue);
|
|
232
|
+
}, interval);
|
|
233
|
+
}; };
|
|
234
|
+
}
|
|
235
|
+
export function withLatestFrom() {
|
|
236
|
+
var sources = [];
|
|
237
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
238
|
+
sources[_i] = arguments[_i];
|
|
239
|
+
}
|
|
240
|
+
var values = new Array(sources.length);
|
|
241
|
+
var called = 0;
|
|
242
|
+
var pendingCall = null;
|
|
243
|
+
var allCalled = Math.pow(2, sources.length) - 1;
|
|
244
|
+
sources.forEach(function (source, index) {
|
|
245
|
+
var bit = Math.pow(2, index);
|
|
246
|
+
subscribe(source, function (value) {
|
|
247
|
+
var prevCalled = called;
|
|
248
|
+
called = called | bit;
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
250
|
+
values[index] = value;
|
|
251
|
+
if (prevCalled !== allCalled && called === allCalled && pendingCall) {
|
|
252
|
+
pendingCall();
|
|
253
|
+
pendingCall = null;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
return function (done) { return function (value) {
|
|
258
|
+
var call = function () { return done([value].concat(values)); };
|
|
259
|
+
if (called === allCalled) {
|
|
260
|
+
call();
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
pendingCall = call;
|
|
264
|
+
}
|
|
265
|
+
}; };
|
|
266
|
+
}
|